对Dlinear及Transformer类模型进行回测
策略思想
预测未来两天:
当预测明天的价格低于后天的价格时,就以明天的价格买入所有股票。
当预测明天的价格高于后天的价格时,就以明天的价格卖出所有股票。
再根据最终的现金和股票数量计算策略的最终价值、收益率和年化收益率,并与市场涨幅进行对比。
实验设置
为了方便起见,我暂时没有使用股票数据集,而是将汇率数据集exchange_rate.csv中的’OT’列看作收盘价进行回测计算,熟悉回测策略及其流程。
实验效果
市场年化收益率:-174.0780%
模型 | MSE | MAE | 策略年化收益率 | 超额年化收益率 |
---|---|---|---|---|
FEDformer | 1.382051 | 0.773845 | -179.0415% | -4.9635% |
Autoformer | 0.014931 | 0.100018 | -192.9526% | -18.8746% |
Transformer | 0.006252 | 0.061371 | -174.2428% | -0.1648% |
Informer | 0.039667 | 0.178975 | -179.0415% | -4.9635% |
Dlinear | 0.002326 | 0.034621 | -174.2428% | -0.1648% |
FEDformer预测两天
Autoformer预测两天
Transformer预测两天
Informer预测两天
Dlinear预测两天
实验记录
sh scripts/EXP-LongForecasting/myformers-short.sh
>>>>>>>testing : exchange_96_2_Autoformer_custom_ftMS_sl96_ll48_pl2_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 99
mse:0.01493128016591072, mae:0.10001752525568008
回测序列长度: 96
初始价值:10000000.0000 最终价值:4925081.4584
回测总收益率:-50.7492 回测年化收益率:-192.9526
市场总涨幅:-45.7849 市场年化收益率:-174.0780
>>>>>>>testing : exchange_96_2_Informer_custom_ftMS_sl96_ll48_pl2_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 99
mse:0.039666566997766495, mae:0.17897455394268036
回测序列长度: 96
初始价值:10000000.0000 最终价值:5290962.0168
回测总收益率:-47.0904 回测年化收益率:-179.0415
市场总涨幅:-45.7849 市场年化收益率:-174.0780
>>>>>>>testing : exchange_96_2_Transformer_custom_ftMS_sl96_ll48_pl2_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 99
mse:0.006251905113458633, mae:0.06137145683169365
回测序列长度: 96
初始价值:10000000.0000 最终价值:5417176.0332
回测总收益率:-45.8282 回测年化收益率:-174.2428
市场总涨幅:-45.7849 市场年化收益率:-174.0780
sh FEDformer/scripts/myfedformer-short.sh
>>>>>>>testing : Exchange_FEDformer_random_modes64_custom_ftMS_sl96_ll48_pl2_dm512_nh8_el2_dl1_df2048_fc3_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 99
test shape: (3, 32, 2, 8) (3, 32, 2, 1)
test shape: (96, 2, 8) (96, 2, 1)
mse:1.3820511102676392, mae:0.773845374584198
初始价值:10000000.0000 最终价值:5290962.0168
回测总收益率:-47.0904 回测年化收益率:-179.0415
市场总涨幅:-45.7849 市场年化收益率:-174.0780
sh scripts/EXP-LongForecasting/mydlinear-short.sh
>>>>>>>testing : Exchange_96_2_DLinear_custom_ftMS_sl96_ll48_pl2_dm512_nh8_el2_dl1_df2048_fc1_ebtimeF_dtTrue_Exp_0<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
test 99
mse:0.0023264677729457617, mae:0.03462085500359535
回测序列长度: 96
初始价值:10000000.0000 最终价值:5417176.0332
回测总收益率:-45.8282 回测年化收益率:-174.2428
市场总涨幅:-45.7849 市场年化收益率:-174.0780
下周工作
将数据集替换成股票数据CSI300.csv再次进行实验。