1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
//! # Utils Module
//!
//! This module provides various utility functions, types, and tools for common tasks
//! across the library, including logging, time handling, testing, and general-purpose
//! utilities.
//!
//! ## Core Components
//!
//! ### Logger (`logger.rs`)
//!
//! Provides logging functionality with configurable log levels:
//!
//! ```rust
//! use optionstratlib::utils::logger::{setup_logger, setup_logger_with_level};
//! ```
//!
//! ### Time (`time.rs`)
//!
//! Handles various time frames for financial calculations:
//!
//! ```rust
//! use positive::pos_or_panic;
//! use optionstratlib::utils::time::TimeFrame;
//!
//! let daily = TimeFrame::Day;
//! let trading_days_per_year = daily.periods_per_year(); // Returns 252.0
//!
//! let custom = TimeFrame::Custom(pos_or_panic!(365.0));
//! let periods = custom.periods_per_year(); // Returns 365.0
//! ```
//!
//! ### Testing (`tests.rs`)
//!
//! Provides testing utilities and macros for relative equality assertions:
//!
//! ```rust
//! use positive::{Positive,assert_pos_relative_eq,pos_or_panic};
//!
//! let a = Positive::ONE;
//! let b = pos_or_panic!(1.0001);
//! let epsilon = pos_or_panic!(0.001);
//! assert_pos_relative_eq!(a, b, epsilon);
//! ```
//!
//! ### Other Utilities (`others.rs`)
//!
//! General-purpose utility functions:
//!
//! ```rust
//! use optionstratlib::utils::others::{approx_equal, get_random_element, process_n_times_iter};
//! use std::collections::BTreeSet;
//!
//! // Approximate equality comparison
//! let equal = approx_equal(1.0, 1.0001);
//!
//! // Get random element from a set
//! let mut set = BTreeSet::new();
//! set.insert(1);
//! set.insert(2);
//! let random = get_random_element(&set);
//!
//! // Process combinations
//! let numbers = vec![1, 2, 3];
//! let result = process_n_times_iter(&numbers, 2, |combination| {
//! vec![combination[0] + combination[1]]
//! });
//! ```
//!
//! ## Time Frame Support
//!
//! The module supports various time frames for financial calculations:
//!
//! - Microsecond
//! - Millisecond
//! - Second
//! - Minute
//! - Hour
//! - Day
//! - Week
//! - Month
//! - Quarter
//! - Year
//! - Custom periods
//!
//! ### Example: Time Frame Usage
//!
//! ```rust
//! use tracing::info;
//! use positive::pos_or_panic;
//! use optionstratlib::utils::time::TimeFrame;
//!
//! let timeframes = vec![
//! TimeFrame::Day,
//! TimeFrame::Week,
//! TimeFrame::Month,
//! TimeFrame::Custom(pos_or_panic!(360.0))
//! ];
//!
//! for tf in timeframes {
//! info!("Periods per year: {}", tf.periods_per_year());
//! }
//! ```
//!
//! ## Logging Configuration
//!
//! Log levels can be configured through:
//! - Environment variable `LOGLEVEL`
//! - Direct specification in code
//!
//! Supported levels:
//! - DEBUG
//! - INFO
//! - WARN
//! - ERROR
//! - TRACE
//!
//! ### Example: Logging Setup
//!
//! ```rust
//! use optionstratlib::utils::logger::setup_logger_with_level;
//! use tracing::{debug, info, warn};
//!
//! // Setup with specific level
//!
//!
//! // Log messages
//! debug!("Detailed information for debugging");
//! info!("General information about program execution");
//! warn!("Warning messages for potentially harmful situations");
//! ```
//!
//! ## Testing Utilities
//!
//! The module provides testing utilities for:
//! - Relative equality comparisons for Positive
//! - Approximate floating-point comparisons
//! - Random element selection testing
//!
//! ### Example: Testing Positive Values
//!
//! ```rust
//! use positive::{Positive,pos_or_panic,assert_pos_relative_eq};
//!
//! fn test_values() {
//! let a = Positive::ONE;
//! let b = pos_or_panic!(1.0001);
//! let epsilon = pos_or_panic!(0.001);
//! assert_pos_relative_eq!(a, b, epsilon);
//! }
//! ```
//!
//! ## Performance Considerations
//!
//! - Logger initialization is thread-safe and happens only once
//! - Time frame calculations are constant-time operations
//! - Random element selection is O(n) where n is the set size
//! - Process combinations has complexity based on combination size
//!
//! ## Implementation Notes
//!
//! - Logger uses the `tracing` crate for structured logging
//! - Time frames use predefined constants for standard periods
//! - Testing utilities provide accurate floating-point comparisons
//! - Utility functions handle edge cases and error conditions
/// This module contains the logger setup and configuration. It provides functionality for
/// initializing the logger, setting log levels, and formatting log messages. It uses the `tracing`
/// crate for structured logging and supports various log levels.
/// This module contains other miscellaneous modules and functions. It acts as a container for
/// functionality that doesn't fit neatly into the main project structure. More specific
/// documentation can be found within each sub-module.
/// This module contains the CSV reader and writer for OHLCV data. It provides functionality for
/// reading and writing OHLCV data in CSV format, as well as handling errors related to CSV
/// parsing.
/// This module contains the file reader and writer for OHLCV data. It provides functionality for
/// reading and writing OHLCV data in various file formats, including CSV and JSON.
/// Module for time-related utilities.
/// This module contains traits and type definitions used throughout the library. It provides
/// functionality for defining and implementing common traits, as well as type aliases for
/// convenience.
pub use read_ohlcv_from_zip_async;
pub use ;
pub use ;
pub use ;
pub use TimeFrame;
pub use Len;