接上一篇文章《29DMA之七回顾小节》
DMA之八滑窗网格参数优选(止损,止盈)
回测结果汇总
原始双均线
参数
fast_windows = np.arange(10, 50,5)slow_multis = np.arange(1.5, 5.5, 0.5)最佳参数
in_best_index[:5]MultiIndex([( 0, 35, 2.0), ( 1, 10, 4.5), ( 2, 10, 2.0), ( 3, 25, 3.5), ( 4, 40, 5.0), ( 5, 35, 5.0), ( 6, 10, 1.5), ( 7, 45, 3.0), ( 8, 40, 1.5), ( 9, 20, 1.5), (10, 25, 1.5)], names=['split_idx', 'dualma_fast_window', 'dualma_slow_multi'])最佳参数样本内网sharp

最佳参数测试集回测表现

最佳参数验证集回测表现

简单说明:对于训练集合,其整体时间为2T,2倍于预测时间。 所以
01,训练集和验证集数据图上,即使同一种颜色也无太大比较意义。
02,训练集绿色线高于蓝色线,说明参数优选效果(拟合效果,训练效果)较好。这也是合理,毕竟用训练的最优最结果又用来回测自身,效果当然也应当好嘛。
03,验证集绿色高于蓝色越多越好,说明相对简单持有具有超额收益。当然实际上有难度,尤其是行情好时。由于策略需要控制风险(追求高sharpe),所以时间维度难以持续满仓,所以牛市可能不如稳定持有,但是遇到大跌时,规避风险的优势就很明显了。
跟踪止损
参数
sl_stops = [0.05,0.1,0.15,0.20]sl_trail=True最佳参数
MultiIndex([( 0, 35, 2.0, 0.1), ( 1, 15, 4.0, 0.05), ( 2, 10, 2.0, 0.05), ( 3, 10, 1.5, 0.1), ( 4, 40, 5.0, 0.2), ( 5, 35, 5.0, 0.2), ( 6, 10, 4.0, 0.1), ( 7, 45, 2.5, 0.2), ( 8, 40, 1.5, 0.2), ( 9, 20, 1.5, 0.1), (10, 30, 1.5, 0.05)], names=['split_idx', 'dualma_fast_window', 'dualma_slow_multi', 'sl_stop'])最佳参数样本内网sharp

最佳参数测试集回测表现

最佳参数验证集回测表现

跟踪止损+np.inf
参数
sl_stops = [np.inf,0.05,0.1,0.15,0.20]sl_trail=True最佳参数
merged_df[in_test_best_index_basic] in_sharpe in_return out_sharpe out_returnsplit_idx dualma_fast_window dualma_slow_multi sl_stop0 35 2.0 0.10 1.979770 0.319978 -2.876613 -0.1240381 15 4.0 0.05 0.324361 0.016997 2.231171 0.1957002 10 2.0 0.05 1.844657 0.303627 2.693463 0.1618173 25 3.5 inf 3.374967 1.233830 3.996941 0.5710244 40 5.0 inf 4.501923 2.451051 0.688785 0.0538865 35 5.0 0.20 2.959891 1.144421 -2.467499 -0.1936636 10 4.0 0.10 3.029320 0.727907 -1.060044 -0.0736907 45 3.0 inf 2.296182 0.749108 inf 0.0000008 40 1.5 inf 2.489317 0.692895 3.678357 0.4492879 20 1.5 inf 2.926436 0.575073 2.364898 0.12873410 30 1.5 0.05 2.402594 0.302466 -4.323912 -0.074724最佳参数样本内网sharp

最佳参数测试集回测表现

最佳参数验证集回测表现

止损止盈
sl_stops = [0.05,0.1,0.15,0.20]sl_trails = [False, True]tp_stops = [0.1, 0.2]最佳参数
MultiIndex([( 0, 45, 2.0, 0.05, False, 0.1), ( 1, 15, 4.0, 0.05, False, 0.1), ( 2, 10, 2.0, 0.05, True, 0.2), ( 3, 10, 2.0, 0.05, True, 0.2), ( 4, 15, 1.5, 0.05, False, 0.2), ( 5, 40, 3.5, 0.2, False, 0.2), ( 6, 20, 4.0, 0.05, False, 0.2), ( 7, 25, 2.0, 0.05, False, 0.2), ( 8, 40, 1.5, 0.1, False, 0.2), ( 9, 30, 5.0, 0.1, False, 0.2), (10, 30, 3.0, 0.05, False, 0.2)], names=['split_idx', 'dualma_fast_window', 'dualma_slow_multi', 'sl_stop', 'sl_trail', 'tp_stop'])最佳参数样本内网sharp

最佳参数训练集回测表现

最佳参数验证集回测表现

