quantlab.factor.predefined.residual_momentum.ResidualMomentumFF3#
- class quantlab.factor.predefined.residual_momentum.ResidualMomentumFF3(config)[source]#
Bases:
FactorKunQuantResidual momentum estimated from a Fama-French three-factor regression.
Formula settings, the Fama-French CSV and optional column renames live in
config.kwargs(seeResidualMomentumParameters). The usual setup on a CRSP daily panel names the CSV infama_french_csvand reads only the panel’sret; the four factor series are then compounded onto the panel’s bars bycompound_onto_bars()and broadcast across symbols before they reach KunQuant. Without a CSV the panel must already carry all five inputs, broadcast across symbols.With the defaults on daily bars, the signal at bar
dfits the regression on barsd-755todand sums residuals over barsd-251tod-21. It uses data up to bardonly, so it can be traded from bard+1.config.warmup_barsis the warm-up in bars thatcomputereads beforestart, like every factor: 756 covers the regression window.Outputs are
resmom_raw(the score) andresmom_rank(its cross-sectional rank in[0, 1]per bar), plus the diagnostics listed in_DIAGNOSTIC_FACTOR_NAMESwhenemit_diagnosticsis on. Stream mode needs the five inputs on the panel and refuses a CSV.- Parameters:
- factor_configFactorConfig
The KunQuant factor config.
data_columnsmust name exactlyResidualMomentumParameters.panel_columns, andfactor_namesmay pick any subset of the outputs.
- Raises:
- ValueError
If
data_columnsdoes not match the panel columns, iffactor_namesnames an unknown output, or ifkwargsholds an unknown or invalid parameter.
Examples
datasetis aCrspStockDatasetover a daily market store andff3_daily.csvthe filescripts/fama_french.pywrites.>>> config = FactorConfig( ... warmup_bars=756, ... dataset=dataset, ... mode="batch", ... data_columns=("ret",), ... factor_names=("resmom_raw", "resmom_rank"), ... file_path="resmom.zarr", ... kwargs={"fama_french_csv": "downloads/fama_french/ff3_daily.csv"}, ... ) >>> factor = ResidualMomentumFF3(config) >>> factor.get_factor_names() ('resmom_raw', 'resmom_rank')