Skip to content

Commit 007082a

Browse files
lwwang1995lewwang
andauthored
Add AdaRNN baseline. (#689)
* Update TCTS. * Update TCTS README. * Update TCTS README. * Update TCTS. * Add ADARNN. * Update README. * Reformat ADARNN. * Add README for adarnn. Co-authored-by: lewwang <[email protected]>
1 parent 4e380b6 commit 007082a

File tree

7 files changed

+891
-4
lines changed

7 files changed

+891
-4
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
Recent released features
1212
| Feature | Status |
1313
| -- | ------ |
14+
| ADARNN model | [Released](https://github.com/microsoft/qlib/pull/689) on Nov 14, 2021 |
1415
| TCN model | [Released](https://github.com/microsoft/qlib/pull/668) on Nov 4, 2021 |
1516
|Temporal Routing Adaptor (TRA) | [Released](https://github.com/microsoft/qlib/pull/531) on July 30, 2021 |
1617
| Transformer & Localformer | [Released](https://github.com/microsoft/qlib/pull/508) on July 22, 2021 |
@@ -296,6 +297,7 @@ Here is a list of models built on `Qlib`.
296297
- [Localformer based on pytorch (Juyong Jiang, et al.)](examples/benchmarks/Localformer/)
297298
- [TRA based on pytorch (Hengxu, Dong, et al. KDD 2021)](examples/benchmarks/TRA/)
298299
- [TCN based on pytorch (Shaojie Bai, et al. 2018)](examples/benchmarks/TCN/)
300+
- [ADARNN based on pytorch (YunTao Du, et al. 2021)](examples/benchmarks/ADARNN/)
299301
300302
Your PR of new Quant models is highly welcomed.
301303

examples/benchmarks/ADARNN/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# AdaRNN
2+
* Code: [https://github.com/jindongwang/transferlearning/tree/master/code/deep/adarnn](https://github.com/jindongwang/transferlearning/tree/master/code/deep/adarnn)
3+
* Paper: [AdaRNN: Adaptive Learning and Forecasting for Time Series](https://arxiv.org/pdf/2108.04443.pdf).
4+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
pandas==1.1.2
2+
numpy==1.17.4
3+
scikit_learn==0.23.2
4+
torch==1.7.0
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
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+
label: ["Ref($close, -2) / Ref($close, -1) - 1"]
26+
port_analysis_config: &port_analysis_config
27+
strategy:
28+
class: TopkDropoutStrategy
29+
module_path: qlib.contrib.strategy
30+
kwargs:
31+
model: <MODEL>
32+
dataset: <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: ADARNN
49+
module_path: qlib.contrib.model.pytorch_adarnn
50+
kwargs:
51+
d_feat: 6
52+
hidden_size: 64
53+
num_layers: 2
54+
dropout: 0.0
55+
n_epochs: 200
56+
lr: 1e-3
57+
early_stop: 20
58+
batch_size: 800
59+
metric: loss
60+
loss: mse
61+
GPU: 0
62+
dataset:
63+
class: DatasetH
64+
module_path: qlib.data.dataset
65+
kwargs:
66+
handler:
67+
class: Alpha360
68+
module_path: qlib.contrib.data.handler
69+
kwargs: *data_handler_config
70+
segments:
71+
train: [2008-01-01, 2014-12-31]
72+
valid: [2015-01-01, 2016-12-31]
73+
test: [2017-01-01, 2020-08-01]
74+
record:
75+
- class: SignalRecord
76+
module_path: qlib.workflow.record_temp
77+
kwargs:
78+
model: <MODEL>
79+
dataset: <DATASET>
80+
- class: SigAnaRecord
81+
module_path: qlib.workflow.record_temp
82+
kwargs:
83+
ana_long_short: False
84+
ann_scaler: 252
85+
- class: PortAnaRecord
86+
module_path: qlib.workflow.record_temp
87+
kwargs:
88+
config: *port_analysis_config

examples/benchmarks/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ The numbers shown below demonstrate the performance of the entire `workflow` of
2121

2222
| Model Name | Dataset | IC | ICIR | Rank IC | Rank ICIR | Annualized Return | Information Ratio | Max Drawdown |
2323
|------------------------------------------|-------------------------------------|-------------|-------------|-------------|-------------|-------------------|-------------------|--------------|
24+
| TCN(Shaojie Bai, et al.) | Alpha158 | 0.0275±0.00 | 0.2157±0.01 | 0.0411±0.00 | 0.3379±0.01 | 0.0190±0.02 | 0.2887±0.27 | -0.1202±0.03 |
2425
| TabNet(Sercan O. Arik, et al.) | Alpha158 | 0.0204±0.01 | 0.1554±0.07 | 0.0333±0.00 | 0.2552±0.05 | 0.0227±0.04 | 0.3676±0.54 | -0.1089±0.08 |
2526
| Transformer(Ashish Vaswani, et al.) | Alpha158 | 0.0264±0.00 | 0.2053±0.02 | 0.0407±0.00 | 0.3273±0.02 | 0.0273±0.02 | 0.3970±0.26 | -0.1101±0.02 |
2627
| GRU(Kyunghyun Cho, et al.) | Alpha158(with selected 20 features) | 0.0315±0.00 | 0.2450±0.04 | 0.0428±0.00 | 0.3440±0.03 | 0.0344±0.02 | 0.5160±0.25 | -0.1017±0.02 |
@@ -38,8 +39,6 @@ The numbers shown below demonstrate the performance of the entire `workflow` of
3839
| MLP | Alpha158 | 0.0376±0.00 | 0.2846±0.02 | 0.0429±0.00 | 0.3220±0.01 | 0.0895±0.02 | 1.1408±0.23 | -0.1103±0.02 |
3940
| LightGBM(Guolin Ke, et al.) | Alpha158 | 0.0448±0.00 | 0.3660±0.00 | 0.0469±0.00 | 0.3877±0.00 | 0.0901±0.00 | 1.0164±0.00 | -0.1038±0.00 |
4041
| DoubleEnsemble(Chuheng Zhang, et al.) | Alpha158 | 0.0544±0.00 | 0.4340±0.00 | 0.0523±0.00 | 0.4284±0.01 | 0.1168±0.01 | 1.3384±0.12 | -0.1036±0.01 |
41-
| TCN | Alpha158 | 0.0275±0.00 | 0.2157±0.01 | 0.0411±0.00 | 0.3379±0.01 | 0.0190±0.02 | 0.2887±0.27 | -0.1202±0.03 |
42-
4342

4443

4544
## Alpha360 dataset
@@ -54,13 +53,14 @@ The numbers shown below demonstrate the performance of the entire `workflow` of
5453
| XGBoost(Tianqi Chen, et al.) | Alpha360 | 0.0394±0.00 | 0.2909±0.00 | 0.0448±0.00 | 0.3679±0.00 | 0.0344±0.00 | 0.4527±0.02 | -0.1004±0.00 |
5554
| DoubleEnsemble(Chuheng Zhang, et al.) | Alpha360 | 0.0404±0.00 | 0.3023±0.00 | 0.0495±0.00 | 0.3898±0.00 | 0.0468±0.01 | 0.6302±0.20 | -0.0860±0.01 |
5655
| LightGBM(Guolin Ke, et al.) | Alpha360 | 0.0400±0.00 | 0.3037±0.00 | 0.0499±0.00 | 0.4042±0.00 | 0.0558±0.00 | 0.7632±0.00 | -0.0659±0.00 |
56+
| TCN(Shaojie Bai, et al.) | Alpha360 | 0.0441±0.00 | 0.3301±0.02 | 0.0519±0.00 | 0.4130±0.01 | 0.0604±0.02 | 0.8295±0.34 | -0.1018±0.03 |
5757
| ALSTM (Yao Qin, et al.) | Alpha360 | 0.0497±0.00 | 0.3829±0.04 | 0.0599±0.00 | 0.4736±0.03 | 0.0626±0.02 | 0.8651±0.31 | -0.0994±0.03 |
5858
| LSTM(Sepp Hochreiter, et al.) | Alpha360 | 0.0448±0.00 | 0.3474±0.04 | 0.0549±0.00 | 0.4366±0.03 | 0.0647±0.03 | 0.8963±0.39 | -0.0875±0.02 |
5959
| GRU(Kyunghyun Cho, et al.) | Alpha360 | 0.0493±0.00 | 0.3772±0.04 | 0.0584±0.00 | 0.4638±0.03 | 0.0720±0.02 | 0.9730±0.33 | -0.0821±0.02 |
60+
| AdaRNN(Yuntao Du, et al.) | Alpha360 | 0.0464±0.01 | 0.3619±0.08 | 0.0539±0.01 | 0.4287±0.06 | 0.0753±0.03 | 1.0200±0.40 | -0.0936±0.03 |
6061
| GATs (Petar Velickovic, et al.) | Alpha360 | 0.0476±0.00 | 0.3508±0.02 | 0.0598±0.00 | 0.4604±0.01 | 0.0824±0.02 | 1.1079±0.26 | -0.0894±0.03 |
6162
| TCTS(Xueqing Wu, et al.) | Alpha360 | 0.0508±0.00 | 0.3931±0.04 | 0.0599±0.00 | 0.4756±0.03 | 0.0893±0.03 | 1.2256±0.36 | -0.0857±0.02 |
6263
| TRA(Hengxu Lin, et al.) | Alpha360 | 0.0485±0.00 | 0.3787±0.03 | 0.0587±0.00 | 0.4756±0.03 | 0.0920±0.03 | 1.2789±0.42 | -0.0834±0.02 |
63-
| TCN(Shaojie Bai, et al.) | Alpha360 | 0.0441±0.00 | 0.3301±0.02 | 0.0519±0.00 | 0.4130±0.01 | 0.0604±0.02 | 0.8295±0.34 | -0.1018±0.03 |
6464

6565
- The selected 20 features are based on the feature importance of a lightgbm-based model.
6666
- The base model of DoubleEnsemble is LGBM.

examples/benchmarks/TCTS/workflow_config_tcts_Alpha360.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,4 +95,4 @@ task:
9595
- class: PortAnaRecord
9696
module_path: qlib.workflow.record_temp
9797
kwargs:
98-
config: *port_analysis_config
98+
config: *port_analysis_config

0 commit comments

Comments
 (0)