Expand description
Pure indicator math library for trading.
All functions are pure math - no I/O, no async, WASM-compatible.
§Example
use quant_indicators::{Indicator, Sma, Ema};
use quant_primitives::Candle;
use chrono::Utc;
use rust_decimal_macros::dec;
let ts = Utc::now();
let candles: Vec<Candle> = (0..20).map(|i| {
Candle::new(dec!(100), dec!(110), dec!(90), dec!(100) + rust_decimal::Decimal::from(i), dec!(1000), ts).unwrap()
}).collect();
let sma = Sma::new(20).unwrap();
let series = sma.compute(&candles).unwrap();
// Indicators are composable
let ema = Ema::new(20).unwrap();
let ema_series = ema.compute(&candles).unwrap();Modules§
- hrp
- Hierarchical Risk Parity (HRP) — pure math functions.
Structs§
- Atr
- Average True Range indicator.
- Bollinger
Bands - Bollinger Bands indicator.
- Bollinger
Result - Bollinger Bands result containing all three bands.
- Close
- Passthrough indicator that returns close prices.
- Detrended
Oscillator - Detrended Oscillator: (close - HMA) / ATR.
- Diff
- Difference between two indicators: A - B
- Efficiency
Ratio - Kaufman Efficiency Ratio indicator.
- Ema
- Exponential Moving Average indicator.
- HullMa
- Hull Moving Average indicator.
- Hurst
Exponent - Hurst Exponent regime classifier via R/S analysis.
- Kalman
Filter - Kalman filter with a Local Linear Trend state-space model.
- Kalman
Result - Kalman filter result containing all five output series.
- Lag
- Lag shifts indicator values by N periods.
- Macd
- MACD indicator.
- Momentum
- Momentum indicator.
- Ratio
- Ratio between two indicators: A / B
- RollingZ
Score - Rolling z-score over a sliding window of scalar observations.
- Rsi
- Relative Strength Index indicator.
- Scale
- Scale multiplies indicator values by a constant factor.
- Series
- A time-indexed series of values.
- Sma
- Simple Moving Average indicator.
- StdDev
- Standard Deviation indicator.
- Supertrend
- Supertrend trend-direction indicator.
- Variance
Ratio - Variance Ratio regime classifier.
- VolSignal
Config - Configuration for the VolumeSignal indicator.
- Volume
Signal - Output of the VolumeSignal indicator for a single candle.
- Volume
Signal Indicator - Volume anomaly indicator.
- Wma
- Weighted Moving Average indicator.
Enums§
- Indicator
Error - Errors that can occur during indicator computation.
- Ma
- Generic moving average — dispatches to the concrete MA variant.
- MaType
- Moving average type selector.
- Ratio
Candle Error - Errors from ratio candle synthesis.
- Volume
Anomaly - Classification of volume activity relative to rolling baseline.
Traits§
- Classification
Indicator - A classification indicator that maps each candle to a typed domain outcome.
- Indicator
- A technical indicator that computes a continuous numeric time series.
Functions§
- compute_
log_ returns - Compute log-returns as simple percentage changes: (P[i] - P[i-1]) / P[i-1].
- estimate_
slope - Estimate the Hurst exponent H from the log-log slope of R/S vs subseries size.
- ratio_
close_ series - Return only the closes of a synthetic ratio series — convenience for
callers that want a
(timestamp, ratio_close)series for statistical analysis (Hurst, Variance Ratio, autocorrelation). - rescaled_
range_ for_ n - Compute the average Rescaled Range statistic for a given subseries size
n. - rolling_
atr_ mean - Compute the simple mean of true-range values in a sliding window.
- synthesize_
ratio_ candles - Synthesize ratio candles A/B from two aligned candle series.
- true_
range - Calculate True Range for a candle given previous close.