quantlab.factor.predefined.alpha158.Alpha158SpotKline#
- class quantlab.factor.predefined.alpha158.Alpha158SpotKline(factor_config)[source]#
Bases:
TimeSeriesZScoredFactorAlpha158 factors over crypto spot klines, z-scored along time.
Builds the Alpha158 feature set from the lowercase
open,high,low,close,volumeandamount(traded value) columns: k-bar shape features, price and volume ratios lagged 0 to 4 bars, and rolling features over 5, 10, 20, 30 and 60 bars. The rolling regression featuresBETA,RSQRandRESIare left out. Every output is wrapped inWindowedZScoreoverzscore_windowbars (kwargs["zscore_window"], default 20), which standardizes each symbol against its own recent past. That suits the time-series strategies spot data is traded with here;Alpha158Stockz-scores across symbols for cross-sectional strategies instead.Set
factor_namesto a few columns while experimenting: the full set has over a hundred columns, and compile time grows with the graph.- Parameters:
- factor_configFactorConfig
The KunQuant factor config.
kwargs["zscore_window"]sets the z-score window.warmup_barsmust cover the longest feature window (60 bars for the full set) pluszscore_window - 1bars for the first requested bar to be fully normalized.data_columnslists the six input columns above, andfactor_namesselects which features to compute (all when unset).
Examples
>>> factor = Alpha158SpotKline(FactorConfig( ... warmup_bars=24, dataset=dataset, mode="batch", ... data_columns=["open", "high", "low", "close", "volume", "amount"], ... factor_names=["KMID", "STD5"], kwargs={"zscore_window": 20}, ... file_path="alpha158.zarr", ... )) >>> panel = factor.compute("2024-01-01", "2024-06-30")