Qlib Alpha158 Ridge Model and CSI 300 Top-K Backtest Setup
Summary
This Qlib configuration defines a Chinese-equity ranking workflow using the Alpha158 feature handler and a ridge linear model. It assigns CSI 300 instruments and the related index benchmark, with historical data split into training, validation, and test segments. Feature processing applies robust z-score normalization with outlier clipping and fills missing values; labels are cross-sectionally rank-normalized after rows without labels are dropped.
For portfolio analysis, the setup uses a top-k dropout strategy that holds the highest-ranked names and replaces a subset as rankings change. The backtest includes a specified account size, benchmark, close-price dealing, transaction costs, minimum commission, and a price-limit threshold. Signal and portfolio analysis records are configured as outputs. This is an experiment template, not a report: it includes no measured returns, risk statistics, or comparison against alternatives, and results would depend on data quality, implementation assumptions, and model behavior.
Key ideas
- The workflow pairs Alpha158 features with a ridge linear model for Chinese equities.
- Robust feature normalization, outlier clipping, missing-value filling, and cross-sectional label ranking are configured.
- The historical sample is divided into training, validation, and test periods.
- Portfolio testing uses a top-k dropout strategy with a benchmark and explicit trading-cost assumptions.
- The configuration specifies an experiment but does not report performance results.
Tags
Full text
# workflow_config_linear_Alpha158.yaml
```yaml
qlib_init:
provider_uri: "~/.qlib/qlib_data/cn_data"
region: cn
market: &market csi300
benchmark: &benchmark SH000300
data_handler_config: &data_handler_config
start_time: 2008-01-01
end_time: 2020-08-01
fit_start_time: 2008-01-01
fit_end_time: 2014-12-31
instruments: *market
infer_processors:
- class: RobustZScoreNorm
kwargs:
fields_group: feature
clip_outlier: true
- class: Fillna
kwargs:
fields_group: feature
learn_processors:
- class: DropnaLabel
- class: CSRankNorm
kwargs:
fields_group: label
port_analysis_config: &port_analysis_config
strategy:
class: TopkDropoutStrategy
module_path: qlib.contrib.strategy
kwargs:
signal: <PRED>
topk: 50
n_drop: 5
backtest:
start_time: 2017-01-01
end_time: 2020-08-01
account: 100000000
benchmark: *benchmark
exchange_kwargs:
limit_threshold: 0.095
deal_price: close
open_cost: 0.0005
close_cost: 0.0015
min_cost: 5
task:
model:
class: LinearModel
module_path: qlib.contrib.model.linear
kwargs:
estimator: ridge
alpha: 0.05
dataset:
class: DatasetH
module_path: qlib.data.dataset
kwargs:
handler:
class: Alpha158
module_path: qlib.contrib.data.handler
kwargs: *data_handler_config
segments:
train: [2008-01-01, 2014-12-31]
valid: [2015-01-01, 2016-12-31]
test: [2017-01-01, 2020-08-01]
record:
- class: SignalRecord
module_path: qlib.workflow.record_temp
kwargs:
model: <MODEL>
dataset: <DATASET>
- class: SigAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
ana_long_short: True
ann_scaler: 252
- class: PortAnaRecord
module_path: qlib.workflow.record_temp
kwargs:
config: *port_analysis_config
```Shown in full with attribution under the source's licence. Licence: MIT
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.