qis.compute_ewm¶
- qis.compute_ewm(data, span=None, ewm_lambda=0.94, init_value=None, init_type=InitType.X0, is_unit_vol_scaling=False, nan_backfill=NanBackfill.FFILL)[source]¶
exponentially weighted moving average of a t-by-n panel.
Implements the recursion
m_t = (1 - lambda) x_t + lambda m_{t-1}, evaluated column-wise by the numba kernelewm_recursion(). The seed is the state before each column’s first finite observation, and that observation updates it, so with the defaultX0seed the result is pandasewm(adjust=False)column by column, however late a column starts. The container type ofdatais preserved.- Parameters:
data (DataFrame | Series | ndarray) – observations, time along the first axis
span (float | ndarray) – if given, overrides
ewm_lambdavialambda = 1 - 2 / (span + 1), the same correspondence pandas usesewm_lambda (float | ndarray) – decay in [0, 1); higher is smoother. Ignored when
spanis giveninit_value (float | ndarray | None) – explicit seed, the state before the first observation; overrides
init_typeinit_type (InitType) – how the seed is set when
init_valueis None — the first observation (X0), zero, or the full-sample mean (look-ahead); seeInitTypeis_unit_vol_scaling (bool) – rescale the output to unit unconditional variance
nan_backfill (NanBackfill) – how the recursion carries over missing observations
- Returns:
smoothed data, same container and shape as
data- Raises:
ValueError – if the selected span or decay is outside the stable EWM domain, the decay shape is incompatible with the data, or
init_typeisInitType.VAR- Return type: