quantlab.factor.kunquant_ts.EWVar#
- class quantlab.factor.kunquant_ts.EWVar(v, window, half_life)[source]#
Bases:
_EWWindowOpExponentially weighted window variance,
sum(w * (x - m)**2) / sum(w).mis theEWMeanof 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 firstwindow - 1bars 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 < 1orhalf_life <= 0.
Examples
>>> Output(Sqrt(EWVar(Input("ret"), 252, 42)), "dastd")