quantlab.factor.kunquant_ts#
Custom KunQuant time-series operators: each symbol against its own past.
KunQuant is the library this project uses to compute most factors. A factor
formula is written as a graph of operators (WindowedAvg, Rank, …),
and KunQuant compiles that graph to native C++ code that runs over a whole
(timestamp, symbol) array at once. This module adds operators that look
along time, one symbol at a time; quantlab.factor.kunquant_cs has the
ones that look across symbols on one bar.
WindowedZScore is a time-series normalization: each symbol is compared
with its own recent past. Its cross-sectional counterpart,
kunquant_cs.CrossSectionalZScore, compares each symbol with all the other
symbols on the same bar. Which one is right depends on the strategy that
consumes the factor. A strategy that trades one asset over time wants the
first; a strategy that ranks many assets against each other wants the
second. They are not two implementations of the same thing.
The exponentially weighted window statistics (EWSum, EWMean,
EWVar, EWCov, EWBeta, EWAlpha, EWResidualStd) weight the
trailing window bars by 0.5 ** (age / half_life), where age is 0
for the current bar, and skip missing values. CMRA is USE4’s cumulative
range of monthly returns. BarraStyle
(quantlab.factor.predefined.barra) uses them; any factor can.
Classes
USE4's cumulative range of monthly returns, from a series of daily log returns. |
|
Intercept of the exponentially weighted least-squares fit of |
|
Slope of the exponentially weighted least-squares fit of |
|
Exponentially weighted window covariance of |
|
Exponentially weighted window mean, |
|
Standard deviation of the residual of |
|
Exponentially weighted window sum, |
|
Exponentially weighted window variance, |
|
Rolling z-score along time, |