Skip to main content

polars_ta_classic/
lib.rs

1//! # polars-ta-classic
2//!
3//! A 1-to-1 Rust/Polars reimplementation of
4//! [pandas-ta-classic](https://github.com/xgboosted/pandas-ta-classic).
5//!
6//! Provides 150 technical-analysis indicators across 9 categories:
7//! momentum (45), overlap (36), trend (18), volume (17), volatility (14),
8//! statistics (10), candles (5), performance (3), cycles (2).
9
10// TA indicators inherently take many parameters and rely on indexed
11// access to prior bars; both patterns are intrinsic to the algorithms.
12#![allow(clippy::too_many_arguments, clippy::needless_range_loop)]
13
14use thiserror::Error;
15
16pub mod candles;
17pub mod cycles;
18pub mod momentum;
19pub mod overlap;
20pub mod performance;
21pub mod statistics;
22pub mod trend;
23pub mod utils;
24pub mod volatility;
25pub mod volume;
26
27/// Errors returned by indicator functions.
28#[derive(Debug, Error)]
29pub enum TaError {
30    #[error("polars error: {0}")]
31    Polars(#[from] polars::prelude::PolarsError),
32
33    #[error("insufficient data: need at least {need} rows, got {got}")]
34    InsufficientData { need: usize, got: usize },
35
36    #[error("invalid parameter: {0}")]
37    InvalidParameter(String),
38}
39
40pub type TaResult<T> = Result<T, TaError>;