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//! - **Trend**: Indicators designed to identify market direction
18//! - **Momentum**: Indicators that measure the rate of price change
19//!
20//! ## Usage Example
21//!
22//! ```rust
23//! use polars::prelude::*;
24//! use technical_indicators::indicators::moving_averages::sma::calculate_sma;
25//!
26//! fn main() -> PolarsResult<()> {
27//! let close_prices = Series::new(
28//!         "close".into(),
29//!         &[
30//!             100.0, 101.0, 102.0, 103.0, 105.0, 104.0, 106.0, 107.0, 109.0, 108.0,
31//!             107.0, 109.0, 111.0, 114.0, 113.0, 116.0, 119.0, 120.0, 119.0, 117.0,
32//!             118.0, 120.0, 123.0, 122.0, 120.0, 118.0, 119.0, 121.0, 124.0, 125.0,
33//!         ],
34//!     );
35//!     // Create a sample DataFrame with price data
36//!     let mut df = DataFrame::new(vec![close_prices.clone().into()])?;
37//!
38//!     // Calculate a Simple Moving Average
39//!     let sma_10 = calculate_sma(&df, "close", 10)?;
40//!     df.with_column(sma_10)?;
41//!
42//!     println!("{}", df);
43//!     Ok(())
44//! }
45//! ```
46//!
47//! See the documentation for each module for more detailed information and examples.
48
49pub mod indicators;
50pub mod util;
51
52// Re-export commonly used items
53pub use indicators::*;
54
55// This is a placeholder function - should be removed before final release
56pub fn add(left: u64, right: u64) -> u64 {
57    left + right
58}
59
60#[cfg(test)]
61mod tests {
62    use super::*;
63
64    #[test]
65    fn it_works() {
66        let result = add(2, 2);
67        assert_eq!(result, 4);
68    }
69}