quantlab.factor.kunquant_ts.EWVar#

class quantlab.factor.kunquant_ts.EWVar(v, window, half_life)[source]#

Bases: _EWWindowOp

Exponentially weighted window variance, sum(w * (x - m)**2) / sum(w).

m is the EWMean of the same window and the sums run over the valid bars. The variance is the weighted population variance: no small-sample correction is applied, as in USE4’s DASTD. NaN for the first window - 1 bars and for a window with no valid value.

Parameters:
vOpBase

The input series.

windowint

Number of trailing bars, the current one included.

half_lifefloat

Age in bars at which the weight is one half.

Raises:
ValueError

If window < 1 or half_life <= 0.

Examples

>>> Output(Sqrt(EWVar(Input("ret"), 252, 42)), "dastd")
decompose(options)[source]#

Expand into two window loops; KunQuant calls this while compiling.