ta_lib_in_rust/
lib.rs

1//! # Technical Indicators
2//!
3//! A comprehensive Rust library for calculating financial technical indicators
4//! using the [Polars](https://pola.rs/) DataFrame library.
5//!
6//! This crate provides functions to calculate various technical indicators
7//! from OHLCV (Open, High, Low, Close, Volume) data stored in Polars DataFrames.
8//!
9//! ## Categories
10//!
11//! The indicators are organized into the following categories:
12//!
13//! - **Moving Averages**: Trend-following indicators that smooth price data
14//! - **Oscillators**: Indicators that fluctuate within a bounded range
15//! - **Volatility**: Indicators that measure the rate of price movement
16//! - **Volume**: Indicators based on trading volume
17//! - **Momentum**: Indicators that measure the rate of price change
18//!
19//! ## Usage Examples
20//!
21//! ### Basic Indicator Calculation
22//!
23//! ```rust
24//! use polars::prelude::*;
25//! use ta_lib_in_rust::indicators::moving_averages::calculate_sma;
26//!
27//! fn main() -> PolarsResult<()> {
28//!     let close_prices = Series::new(
29//!         "close".into(),
30//!         &[
31//!             100.0, 101.0, 102.0, 103.0, 105.0, 104.0, 106.0, 107.0, 109.0, 108.0,
32//!             107.0, 109.0, 111.0, 114.0, 113.0, 116.0, 119.0, 120.0, 119.0, 117.0,
33//!             118.0, 120.0, 123.0, 122.0, 120.0, 118.0, 119.0, 121.0, 124.0, 125.0,
34//!         ],
35//!     );
36//!     // Create a sample DataFrame with price data
37//!     let mut df = DataFrame::new(vec![close_prices.clone().into()])?;
38//!
39//!     // Calculate a Simple Moving Average
40//!     let sma_10 = calculate_sma(&df, "close", 10)?;
41//!     df.with_column(sma_10)?;
42//!
43//!     println!("{}", df);
44//!     Ok(())
45//! }
46//! ```
47//!
48//! ## Advanced Intraday Strategy Example
49//!
50//! See `examples/enhanced_minute_strategy_example.rs` for a full example of an advanced minute-level multi-indicator strategy. This example demonstrates:
51//!
52//! - Loading minute-level OHLCV data from CSV
53//! - Running a multi-indicator strategy with risk management
54//! - Calculating and printing performance metrics
55//! - Saving all signals and indicators to a CSV file (`enhanced_minute_strategy_results.csv`) for further analysis
56//!
57//! See the documentation for each module for more detailed information and examples.
58
59pub mod indicators;
60pub mod util;
61
62// Re-export commonly used items
63pub use indicators::*;
64
65// This is a placeholder function - should be removed before final release
66pub fn add(left: u64, right: u64) -> u64 {
67    left + right
68}
69
70#[cfg(test)]
71mod tests {
72    use super::*;
73
74    #[test]
75    fn it_works() {
76        let result = add(2, 2);
77        assert_eq!(result, 4);
78    }
79}