回测一:从高点跌到低点
选取创业板ETF(159915),时间:20220101-20240730
#前两天K线买卖法:当天涨幅超过前两天高点的平均值买入,低于前两天低点平均值卖出
def huice_by_previous_2days_k(df,need_print='N'):
date=list(df['trade_date'])
open=list(df['open'])
close=list(df['close'])
high=list(df['high'])
low=list(df['low'])
buy_price=0
total_exchange=0
sum_benefit=0
is_hold=False
benefit_list=[]
pre_1high=high[1]
pre_1low=low[1]
pre_2high=high[0]
pre_2low=low[0]
buy_date=''
the_day_after_buy=0
exchange_list=[]
for i in range(2,len(open)):
today_date=date[i]
today_open=open[i]
today_close=close[i]
today_high=high[i]
today_low=low[i]
#计算出前两天的高点平均值
previous_high=round((pre_1high+pre_2high)/2,3)
#计算出前两天的低点平均值
previous_low=round((pre_1low+pre_2low)/2,3)
#买入
if is_hold is False and today_high>=previous_high:
buy_price=previous_high
buy_date=today_date
print_exchange(today_date,'buy',buy_price,need_print)
is_hold=True
the_day_after_buy+=1
elif is_hold is True and today_low<=previous_low:
sale_price=previous_low
sale_date=today_date
exchange_list.append([buy_date,buy_price,sale_date,sale_price,round(sale_price-buy_price,3)])
print_exchange(today_date,'sale',sale_price,need_print)
sum_benefit+=(sale_price-buy_price)
total_exchange+=1
is_hold=False
else:
pass
pre_1high=high[i-1]
pre_1low=low[i-1]
pre_2high=high[i-2]
pre_2low=low[i-2]
exchange_list.sort(key=lambda x:(x[4]))
[print(i) for i in exchange_list]
print('总交易次数',total_exchange)
print('股价变化',round(close[-1]-open[0],3))
print('总利润',round(sum_benefit,3))
print('盈利率',round(sum_benefit/open[0],3)*100,'%')
['20220419', 2.418, '20220420', 2.337, -0.081]
['20221027', 2.313, '20221028', 2.232, -0.081]
['20221111', 2.374, '20221114', 2.301, -0.073]
['20221115', 2.361, '20221117', 2.292, -0.069]
['20220223', 2.744, '20220224', 2.681, -0.063]
['20220112', 3.032, '20220114', 2.97, -0.062]
['20220823', 2.705, '20220824', 2.643, -0.062]
['20220117', 3.041, '20220119', 2.984, -0.057]
['20240125', 1.663, '20240129', 1.613, -0.05]
['20220714', 2.711, '20220719', 2.665, -0.046]
['20220728', 2.654, '20220729', 2.61, -0.044]
['20220330', 2.586, '20220406', 2.543, -0.043]
['20220311', 2.547, '20220315', 2.505, -0.042]
['20220705', 2.744, '20220711', 2.702, -0.042]
['20230301', 2.376, '20230303', 2.339, -0.037]
['20240417', 1.748, '20240419', 1.714, -0.034]
['20231222', 1.789, '20231226', 1.756, -0.033]
['20220907', 2.479, '20220914', 2.447, -0.032]
['20220926', 2.284, '20220930', 2.253, -0.031]
['20231121', 1.949, '20231122', 1.918, -0.031]
['20231114', 1.972, '20231116', 1.944, -0.028]
['20240111', 1.732, '20240116', 1.704, -0.028]
['20240509', 1.86, '20240510', 1.832, -0.028]
['20230905', 2.066, '20230906', 2.039, -0.027]
['20220518', 2.308, '20220524', 2.282, -0.026]
['20240531', 1.791, '20240603', 1.766, -0.025]
['20230922', 1.96, '20231009', 1.937, -0.023]
['20231011', 1.962, '20231013', 1.941, -0.021]
['20220809', 2.594, '20220811', 2.575, -0.019]
['20230417', 2.358, '20230419', 2.342, -0.016]
['20230602', 2.155, '20230606', 2.139, -0.016]
['20230209', 2.484, '20230216', 2.469, -0.015]
['20230725', 2.134, '20230728', 2.119, -0.015]
['20230428', 2.24, '20230505', 2.226, -0.014]
['20221207', 2.337, '20221213', 2.325, -0.012]
['20230804', 2.184, '20230808', 2.174, -0.01]
['20231211', 1.845, '20231214', 1.835, -0.01]
['20240318', 1.86, '20240321', 1.85, -0.01]
['20220428', 2.171, '20220509', 2.163, -0.008]
['20230511', 2.212, '20230518', 2.206, -0.006]
['20230711', 2.147, '20230717', 2.144, -0.003]
['20240520', 1.821, '20240523', 1.818, -0.003]
['20240604', 1.788, '20240607', 1.786, -0.002]
['20221226', 2.256, '20230103', 2.255, -0.001]
['20240614', 1.756, '20240620', 1.755, -0.001]
['20220216', 2.706, '20220221', 2.712, 0.006]
['20231228', 1.786, '20240103', 1.792, 0.006]
['20240401', 1.783, '20240408', 1.79, 0.007]
['20220225', 2.723, '20220302', 2.737, 0.014]
['20230630', 2.143, '20230706', 2.16, 0.017]
['20230731', 2.144, '20230803', 2.167, 0.023]
['20230828', 2.03, '20230904', 2.053, 0.023]
['20221129', 2.275, '20221206', 2.305, 0.03]
['20230321', 2.258, '20230330', 2.292, 0.034]
['20231103', 1.923, '20231110', 1.958, 0.035]
['20240710', 1.625, '20240723', 1.66, 0.035]
['20230331', 2.316, '20230412', 2.353, 0.037]
['20240311', 1.796, '20240315', 1.835, 0.039]
['20220812', 2.617, '20220822', 2.66, 0.043]
['20220317', 2.552, '20220323', 2.598, 0.046]
['20231027', 1.845, '20231102', 1.891, 0.046]
['20240228', 1.72, '20240307', 1.766, 0.046]
['20220511', 2.199, '20220517', 2.255, 0.056]
['20221102', 2.245, '20221109', 2.332, 0.087]
['20221012', 2.254, '20221020', 2.344, 0.09]
['20230612', 2.095, '20230621', 2.189, 0.094]
['20240425', 1.717, '20240508', 1.831, 0.114]
['20240206', 1.564, '20240227', 1.695, 0.131]
['20220527', 2.295, '20220610', 2.445, 0.15]
['20230105', 2.296, '20230201', 2.514, 0.218]
['20220615', 2.484, '20220629', 2.707, 0.223]
总交易次数 71
股价变化 -1.635
总利润 0.27
盈利率 8.3 %
注:手续费简单计算=总交易次数乘以0.001(买卖一次10元,每次买入10000股)
回测二:从低点到高点再回到低点
选取创业板ETF(159915),时间:20180605-20240730
['20210112', 3.071, '20210115', 2.976, -0.095]
['20220419', 2.418, '20220420', 2.337, -0.081]
['20221027', 2.313, '20221028', 2.232, -0.081]
['20210608', 3.163, '20210609', 3.085, -0.078]
['20221111', 2.374, '20221114', 2.301, -0.073]
['20221115', 2.361, '20221117', 2.292, -0.069]
['20200526', 2.038, '20200528', 1.972, -0.066]
['20210302', 2.896, '20210304', 2.833, -0.063]
['20220223', 2.744, '20220224', 2.681, -0.063]
['20220112', 3.032, '20220114', 2.97, -0.062]
['20220823', 2.705, '20220824', 2.643, -0.062]
['20210914', 3.145, '20210916', 3.085, -0.06]
['20220117', 3.041, '20220119', 2.984, -0.057]
['20210312', 2.631, '20210315', 2.577, -0.054]
['20201228', 2.76, '20201229', 2.707, -0.053]
['20240125', 1.663, '20240129', 1.613, -0.05]
['20200303', 2.111, '20200309', 2.065, -0.046]
['20220714', 2.711, '20220719', 2.665, -0.046]
['20211230', 3.221, '20220104', 3.176, -0.045]
['20200123', 1.911, '20200203', 1.867, -0.044]
['20220728', 2.654, '20220729', 2.61, -0.044]
['20200918', 2.508, '20200923', 2.465, -0.043]
['20220330', 2.586, '20220406', 2.543, -0.043]
['20200423', 1.965, '20200424', 1.923, -0.042]
['20220311', 2.547, '20220315', 2.505, -0.042]
['20220705', 2.744, '20220711', 2.702, -0.042]
['20200817', 2.585, '20200819', 2.544, -0.041]
['20200914', 2.506, '20200917', 2.467, -0.039]
['20211129', 3.389, '20211202', 3.351, -0.038]
['20190424', 1.647, '20190425', 1.61, -0.037]
['20230301', 2.376, '20230303', 2.339, -0.037]
['20210318', 2.612, '20210322', 2.577, -0.035]
['20211008', 3.139, '20211012', 3.104, -0.035]
['20240417', 1.748, '20240419', 1.714, -0.034]
['20231222', 1.789, '20231226', 1.756, -0.033]
['20220907', 2.479, '20220914', 2.447, -0.032]
['20220926', 2.284, '20220930', 2.253, -0.031]
['20231121', 1.949, '20231122', 1.918, -0.031]
['20180607', 1.655, '20180608', 1.627, -0.028]
['20181128', 1.272, '20181130', 1.244, -0.028]
['20231114', 1.972, '20231116', 1.944, -0.028]
['20240111', 1.732, '20240116', 1.704, -0.028]
['20240509', 1.86, '20240510', 1.832, -0.028]
['20200519', 2.057, '20200521', 2.03, -0.027]
['20230905', 2.066, '20230906', 2.039, -0.027]
['20180905', 1.383, '20180906', 1.357, -0.026]
['20190312', 1.646, '20190314', 1.62, -0.026]
['20220518', 2.308, '20220524', 2.282, -0.026]
['20190920', 1.635, '20190923', 1.61, -0.025]
['20240531', 1.791, '20240603', 1.766, -0.025]
['20200513', 2.058, '20200518', 2.034, -0.024]
['20181225', 1.222, '20181227', 1.199, -0.023]
['20191128', 1.618, '20191129', 1.595, -0.023]
['20200722', 2.632, '20200724', 2.609, -0.023]
['20230922', 1.96, '20231009', 1.937, -0.023]
['20190121', 1.22, '20190122', 1.198, -0.022]
['20190510', 1.455, '20190517', 1.434, -0.021]
['20191018', 1.612, '20191021', 1.591, -0.021]
['20201123', 2.575, '20201125', 2.554, -0.021]
['20231011', 1.962, '20231013', 1.941, -0.021]
['20210610', 3.153, '20210616', 3.133, -0.02]
['20191114', 1.629, '20191118', 1.61, -0.019]
['20220809', 2.594, '20220811', 2.575, -0.019]
['20190319', 1.619, '20190322', 1.601, -0.018]
['20190712', 1.468, '20190715', 1.451, -0.017]
['20190115', 1.216, '20190118', 1.2, -0.016]
['20191023', 1.602, '20191025', 1.586, -0.016]
['20230417', 2.358, '20230419', 2.342, -0.016]
['20230602', 2.155, '20230606', 2.139, -0.016]
['20190417', 1.64, '20190422', 1.625, -0.015]
['20191225', 1.719, '20191230', 1.704, -0.015]
['20230209', 2.484, '20230216', 2.469, -0.015]
['20230725', 2.134, '20230728', 2.119, -0.015]
['20230428', 2.24, '20230505', 2.226, -0.014]
['20181212', 1.282, '20181214', 1.269, -0.013]
['20221207', 2.337, '20221213', 2.325, -0.012]
['20210923', 3.102, '20210929', 3.091, -0.011]
['20211224', 3.261, '20211227', 3.25, -0.011]
['20210721', 3.393, '20210726', 3.383, -0.01]
['20230804', 2.184, '20230808', 2.174, -0.01]
['20231211', 1.845, '20231214', 1.835, -0.01]
['20240318', 1.86, '20240321', 1.85, -0.01]
['20190125', 1.212, '20190129', 1.203, -0.009]
['20190527', 1.431, '20190531', 1.422, -0.009]
['20190827', 1.559, '20190830', 1.551, -0.008]
['20211025', 3.208, '20211028', 3.2, -0.008]
['20220428', 2.171, '20220509', 2.163, -0.008]
['20190809', 1.465, '20190815', 1.458, -0.007]
['20211111', 3.295, '20211116', 3.289, -0.006]
['20230511', 2.212, '20230518', 2.206, -0.006]
['20210823', 3.186, '20210827', 3.181, -0.005]
['20180724', 1.542, '20180727', 1.538, -0.004]
['20180626', 1.48, '20180704', 1.477, -0.003]
['20211029', 3.242, '20211110', 3.239, -0.003]
['20230711', 2.147, '20230717', 2.144, -0.003]
['20240520', 1.821, '20240523', 1.818, -0.003]
['20240604', 1.788, '20240607', 1.786, -0.002]
['20221226', 2.256, '20230103', 2.255, -0.001]
['20240614', 1.756, '20240620', 1.755, -0.001]
['20210906', 3.111, '20210910', 3.111, 0.0]
['20200325', 1.835, '20200330', 1.837, 0.002]
['20190611', 1.405, '20190617', 1.408, 0.003]
['20191119', 1.633, '20191122', 1.636, 0.003]
['20191104', 1.628, '20191111', 1.632, 0.004]
['20220216', 2.706, '20220221', 2.712, 0.006]
['20231228', 1.786, '20240103', 1.792, 0.006]
['20180809', 1.414, '20180815', 1.421, 0.007]
['20240401', 1.783, '20240408', 1.79, 0.007]
['20190716', 1.474, '20190719', 1.482, 0.008]
['20190724', 1.494, '20190801', 1.502, 0.008]
['20190107', 1.194, '20190111', 1.207, 0.013]
['20220225', 2.723, '20220302', 2.737, 0.014]
['20181203', 1.282, '20181206', 1.297, 0.015]
['20180823', 1.385, '20180830', 1.401, 0.016]
['20180919', 1.317, '20180928', 1.333, 0.016]
['20181112', 1.299, '20181119', 1.315, 0.016]
['20211209', 3.343, '20211216', 3.359, 0.016]
['20191028', 1.605, '20191031', 1.622, 0.017]
['20230630', 2.143, '20230706', 2.16, 0.017]
['20180709', 1.505, '20180719', 1.524, 0.019]
['20190619', 1.417, '20190625', 1.436, 0.019]
['20191010', 1.583, '20191016', 1.602, 0.019]
['20230731', 2.144, '20230803', 2.167, 0.023]
['20230828', 2.03, '20230904', 2.053, 0.023]
['20190627', 1.464, '20190704', 1.49, 0.026]
['20181019', 1.188, '20181025', 1.216, 0.028]
['20210729', 3.339, '20210809', 3.369, 0.03]
['20221129', 2.275, '20221206', 2.305, 0.03]
['20230321', 2.258, '20230330', 2.292, 0.034]
['20231103', 1.923, '20231110', 1.958, 0.035]
['20240710', 1.625, '20240723', 1.66, 0.035]
['20230331', 2.316, '20230412', 2.353, 0.037]
['20240311', 1.796, '20240315', 1.835, 0.039]
['20200415', 1.897, '20200422', 1.938, 0.041]
['20211014', 3.129, '20211022', 3.17, 0.041]
['20220812', 2.617, '20220822', 2.66, 0.043]
['20220317', 2.552, '20220323', 2.598, 0.046]
['20231027', 1.845, '20231102', 1.891, 0.046]
['20240228', 1.72, '20240307', 1.766, 0.046]
['20200824', 2.575, '20200904', 2.623, 0.048]
['20181031', 1.223, '20181109', 1.272, 0.049]
['20201130', 2.563, '20201209', 2.612, 0.049]
['20211122', 3.313, '20211126', 3.364, 0.051]
['20200428', 1.969, '20200512', 2.023, 0.054]
['20220511', 2.199, '20220517', 2.255, 0.056]
['20210707', 3.307, '20210716', 3.365, 0.058]
['20190816', 1.486, '20190823', 1.547, 0.061]
['20201028', 2.574, '20201110', 2.635, 0.061]
['20200402', 1.81, '20200410', 1.873, 0.063]
['20190902', 1.573, '20190912', 1.639, 0.066]
['20200601', 2.017, '20200612', 2.083, 0.066]
['20210525', 3.059, '20210603', 3.133, 0.074]
['20200729', 2.636, '20200806', 2.713, 0.077]
['20201215', 2.639, '20201225', 2.716, 0.077]
['20190329', 1.592, '20190408', 1.672, 0.08]
['20210203', 3.094, '20210219', 3.179, 0.085]
['20221102', 2.245, '20221109', 2.332, 0.087]
['20221012', 2.254, '20221020', 2.344, 0.09]
['20210326', 2.6, '20210407', 2.692, 0.092]
['20230612', 2.095, '20230621', 2.189, 0.094]
['20191204', 1.614, '20191220', 1.717, 0.103]
['20240425', 1.717, '20240508', 1.831, 0.114]
['20191231', 1.732, '20200122', 1.857, 0.125]
['20240206', 1.564, '20240227', 1.695, 0.131]
['20210513', 2.85, '20210524', 2.984, 0.134]
['20220527', 2.295, '20220610', 2.445, 0.15]
['20210621', 3.123, '20210702', 3.28, 0.157]
['20210119', 3.02, '20210127', 3.19, 0.17]
['20200929', 2.489, '20201016', 2.662, 0.173]
['20210416', 2.699, '20210506', 2.893, 0.194]
['20201230', 2.756, '20210111', 2.966, 0.21]
['20230105', 2.296, '20230201', 2.514, 0.218]
['20220615', 2.484, '20220629', 2.707, 0.223]
['20200205', 1.842, '20200226', 2.109, 0.267]
['20190201', 1.202, '20190311', 1.594, 0.392]
['20200615', 2.143, '20200716', 2.694, 0.551]
总交易次数 176
股价变化 -0.014
总利润 2.729
盈利率 169.0 %
回测三:从高点到低点,每日行情振幅较大
选取莱克转债(113659),时间:20240508-20270730
['20240701', 114.662, '20240703', 111.433, -3.229]
['20240517', 121.307, '20240522', 118.897, -2.41]
['20240606', 119.195, '20240607', 117.006, -2.189]
['20240514', 121.658, '20240515', 119.608, -2.05]
['20240524', 120.19, '20240528', 118.169, -2.021]
['20240510', 121.21, '20240513', 119.562, -1.648]
['20240620', 115.33, '20240621', 113.719, -1.611]
['20240531', 119.477, '20240603', 118.133, -1.344]
['20240710', 111.489, '20240716', 110.406, -1.083]
总交易次数 9
股价变化 -11.902
总利润 -17.585
盈利率 -14.6 %
此情形亏损比股价下跌幅度更大
回测四:国债(长期来看波动小,持续上涨)
选取十年国债ETF(511260),时间:成立-20240730
['20190417', 105.404, '20190418', 104.621, -0.783]
['20180611', 101.446, '20180612', 100.928, -0.518]
['20200529', 113.131, '20200601', 112.696, -0.435]
['20220308', 116.44, '20220309', 116.093, -0.347]
['20181122', 105.009, '20181123', 104.671, -0.338]
['20220810', 119.18, '20220812', 118.893, -0.287]
['20181024', 103.156, '20181029', 102.886, -0.27]
['20220208', 117.3, '20220211', 117.052, -0.248]
['20240322', 126.95, '20240325', 126.703, -0.247]
['20221202', 118.903, '20221206', 118.677, -0.226]
['20221208', 118.909, '20221213', 118.686, -0.223]
['20210610', 112.529, '20210611', 112.308, -0.221]
['20191101', 106.808, '20191105', 106.606, -0.202]
['20210223', 110.577, '20210226', 110.379, -0.198]
['20220415', 117.532, '20220418', 117.335, -0.197]
['20210218', 110.414, '20210222', 110.222, -0.192]
['20200629', 111.595, '20200703', 111.41, -0.185]
['20190701', 106.43, '20190702', 106.246, -0.184]
['20220630', 117.564, '20220704', 117.393, -0.171]
['20181129', 104.577, '20181130', 104.409, -0.168]
['20210825', 114.863, '20210826', 114.697, -0.166]
['20191024', 107.295, '20191025', 107.13, -0.165]
['20230728', 122.623, '20230731', 122.458, -0.165]
['20180816', 102.782, '20180820', 102.62, -0.162]
['20201217', 109.791, '20201218', 109.629, -0.162]
['20200805', 110.611, '20200812', 110.45, -0.161]
['20220217', 116.8, '20220221', 116.645, -0.155]
['20210423', 111.657, '20210428', 111.51, -0.147]
['20190215', 106.803, '20190220', 106.672, -0.131]
['20221109', 120.008, '20221111', 119.887, -0.121]
['20181022', 102.952, '20181023', 102.834, -0.118]
['20200814', 110.714, '20200819', 110.604, -0.11]
['20210506', 111.686, '20210511', 111.576, -0.11]
['20231023', 122.742, '20231025', 122.633, -0.109]
['20190301', 106.012, '20190304', 105.904, -0.108]
['20180913', 102.115, '20180920', 102.01, -0.105]
['20201130', 109.646, '20201203', 109.541, -0.105]
['20240705', 129.034, '20240708', 128.933, -0.101]
['20210929', 114.815, '20211011', 114.715, -0.1]
['20220920', 119.794, '20220923', 119.698, -0.096]
['20191018', 107.572, '20191021', 107.477, -0.095]
['20230922', 122.837, '20230925', 122.745, -0.092]
['20191216', 107.793, '20191217', 107.706, -0.087]
['20220622', 117.779, '20220627', 117.695, -0.084]
['20230329', 119.883, '20230330', 119.802, -0.081]
['20190621', 106.435, '20190627', 106.361, -0.074]
['20210618', 112.298, '20210624', 112.23, -0.068]
['20210330', 110.796, '20210406', 110.73, -0.066]
['20211203', 115.487, '20211209', 115.421, -0.066]
['20201124', 109.552, '20201127', 109.487, -0.065]
['20220224', 116.596, '20220301', 116.533, -0.063]
['20210121', 110.916, '20210126', 110.855, -0.061]
['20190906', 108.165, '20190912', 108.105, -0.06]
['20210602', 112.514, '20210604', 112.456, -0.058]
['20230217', 119.394, '20230222', 119.338, -0.056]
['20230621', 122.016, '20230629', 121.96, -0.056]
['20190827', 108.101, '20190902', 108.047, -0.054]
['20230302', 119.351, '20230303', 119.297, -0.054]
['20240514', 127.656, '20240516', 127.608, -0.048]
['20220609', 117.745, '20220613', 117.698, -0.047]
['20211115', 115.165, '20211123', 115.125, -0.04]
['20200415', 113.572, '20200420', 113.535, -0.037]
['20191127', 107.581, '20191202', 107.545, -0.036]
['20200521', 112.959, '20200526', 112.925, -0.034]
['20210512', 111.75, '20210517', 111.716, -0.034]
['20230224', 119.373, '20230227', 119.34, -0.033]
['20231116', 123.448, '20231123', 123.416, -0.032]
['20180926', 102.165, '20181009', 102.136, -0.029]
['20210202', 110.595, '20210205', 110.566, -0.029]
['20230210', 119.355, '20230216', 119.329, -0.026]
['20220509', 117.275, '20220516', 117.261, -0.014]
['20220422', 117.13, '20220428', 117.119, -0.011]
['20210302', 110.614, '20210315', 110.608, -0.006]
['20190110', 106.12, '20190114', 106.129, 0.009]
['20230912', 122.884, '20230918', 122.896, 0.012]
['20191106', 106.793, '20191111', 106.81, 0.017]
['20230928', 122.583, '20231011', 122.601, 0.018]
['20191009', 107.606, '20191014', 107.626, 0.02]
['20210322', 110.578, '20210329', 110.6, 0.022]
['20231129', 123.317, '20231206', 123.343, 0.026]
['20221118', 119.115, '20221128', 119.154, 0.039]
['20210106', 110.309, '20210112', 110.356, 0.047]
['20201019', 109.806, '20201026', 109.856, 0.05]
['20191203', 107.67, '20191210', 107.726, 0.056]
['20211230', 116.165, '20220107', 116.225, 0.06]
['20231016', 122.669, '20231019', 122.734, 0.065]
['20211124', 115.367, '20211201', 115.435, 0.068]
['20180823', 102.078, '20180831', 102.148, 0.07]
['20190116', 106.213, '20190121', 106.294, 0.081]
['20190715', 106.997, '20190725', 107.08, 0.083]
['20210917', 114.599, '20210928', 114.706, 0.107]
['20190614', 106.25, '20190619', 106.362, 0.112]
['20230519', 121.398, '20230526', 121.52, 0.122]
['20221229', 119.186, '20230106', 119.311, 0.125]
['20240318', 126.541, '20240321', 126.679, 0.138]
['20221214', 118.878, '20221226', 119.025, 0.147]
['20220830', 119.842, '20220907', 120.001, 0.159]
['20230718', 122.426, '20230725', 122.608, 0.182]
['20240625', 128.608, '20240701', 128.79, 0.182]
['20201204', 109.65, '20201211', 109.836, 0.186]
['20210901', 114.673, '20210908', 114.861, 0.188]
['20201028', 110.013, '20201106', 110.203, 0.19]
['20240507', 127.32, '20240510', 127.52, 0.2]
['20210113', 110.588, '20210119', 110.79, 0.202]
['20190703', 106.494, '20190708', 106.698, 0.204]
['20220311', 116.545, '20220317', 116.766, 0.221]
['20240306', 126.779, '20240312', 127.001, 0.222]
['20220325', 116.678, '20220331', 116.904, 0.226]
['20230130', 119.012, '20230208', 119.254, 0.242]
['20221010', 119.242, '20221024', 119.488, 0.246]
['20240521', 127.593, '20240531', 127.839, 0.246]
['20200609', 111.781, '20200616', 112.03, 0.249]
['20181030', 103.181, '20181105', 103.435, 0.254]
['20221027', 119.686, '20221102', 119.944, 0.258]
['20230331', 119.91, '20230417', 120.172, 0.262]
['20230630', 122.111, '20230714', 122.374, 0.263]
['20180727', 102.705, '20180808', 102.978, 0.273]
['20220401', 117.03, '20220413', 117.325, 0.295]
['20200106', 108.471, '20200116', 108.769, 0.298]
['20200901', 110.01, '20200914', 110.315, 0.305]
['20210816', 114.471, '20210824', 114.781, 0.31]
['20190130', 106.192, '20190214', 106.523, 0.331]
['20220707', 117.56, '20220719', 117.892, 0.332]
['20201222', 109.722, '20210104', 110.056, 0.334]
['20180712', 102.35, '20180723', 102.699, 0.349]
['20190307', 105.943, '20190318', 106.299, 0.356]
['20211213', 115.466, '20211229', 115.861, 0.395]
['20180702', 102.1, '20180709', 102.5, 0.4]
['20231208', 123.392, '20231221', 123.838, 0.446]
['20200714', 109.883, '20200721', 110.335, 0.452]
['20200917', 110.124, '20200925', 110.579, 0.455]
['20220519', 117.49, '20220531', 117.954, 0.464]
['20180615', 101.28, '20180629', 101.751, 0.471]
['20230306', 119.352, '20230321', 119.823, 0.471]
['20181010', 102.393, '20181019', 102.868, 0.475]
['20240604', 127.906, '20240624', 128.42, 0.514]
['20231026', 122.804, '20231115', 123.335, 0.531]
['20190319', 106.409, '20190329', 106.941, 0.532]
['20210519', 111.929, '20210527', 112.472, 0.543]
['20240219', 125.865, '20240301', 126.437, 0.572]
['20181204', 104.874, '20181213', 105.449, 0.575]
['20200722', 110.585, '20200729', 111.178, 0.593]
['20210412', 110.882, '20210422', 111.476, 0.594]
['20191219', 107.75, '20200103', 108.345, 0.595]
['20191112', 106.92, '20191125', 107.53, 0.61]
['20220815', 119.176, '20220825', 119.832, 0.656]
['20230601', 121.493, '20230616', 122.177, 0.684]
['20190529', 105.636, '20190611', 106.323, 0.687]
['20200423', 113.749, '20200506', 114.445, 0.696]
['20211021', 114.238, '20211110', 115.055, 0.817]
['20220721', 118.074, '20220808', 118.895, 0.821]
['20220110', 116.339, '20220126', 117.181, 0.842]
['20231222', 123.928, '20240111', 124.79, 0.862]
['20240117', 124.838, '20240206', 125.733, 0.895]
['20210721', 114.025, '20210809', 114.921, 0.896]
['20230803', 122.596, '20230824', 123.612, 1.016]
['20240328', 126.747, '20240424', 127.772, 1.025]
['20181220', 105.006, '20190108', 106.04, 1.034]
['20190425', 104.774, '20190521', 105.836, 1.062]
['20181106', 103.585, '20181121', 104.697, 1.112]
['20230419', 120.25, '20230516', 121.37, 1.12]
['20200323', 112.088, '20200413', 113.401, 1.313]
['20190731', 107.094, '20190816', 108.408, 1.314]
['20210625', 112.411, '20210716', 113.814, 1.403]
['20200224', 110.808, '20200313', 112.876, 2.068]
['20200120', 108.84, '20200214', 111.21, 2.37]
总交易次数 166
股价变化 28.861
总利润 31.507
盈利率 31.1 %
回测五:长期国债(长期上涨,短期有较大波动)
选取30年国债ETF(511090),时间:成立-20240730
['20230908', 102.863, '20230911', 102.06, -0.803]
['20231023', 102.086, '20231025', 101.773, -0.313]
['20240508', 111.549, '20240509', 111.236, -0.313]
['20230921', 102.296, '20230922', 102.055, -0.241]
['20240514', 111.45, '20240516', 111.239, -0.211]
['20240403', 113.85, '20240410', 113.651, -0.199]
['20231013', 102.143, '20231019', 102.037, -0.106]
['20231117', 103.058, '20231122', 103.024, -0.034]
['20240328', 113.555, '20240402', 113.523, -0.032]
['20240710', 113.311, '20240716', 113.328, 0.017]
['20230914', 102.24, '20230918', 102.308, 0.068]
['20230928', 101.911, '20231011', 102.006, 0.095]
['20231129', 102.82, '20231205', 102.955, 0.135]
['20240624', 113.743, '20240701', 113.957, 0.214]
['20230717', 101.445, '20230725', 101.675, 0.23]
['20230802', 101.722, '20230811', 102.029, 0.307]
['20240522', 111.064, '20240531', 111.643, 0.579]
['20240105', 105.727, '20240112', 106.484, 0.757]
['20240315', 112.894, '20240322', 113.665, 0.771]
['20230621', 100.549, '20230714', 101.333, 0.784]
['20231031', 102.025, '20231115', 102.812, 0.787]
['20240605', 111.9, '20240621', 113.028, 1.128]
['20240416', 113.568, '20240424', 114.734, 1.166]
['20230814', 102.097, '20230828', 104.084, 1.987]
['20231206', 103.134, '20231228', 105.39, 2.256]
['20240220', 110.818, '20240311', 113.977, 3.159]
['20240117', 106.549, '20240207', 110.013, 3.464]
总交易次数 27
股价变化 15.621
总利润 15.652
盈利率 15.6 %
结论:(此结论仅本人主观判断,未必正确)
1、对于交易量较大的股票或基金成功率较高,小盘股波动大成功率低。
2、对于国债类产品,该策略价值不大,国债更适合买入后长期持有,设置网格策略,下跌后补仓,回涨到起跌点时将补仓部分卖出。卖出后的资金可用于其他投资品种。