quantlab.factor.kunquant_ts.EWCov#

class quantlab.factor.kunquant_ts.EWCov(y, x, window, half_life)[source]#

Bases: _EWWindowOp

Exponentially weighted window covariance of y and x.

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 first window - 1 bars 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 < 1 or half_life <= 0.

Examples

>>> Output(EWCov(Input("ret"), Input("market"), 252, 63), "cov")
decompose(options)[source]#

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