Skip to content
GeneratedGenerated from the built extension by scripts/generate_python_api_reference.py; CI fails if it is stale.

openquant.fast_ewma

Compiled from Rust (crates/pyopenquant). Signatures and types are from the shipped .pyi stubs; descriptions are the functions’ own docstrings, as help() shows them. All Python modules.

Functions

ewma

ewma(arr: Sequence[float], window: int) -> list[float]

Bias-corrected exponentially weighted moving average with span window.

Matches mlfinlab.util.fast_ewma.ewma and pandas' ewm(span=window, adjust=True).mean(): with alpha = 2 / (window + 1), output t is the weighted mean of every value so far, with weight (1 - alpha)^k on the value k steps back. The first output equals the first input, and window = 1 returns the input unchanged. window is a span, not a hard lookback. Values are not validated: a NaN makes that output and every later one NaN (pandas would skip it).

Parameters

arr : list[float]

Input series, oldest first.

window : int

Span of the average; must be positive.

Returns

list[float]

The moving average, same length as arr (empty for an empty input).

Raises

ValueError

If window is 0.