quantlab.factor.kunquant_ts.WindowedZScore#
- class quantlab.factor.kunquant_ts.WindowedZScore(v, window, v2=None)[source]#
Bases:
WindowedCompositiveOpRolling z-score along time,
(x - rolling_mean) / rolling_std.Each symbol is standardized against its own trailing
windowbars; nothing is computed across symbols. NaN inputs propagate, and the firstwindow - 1bars are NaN until the window is full, as with every KunQuant rolling operator. No fill is applied, so fill missing values in the caller if you need them.The operator is a composite op: KunQuant replaces it with simpler built-in operators (see
decompose) while compiling.- Parameters:
- vOpBase
The input series, usually a factor expression.
- windowint
Number of trailing bars the mean and standard deviation use.
Examples
>>> Output(WindowedZScore(alpha(all_data), 20), "alpha001")
- decompose(options)[source]#
Expand into
WindowedAvg,WindowedStddev,SubandDiv.KunQuant calls this while compiling the graph.
- Parameters:
- optionsdict
Decomposition options passed by KunQuant. Unused, but required by KunQuant’s composite-operator interface.
- Returns:
- list[OpBase]
The replacement operators, in dependency order.
Examples
It can also be called directly on an op built inside a
Builder:>>> with Builder(): ... z = WindowedZScore(Input("close"), 20) >>> [type(op).__name__ for op in z.decompose({})] ['WindowedAvg', 'WindowedStddev', 'Sub', 'Div']