quantlab.factor.kunquant_ts.EWSum#
- class quantlab.factor.kunquant_ts.EWSum(v, window, half_life)[source]#
Bases:
_EWWindowOpExponentially weighted window sum,
sum(w_age * x)over valid bars.The weights are
w_age = 0.5 ** (age / half_life)over the trailingwindowbars,age0 being the current bar; they are not normalized. A NaN or infinite value adds nothing. The result is NaN for the firstwindow - 1bars and 0 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(EWSum(Input("ret"), 252, 63), "ret_ew_sum")