Skip to content
GeneratedAssembled automatically from moduleDocs.ts. No human has reviewed this page.

util::fast_ewma

One function: a single-pass exponentially weighted moving average with span-style decay, alpha = 2/(window+1), corrected by the accumulated weight so that early values are not dragged toward the seed. It mirrors mlfinlab.util.fast_ewma exactly, which is the point — it is what makes daily volatility and every EWMA-derived feature numerically comparable between this library and a pandas reference implementation.

Use it instead of writing a rolling loop, so that everything downstream — util::volatility’s daily vol, the microstructure feature panel, dynamic threshold series for filters — shares one decay convention. Remember that window is a span rather than a hard lookback: the weight on a point w bars back is (1-alpha)^w, not zero, so the estimate remembers further than the number suggests. Size the span longer than the horizon you are trying to smooth over.

mt=αxt+(1α)mt1m_t=\alpha x_t + (1-\alpha)m_{t-1}

α=2w+1\alpha=\frac{2}{w+1}

use openquant::util::fast_ewma::ewma;
let x = vec![1.0, 2.0, 3.0, 4.0];
let y = ewma(&x, 3);
  • fast_ewma.ewma
  • ewma
  • Window length controls responsiveness vs smoothness.
  • Prefer this helper over ad-hoc loops for consistency.