Skip to main content

Crate quant_indicators

Crate quant_indicators 

Source
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.
BollingerBands
Bollinger Bands indicator.
BollingerResult
Bollinger Bands result containing all three bands.
Close
Passthrough indicator that returns close prices.
DetrendedOscillator
Detrended Oscillator: (close - HMA) / ATR.
Diff
Difference between two indicators: A - B
EfficiencyRatio
Kaufman Efficiency Ratio indicator.
Ema
Exponential Moving Average indicator.
HullMa
Hull Moving Average indicator.
HurstExponent
Hurst Exponent regime classifier via R/S analysis.
KalmanFilter
Kalman filter with a Local Linear Trend state-space model.
KalmanResult
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
RollingZScore
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.
VarianceRatio
Variance Ratio regime classifier.
VolSignalConfig
Configuration for the VolumeSignal indicator.
VolumeSignal
Output of the VolumeSignal indicator for a single candle.
VolumeSignalIndicator
Volume anomaly indicator.
Wma
Weighted Moving Average indicator.

Enums§

IndicatorError
Errors that can occur during indicator computation.
Ma
Generic moving average — dispatches to the concrete MA variant.
MaType
Moving average type selector.
RatioCandleError
Errors from ratio candle synthesis.
VolumeAnomaly
Classification of volume activity relative to rolling baseline.

Traits§

ClassificationIndicator
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.