止损止盈+np.inf
参数
sl_stops = [np.inf,0.05,0.1,0.15,0.20]sl_trails = [False, True]tp_stops = [np.inf,0.1, 0.2]最佳参数
merged_df[in_test_best_index_basic] in_sharpe in_return out_sharpe out_returnsplit_idx dualma_fast_window dualma_slow_multi sl_stop sl_trail tp_stop0 45 2.0 inf False 0.1 3.158667 0.237753 -0.929956 -0.0641111 15 4.0 inf False 0.1 0.664945 0.034948 2.563318 0.1459632 10 3.0 0.05 False inf 1.978273 0.408342 1.451395 0.0641993 25 3.5 inf False inf 3.374967 1.233830 3.996941 0.5710244 15 1.5 inf False 0.2 5.245280 1.127771 2.858175 0.2392335 35 5.0 0.20 True inf 2.959891 1.144421 -2.467499 -0.1936636 20 4.0 inf False 0.2 4.039079 0.462475 1.890751 0.2072207 45 3.0 inf False inf 2.296182 0.749108 inf 0.0000008 40 1.5 inf False 0.2 2.665200 0.492175 2.449875 0.2399419 30 5.0 inf False 0.2 3.738112 0.507262 -0.434888 -0.06348410 30 3.0 inf False 0.2 2.943695 0.258812 -3.877240 -0.075374最佳参数样本内网sharp

最佳参数测试集回测表现

最佳参数验证集回测表现

DMA之九滑窗网格参数优选(4种参数优选)
回测结果汇总
参数
4种优选方法 训练集夏普sharp ratio
4种优选方法 验证集夏普sharp ratio
4种优选方法 最佳参数测试集回测表现
4种优选方法 最佳参数验证集回测表现
跟踪止损
参数
fast_windows = np.arange(10, 50,5)slow_multis = np.arange(1.5, 5.5, 0.5)sl_stops = [0.05,0.1,0.15,0.20]sl_trails = True无止盈4种优选方法 训练集夏普sharp ratio

4种优选方法 验证集夏普sharp ratio

4种优选方法 最佳参数测试集回测表现

4种优选方法 最佳参数验证集回测表现

非跟踪止损
参数
fast_windows = np.arange(10, 50,5)slow_multis = np.arange(1.5, 5.5, 0.5)sl_stops = [0.05,0.1,0.15,0.20]sl_trails = False无止盈4种优选方法 训练集夏普sharp ratio

4种优选方法 验证集夏普sharp ratio

4种优选方法 最佳参数测试集回测表现
4种优选方法 最佳参数验证集回测表现

跟踪止损+止盈
参数
fast_windows = np.arange(10, 50,5)slow_multis = np.arange(1.5, 5.5, 0.5)sl_stops = [0.05,0.1,0.15,0.20]sl_trails = Truetp_stops = [0.1, 0.2]参数
4种优选方法 训练集夏普sharp ratio

4种优选方法 验证集夏普sharp ratio
4种优选方法 最佳参数测试集回测表现
4种优选方法 最佳参数验证集回测表现

非跟踪止损+止盈
参数
fast_windows = np.arange(10, 50,5)slow_multis = np.arange(1.5, 5.5, 0.5)sl_stops = [0.05,0.1,0.15,0.20]sl_trails = Falsetp_stops = [0.1, 0.2]4种优选方法 训练集夏普sharp ratio

4种优选方法 验证集夏普sharp ratio
4种优选方法 最佳参数测试集回测表现
4种优选方法 最佳参数验证集回测表现

DMA之十滑窗网格参数优选(过滤器)
std_indicator
过滤器规则:
std_close_wbuf = ohlcv_wbuf['Close'].rolling(window=20).std()std_close_ma_wbuf = std_close_wbuf.rolling(window=20).mean()std_close=std_close_wbuf[wobuf_mask]std_close_ma=std_close_ma_wbuf[wobuf_mask]std_indicator = (std_close > std_close_ma )4种优选方法的训练集夏普sharp ratio

4种优选方法的验证集夏普sharp ratio
样本内滚动收益

样本外滚动收益

diff_indicator
过滤器规则:
diff_close_wbuf = ohlcv_wbuf['Close'] - ohlcv_wbuf['Close'].rolling(window=int(20/5)).mean().shift(20)diff_close_ma_wbuf = diff_close_wbuf.rolling(window=20).mean()diff_close=diff_close_wbuf[wobuf_mask]diff_close_ma=diff_close_ma_wbuf[wobuf_mask]diff_indicator = ((diff_close > diff_close_ma )&(diff_close_ma>200*0.0025*20))4种优选方法的训练集夏普sharp ratio
4种优选方法的验证集夏普sharp ratio

样本内滚动收益

样本外滚动收益

小节
过滤器优化后,相比原始的:DMA之九滑窗网格参数优选(4种参数优选)
其sharpe和收益曲线均未见明显改善,但过滤后可视化角度看,的确过滤掉部分低波动行情。
部分信息可能已经过时