Skip to main content

Module bbands

Module bbands 

Source
Expand description

Native Bollinger Bands — TA-Lib parity, incremental for every matype.

Both paths are streaming and bounded-memory:

  • MaType::Sma — O(1) amortised per bar via RollingVariance, a shifted-data accumulator with a deterministic periodic exact refresh. It replaced a sum / sum_sq pair whose E[X²] - E[X]² evaluation lost ~1e-6 relative precision on slowly-varying inputs (quantwave-qkft).
  • every other MaType — the middle band comes from MaStream, and the deviation is a two-pass sum of squared deviations over a rolling window of timeperiod inputs (O(timeperiod) per bar), exactly as the batch talib_rs::overlap::bbands non-SMA path computes it.

The non-SMA path used to push every bar onto an ever-growing history and re-run the batch bbands over the whole thing, i.e. O(n) per bar / O(n²) per series plus an unbounded memory leak in long-running streams.

Structs§

BBANDS
Bollinger Bands — matches talib_rs::overlap::bbands for every matype.