quantlab.factor.predefined.alpha158.Alpha158SpotKline#

class quantlab.factor.predefined.alpha158.Alpha158SpotKline(factor_config)[source]#

Bases: TimeSeriesZScoredFactor

Alpha158 factors over crypto spot klines, z-scored along time.

Builds the Alpha158 feature set from the lowercase open, high, low, close, volume and amount (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 features BETA, RSQR and RESI are left out. Every output is wrapped in WindowedZScore over zscore_window bars (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; Alpha158Stock z-scores across symbols for cross-sectional strategies instead.

Set factor_names to 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_bars must cover the longest feature window (60 bars for the full set) plus zscore_window - 1 bars for the first requested bar to be fully normalized. data_columns lists the six input columns above, and factor_names selects 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")