quantlab.factor.kunquant_ts.EWCov#
- class quantlab.factor.kunquant_ts.EWCov(y, x, window, half_life)[source]#
Bases:
_EWWindowOpExponentially weighted window covariance of
yandx.sum(w * (x - m_x) * (y - m_y)) / sum(w)over the bars where both are valid, the means taken over the same bars. A weighted population covariance, symmetric in its two inputs. NaN for the firstwindow - 1bars and for a window with no bar where both are valid.- Parameters:
- y, xOpBase
The two 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(EWCov(Input("ret"), Input("market"), 252, 63), "cov")