Skip to main content

Crate polars_ta_core

Crate polars_ta_core 

Source
Expand description

§polars-ta-core

Pure algorithm layer for polars-ta. All functions operate on &[f64] slices and have zero external dependencies, making this crate suitable for embedded systems, WASM, and no_std environments.

§Output Convention

Output arrays are shorter than input arrays by lookback elements, matching ta-lib’s C API behavior exactly:

Input:  [v0, v1, v2, v3, v4, v5, v6, v7, v8, v9]  len=10
SMA(3): lookback=2
Output:       [v2', v3', v4', v5', v6', v7', v8', v9']  len=8

The caller is responsible for aligning output indices with the original input.

§Error Handling

  • Input length < lookback + 1: returns an empty Vec (never panics)
  • NaN inputs: once a NaN enters the sliding sum, all subsequent outputs are NaN (IEEE 754 arithmetic, identical to ta-lib C behavior)
  • All-NaN inputs: returns all-NaN output of correct length

§Modules

  • trend — SMA, EMA, WMA, DEMA, TEMA, MACD, BBands, SAR, ADX
  • oscillator — RSI, Stoch, StochRSI, CCI, Williams %R, ULTOSC, Aroon, MFI
  • volume — OBV, AD, ADOSC
  • volatility — ATR, NATR, TRange
  • price_transform — AVGPRICE, MEDPRICE, TYPPRICE, WCLPRICE
  • math_transform — ACOS, ASIN, ATAN, CEIL, COS, COSH, EXP, FLOOR, LN, LOG10, SIN, SINH, SQRT, TAN, TANH
  • math_ops — ADD, DIV, MULT, SUB, MAX, MIN, SUM, MAXINDEX, MININDEX, MINMAX, MINMAXINDEX

Modules§

hilbert
Hilbert Transform indicators — 6 functions matching ta-lib exactly.
math_ops
Math Operator indicators: arithmetic operations and rolling window statistics.
math_transform
Math Transform — Element-wise Mathematical Functions
oscillator
Oscillator indicators: momentum and mean-reversion oscillators.
pattern
Candlestick pattern recognition — 61 patterns matching ta-lib.
price_transform
statistic
Statistical indicators: regression, correlation, variance, and forecast functions.
trend
Trend indicators: moving averages and trend-following oscillators.
volatility
Volatility indicators: average true range and related measures.
volume
Volume indicators: accumulation/distribution and volume flow.