Skip to main content

quant_indicators/
lib.rs

1#![cfg_attr(
2    test,
3    allow(
4        clippy::expect_used,
5        clippy::unwrap_used,
6        clippy::panic,
7        clippy::indexing_slicing
8    )
9)]
10
11//! Pure indicator math library for trading.
12//!
13//! All functions are pure math - no I/O, no async, WASM-compatible.
14//!
15//! # Example
16//!
17//! ```
18//! use quant_indicators::{Indicator, Sma, Ema};
19//! use quant_primitives::Candle;
20//! use chrono::Utc;
21//! use rust_decimal_macros::dec;
22//!
23//! let ts = Utc::now();
24//! let candles: Vec<Candle> = (0..20).map(|i| {
25//!     Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
26//! }).collect();
27//! let sma = Sma::new(20).unwrap();
28//! let series = sma.compute(&candles).unwrap();
29//!
30//! // Indicators are composable
31//! let ema = Ema::new(20).unwrap();
32//! let ema_series = ema.compute(&candles).unwrap();
33//! ```
34
35mod test_helpers;
36
37mod atr;
38mod bollinger;
39mod close;
40mod combinators;
41mod detrended;
42mod efficiency_ratio;
43mod ema;
44mod error;
45pub mod hrp;
46mod hull;
47mod hurst;
48mod indicator;
49mod kalman;
50mod ma;
51mod ma_type;
52mod macd;
53mod momentum;
54mod ratio_candles;
55mod rolling_zscore;
56mod rsi;
57mod series;
58mod sma;
59mod stddev;
60mod supertrend;
61mod variance_ratio;
62mod volume_signal;
63mod wma;
64
65pub use atr::{rolling_atr_mean, true_range, Atr};
66pub use bollinger::{BollingerBands, BollingerResult};
67pub use close::Close;
68pub use combinators::{Diff, Lag, Ratio, Scale};
69pub use detrended::DetrendedOscillator;
70pub use efficiency_ratio::EfficiencyRatio;
71pub use ema::Ema;
72pub use error::IndicatorError;
73pub use hull::HullMa;
74pub use hurst::{compute_log_returns, estimate_slope, rescaled_range_for_n, HurstExponent};
75pub use indicator::{ClassificationIndicator, Indicator};
76pub use kalman::{KalmanFilter, KalmanResult};
77pub use ma::Ma;
78pub use ma_type::MaType;
79pub use macd::Macd;
80pub use momentum::Momentum;
81pub use ratio_candles::{ratio_close_series, synthesize_ratio_candles, RatioCandleError};
82pub use rolling_zscore::RollingZScore;
83pub use rsi::Rsi;
84pub use series::Series;
85pub use sma::Sma;
86pub use stddev::StdDev;
87pub use supertrend::Supertrend;
88pub use variance_ratio::VarianceRatio;
89pub use volume_signal::{VolSignalConfig, VolumeAnomaly, VolumeSignal, VolumeSignalIndicator};
90pub use wma::Wma;