Skip to content

Commit cd4ab99

Browse files
authored
Update on Dynamic Benchmark (#1539)
* move config file to benchmark_dynamic & switch default sim task model to GBDT * Update benchmark_dynamic results * Change the default value of alpha of DDG-DA
1 parent 0e9ac9d commit cd4ab99

File tree

5 files changed

+164
-10
lines changed

5 files changed

+164
-10
lines changed

examples/benchmarks_dynamic/DDG-DA/workflow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,14 @@ class DDGDA:
3434

3535
def __init__(
3636
self,
37-
sim_task_model: Literal["linear", "gbdt"] = "linear",
37+
sim_task_model: Literal["linear", "gbdt"] = "gbdt",
3838
forecast_model: Literal["linear", "gbdt"] = "linear",
3939
h_path: Optional[str] = None,
4040
test_end: Optional[str] = None,
4141
train_start: Optional[str] = None,
4242
meta_1st_train_end: Optional[str] = None,
4343
task_ext_conf: Optional[dict] = None,
44-
alpha: float = 0.0,
44+
alpha: float = 0.01,
4545
proxy_hd: str = "handler_proxy.pkl",
4646
):
4747
"""
@@ -215,7 +215,7 @@ def train_meta_model(self, fill_method="max"):
215215
with R.start(experiment_name=self.meta_exp_name):
216216
R.log_params(**kwargs)
217217
mm = MetaModelDS(
218-
step=self.step, hist_step_n=kwargs["hist_step_n"], lr=0.001, max_epoch=100, seed=43, alpha=self.alpha
218+
step=self.step, hist_step_n=kwargs["hist_step_n"], lr=0.001, max_epoch=30, seed=43, alpha=self.alpha
219219
)
220220
mm.fit(md)
221221
R.save_objects(model=mm)

examples/benchmarks_dynamic/README.md

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ The table below shows the performances of different solutions on different forec
88
Here is the [crowd sourced version of qlib data](data_collector/crowd_source/README.md): https://github.com/chenditc/investment_data/releases
99
```bash
1010
wget https://github.com/chenditc/investment_data/releases/download/20220720/qlib_bin.tar.gz
11+
mkdir -p ~/.qlib/qlib_data/cn_data
1112
tar -zxvf qlib_bin.tar.gz -C ~/.qlib/qlib_data/cn_data --strip-components=2
13+
rm -f qlib_bin.tar.gz
1214
```
1315

1416
| Model Name | Dataset | IC | ICIR | Rank IC | Rank ICIR | Annualized Return | Information Ratio | Max Drawdown |
15-
|------------------|---------|----|------|---------|-----------|-------------------|-------------------|--------------|
16-
| RR[Linear] |Alpha158 |0.089|0.577|0.102 |0.627 |0.093 |1.458 |-0.073 |
17-
| DDG-DA[Linear] |Alpha158 |0.096|0.636|0.107 |0.677 |0.067 |0.996 |-0.091 |
18-
| RR[LightGBM] |Alpha158 |0.082|0.589|0.091 |0.626 |0.077 |1.320 |-0.091 |
19-
| DDG-DA[LightGBM] |Alpha158 |0.085|0.658|0.094 |0.686 |0.115 |1.792 |-0.068 |
17+
|------------------|---------|------|------|---------|-----------|-------------------|-------------------|--------------|
18+
| RR[Linear] |Alpha158 |0.0945|0.5989|0.1069 |0.6495 |0.0857 |1.3682 |-0.0986 |
19+
| DDG-DA[Linear] |Alpha158 |0.0983|0.6157|0.1108 |0.6646 |0.0764 |1.1904 |-0.0769 |
20+
| RR[LightGBM] |Alpha158 |0.0816|0.5887|0.0912 |0.6263 |0.0771 |1.3196 |-0.0909 |
21+
| DDG-DA[LightGBM] |Alpha158 |0.0878|0.6185|0.0975 |0.6524 |0.1261 |2.0096 |-0.0744 |
2022

2123
- The label horizon of the `Alpha158` dataset is set to 20.
2224
- The rolling time intervals are set to 20 trading days.

examples/benchmarks_dynamic/baseline/rolling_benchmark.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,12 @@ def __init__(
6767
def basic_task(self):
6868
"""For fast training rolling"""
6969
if self.model_type == "gbdt":
70-
conf_path = DIRNAME.parent.parent / "benchmarks" / "LightGBM" / "workflow_config_lightgbm_Alpha158.yaml"
70+
conf_path = DIRNAME / "workflow_config_lightgbm_Alpha158.yaml"
7171
# dump the processed data on to disk for later loading to speed up the processing
7272
h_path = DIRNAME / "lightgbm_alpha158_handler_horizon{}.pkl".format(self.horizon)
7373
elif self.model_type == "linear":
74-
conf_path = DIRNAME.parent.parent / "benchmarks" / "Linear" / "workflow_config_linear_Alpha158.yaml"
74+
# We use ridge regression to stabilize the performance
75+
conf_path = DIRNAME / "workflow_config_linear_Alpha158.yaml"
7576
h_path = DIRNAME / "linear_alpha158_handler_horizon{}.pkl".format(self.horizon)
7677
else:
7778
raise AssertionError("Model type is not supported!")
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
qlib_init:
2+
provider_uri: "~/.qlib/qlib_data/cn_data"
3+
region: cn
4+
market: &market csi300
5+
benchmark: &benchmark SH000300
6+
data_handler_config: &data_handler_config
7+
start_time: 2008-01-01
8+
end_time: 2020-08-01
9+
fit_start_time: 2008-01-01
10+
fit_end_time: 2014-12-31
11+
instruments: *market
12+
port_analysis_config: &port_analysis_config
13+
strategy:
14+
class: TopkDropoutStrategy
15+
module_path: qlib.contrib.strategy
16+
kwargs:
17+
model: <MODEL>
18+
dataset: <DATASET>
19+
topk: 50
20+
n_drop: 5
21+
backtest:
22+
start_time: 2017-01-01
23+
end_time: 2020-08-01
24+
account: 100000000
25+
benchmark: *benchmark
26+
exchange_kwargs:
27+
limit_threshold: 0.095
28+
deal_price: close
29+
open_cost: 0.0005
30+
close_cost: 0.0015
31+
min_cost: 5
32+
task:
33+
model:
34+
class: LGBModel
35+
module_path: qlib.contrib.model.gbdt
36+
kwargs:
37+
loss: mse
38+
colsample_bytree: 0.8879
39+
learning_rate: 0.2
40+
subsample: 0.8789
41+
lambda_l1: 205.6999
42+
lambda_l2: 580.9768
43+
max_depth: 8
44+
num_leaves: 210
45+
num_threads: 20
46+
dataset:
47+
class: DatasetH
48+
module_path: qlib.data.dataset
49+
kwargs:
50+
handler:
51+
class: Alpha158
52+
module_path: qlib.contrib.data.handler
53+
kwargs: *data_handler_config
54+
segments:
55+
train: [2008-01-01, 2014-12-31]
56+
valid: [2015-01-01, 2016-12-31]
57+
test: [2017-01-01, 2020-08-01]
58+
record:
59+
- class: SignalRecord
60+
module_path: qlib.workflow.record_temp
61+
kwargs:
62+
model: <MODEL>
63+
dataset: <DATASET>
64+
- class: SigAnaRecord
65+
module_path: qlib.workflow.record_temp
66+
kwargs:
67+
ana_long_short: False
68+
ann_scaler: 252
69+
- class: PortAnaRecord
70+
module_path: qlib.workflow.record_temp
71+
kwargs:
72+
config: *port_analysis_config
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
qlib_init:
2+
provider_uri: "~/.qlib/qlib_data/cn_data"
3+
region: cn
4+
market: &market csi300
5+
benchmark: &benchmark SH000300
6+
data_handler_config: &data_handler_config
7+
start_time: 2008-01-01
8+
end_time: 2020-08-01
9+
fit_start_time: 2008-01-01
10+
fit_end_time: 2014-12-31
11+
instruments: *market
12+
infer_processors:
13+
- class: RobustZScoreNorm
14+
kwargs:
15+
fields_group: feature
16+
clip_outlier: true
17+
- class: Fillna
18+
kwargs:
19+
fields_group: feature
20+
learn_processors:
21+
- class: DropnaLabel
22+
- class: CSRankNorm
23+
kwargs:
24+
fields_group: label
25+
port_analysis_config: &port_analysis_config
26+
strategy:
27+
class: TopkDropoutStrategy
28+
module_path: qlib.contrib.strategy
29+
kwargs:
30+
signal:
31+
- <MODEL>
32+
- <DATASET>
33+
topk: 50
34+
n_drop: 5
35+
backtest:
36+
start_time: 2017-01-01
37+
end_time: 2020-08-01
38+
account: 100000000
39+
benchmark: *benchmark
40+
exchange_kwargs:
41+
limit_threshold: 0.095
42+
deal_price: close
43+
open_cost: 0.0005
44+
close_cost: 0.0015
45+
min_cost: 5
46+
task:
47+
model:
48+
class: LinearModel
49+
module_path: qlib.contrib.model.linear
50+
kwargs:
51+
estimator: ridge
52+
alpha: 0.05
53+
dataset:
54+
class: DatasetH
55+
module_path: qlib.data.dataset
56+
kwargs:
57+
handler:
58+
class: Alpha158
59+
module_path: qlib.contrib.data.handler
60+
kwargs: *data_handler_config
61+
segments:
62+
train: [2008-01-01, 2014-12-31]
63+
valid: [2015-01-01, 2016-12-31]
64+
test: [2017-01-01, 2020-08-01]
65+
record:
66+
- class: SignalRecord
67+
module_path: qlib.workflow.record_temp
68+
kwargs:
69+
model: <MODEL>
70+
dataset: <DATASET>
71+
- class: SigAnaRecord
72+
module_path: qlib.workflow.record_temp
73+
kwargs:
74+
ana_long_short: True
75+
ann_scaler: 252
76+
- class: PortAnaRecord
77+
module_path: qlib.workflow.record_temp
78+
kwargs:
79+
config: *port_analysis_config

0 commit comments

Comments
 (0)