对于因子分析,一个很重要的需求是如何对因子的参数做穷举测试,从而找到最优的参数.在聚宽中,在新版本中提供了对参数动态调整的方法.本例是通过一个简单的例子,来延时方法的使用; 测试方法:
创建回测代码,并在聚宽系统中编译运行,策略编译后,可以 下面的ID就是需要回测的策略; algorithmId=bde5766fd886bf891d196d15beda3c20
在策略中使用global 参数替代需要动态调整的参数,需要在init中定义,但回测程序是运行在init函数之后,因此会覆盖这些变量,达到动态调参的目的; g.ma1 = 5 g.ma2 = 10 g.ma3 = 20
创建回测程序,多次调用回测,并把结果保存在result的列表中;
create_backtest(algorithm_id, start_date, end_date, frequency="day", initial_cash=10000,initial_positions=None, extras=None, name=None, code="", benchmark=None)
在执行完成后,调用get_backtest取得结果;
通过dataframe将结果输出
通过plot绘制结果图表
# algorithmId = 'fa291fe236040e62ceb02a8aa9d30711'backtest_list = []for i in range()extra_vars = {'ma1': 7, 'ma2': 8, 'ma3': 10}params = {"algorithm_id": algorithmId,"start_date": "2015-10-01","end_date": "2016-07-31","frequency": "day","initial_cash": "1000000",# "initial_positions": initial_positions,"extras": extra_vars,}created_bt_id = create_backtest( **params)import pandas as pd# 需要回测的策略ID;algorithmId = 'fa291fe236040e62ceb02a8aa9d30711'# 保存测试结果的列表backtest_list = []# 创建一个循环,用于运行回测策略;for i in range(1,20,5):# 回测主要参数,赋值extra_vars = {'ma1': i, 'ma2': i + 5, 'ma3': i + 10}# print(extra_vars)# 回测参数赋值params = {"algorithm_id": algorithmId, "start_date": "2015-10-01","end_date": "2016-07-31","frequency": "day","initial_cash": "1000000",# "initial_positions": initial_positions,"extras": extra_vars, # 回测动态参数,字典类型;}# 开始回测,并将结果对象保存在列表中backtest_list.append(create_backtest( **params))# 获取测试结果# 创建函数,将参数dict转换为strdef dict_to_str(d):tmp_str = ""name = ""for k,v in d.items():tmp_str = name + str(k) + ":" + str(v)name = tmp_str + "-"return namegt = get_backtest(backtest_list[0]) # 获取第一个测试结果对象res = gt.get_results() #得到测试结果res_list = []time_list = []for j in res:res_list.append(j['benchmark_returns'])time_list.append(j['time'])# 创建dataframe对象data = pd.DataFrame(index=time_list)data['result'] = res_list# 画出收益曲线图data.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f9a5720d208>
# 多个测试结果的比较for i in range(len(backtest_list)):gt = get_backtest(backtest_list[i])result_tmp = gt.get_results()param_dict = gt.get_params()name = param_dict['name']name_param = dict_to_str(param_dict['extras'])name_title = name + "" + name_param# print(name_title)res1_list = []for r in result_tmp:res1_list.append(r['returns'])data[name_title] = res1_listdata.plot()
<matplotlib.axes._subplots.AxesSubplot at 0x7f9a3cd54dd8>
# 其他结果gt = get_backtest(backtest_list[0])# 获取运行结果gt.get_results()
[{'benchmark_returns': 0.029201205139012476,
'returns': 0.0,
'time': '2015-10-08 16:00:00'},
{'benchmark_returns': 0.0428261446479028,
'returns': 0.0,
'time': '2015-10-09 16:00:00'},
{'benchmark_returns': 0.07641080878565076,
'returns': 0.0,
'time': '2015-10-12 16:00:00'},
{'benchmark_returns': 0.07558344651024851,
'returns': 0.0,
'time': '2015-10-13 16:00:00'},
{'benchmark_returns': 0.06342902636631864,
'returns': 0.0,
'time': '2015-10-14 16:00:00'},
{'benchmark_returns': 0.08862767136546013,
'returns': 0.0,
'time': '2015-10-15 16:00:00'},
{'benchmark_returns': 0.10337969684197401,
'returns': 0.0,
'time': '2015-10-16 16:00:00'},
{'benchmark_returns': 0.10341404018170741,
'returns': 0.0,
'time': '2015-10-19 16:00:00'},
{'benchmark_returns': 0.11700151422907012,
'returns': 0.0,
'time': '2015-10-20 16:00:00'},
{'benchmark_returns': 0.08439095209104108,
'returns': 0.0,
'time': '2015-10-21 16:00:00'},
{'benchmark_returns': 0.1004011926505255,
'returns': 0.0,
'time': '2015-10-22 16:00:00'},
{'benchmark_returns': 0.11498462355016459,
'returns': 0.0,
'time': '2015-10-23 16:00:00'},
{'benchmark_returns': 0.1206106870229009,
'returns': 0.0,
'time': '2015-10-26 16:00:00'},
{'benchmark_returns': 0.12174089511231845,
'returns': 0.0,
'time': '2015-10-27 16:00:00'},
{'benchmark_returns': 0.10052295540049028,
'returns': 0.0,
'time': '2015-10-28 16:00:00'},
{'benchmark_returns': 0.10314241558563197,
'returns': 0.0,
'time': '2015-10-29 16:00:00'},
{'benchmark_returns': 0.10338281896376778,
'returns': 0.0,
'time': '2015-10-30 16:00:00'},
{'benchmark_returns': 0.08523704709720725,
'returns': 0.0,
'time': '2015-11-02 16:00:00'},
{'benchmark_returns': 0.08196818557891938,
'returns': 0.0,
'time': '2015-11-03 16:00:00'},
{'benchmark_returns': 0.1328743814296196,
'returns': 0.0,
'time': '2015-11-04 16:00:00'},
{'benchmark_returns': 0.1570489704803384,
'returns': 0.0,
'time': '2015-11-05 16:00:00'},
{'benchmark_returns': 0.18433631495964664,
'returns': 0.0,
'time': '2015-11-06 16:00:00'},
{'benchmark_returns': 0.19900716526951734,
'returns': 0.0,
'time': '2015-11-09 16:00:00'},
{'benchmark_returns': 0.19678421455220962,
'returns': 0.0,
'time': '2015-11-10 16:00:00'},
{'benchmark_returns': 0.1969122215457626,
'returns': 0.0,
'time': '2015-11-11 16:00:00'},
{'benchmark_returns': 0.184945128709471,
'returns': 0.0,
'time': '2015-11-12 16:00:00'},
{'benchmark_returns': 0.16962175494466036,
'returns': 0.0,
'time': '2015-11-13 16:00:00'},
{'benchmark_returns': 0.17520723083407486,
'returns': 0.0,
'time': '2015-11-16 16:00:00'},
{'benchmark_returns': 0.1734151329243354,
'returns': 0.0,
'time': '2015-11-17 16:00:00'},
{'benchmark_returns': 0.1600493295243448,
'returns': 0.0,
'time': '2015-11-18 16:00:00'},
{'benchmark_returns': 0.17859161085873954,
'returns': 0.027737318800000077,
'time': '2015-11-19 16:00:00'},
{'benchmark_returns': 0.17840740567289548,
'returns': -0.002580681199999879,
'time': '2015-11-20 16:00:00'},
{'benchmark_returns': 0.1718384614183801,
'returns': -0.004699681199999972,
'time': '2015-11-23 16:00:00'},
{'benchmark_returns': 0.17201017811704844,
'returns': 0.03034531880000002,
'time': '2015-11-24 16:00:00'},
{'benchmark_returns': 0.1806646997299366,
'returns': 0.07011731880000016,
'time': '2015-11-25 16:00:00'},
{'benchmark_returns': 0.1737398335909084,
'returns': 0.012415318800000241,
'time': '2015-11-26 16:00:00'},
{'benchmark_returns': 0.11053559999375584,
'returns': -0.04707968119999972,
'time': '2015-11-27 16:00:00'},
{'benchmark_returns': 0.11347663872367653,
'returns': -0.0715296811999997,
'time': '2015-11-30 16:00:00'},
{'benchmark_returns': 0.12137248474062967,
'returns': -0.08261368119999968,
'time': '2015-12-01 16:00:00'},
{'benchmark_returns': 0.16203812110710447,
'returns': -0.057674681199999744,
'time': '2015-12-02 16:00:00'},
{'benchmark_returns': 0.1705771242136156,
'returns': -0.03403968119999967,
'time': '2015-12-03 16:00:00'},
{'benchmark_returns': 0.14818838882904828,
'returns': -0.06370568119999964,
'time': '2015-12-04 16:00:00'},
{'benchmark_returns': 0.15131675486660745,
'returns': -0.05718568119999967,
'time': '2015-12-07 16:00:00'},
{'benchmark_returns': 0.13115097019934763,
'returns': -0.07256857799999972,
'time': '2015-12-08 16:00:00'},
{'benchmark_returns': 0.13518475155715826,
'returns': -0.07256857799999972,
'time': '2015-12-09 16:00:00'},
{'benchmark_returns': 0.13116970293011132,
'returns': -0.07256857799999972,
'time': '2015-12-10 16:00:00'},
{'benchmark_returns': 0.12648027599556655,
'returns': -0.07256857799999972,
'time': '2015-12-11 16:00:00'},
{'benchmark_returns': 0.15871930564011305,
'returns': -0.07256857799999972,
'time': '2015-12-14 16:00:00'},
{'benchmark_returns': 0.15343355344291987,
'returns': -0.07256857799999972,
'time': '2015-12-15 16:00:00'},
{'benchmark_returns': 0.15063925443731563,
'returns': -0.07256857799999972,
'time': '2015-12-16 16:00:00'},
{'benchmark_returns': 0.1726346024758425,
'returns': -0.07256857799999972,
'time': '2015-12-17 16:00:00'},
{'benchmark_returns': 0.17638739287219596,
'returns': -0.07256857799999972,
'time': '2015-12-18 16:00:00'},
{'benchmark_returns': 0.20700291918387737,
'returns': -0.07256857799999972,
'time': '2015-12-21 16:00:00'},
{'benchmark_returns': 0.21036232223419038,
'returns': -0.07256857799999972,
'time': '2015-12-22 16:00:00'},
{'benchmark_returns': 0.20713092617743034,
'returns': -0.07256857799999972,
'time': '2015-12-23 16:00:00'},
{'benchmark_returns': 0.19558531978332483,
'returns': -0.07256857799999972,
'time': '2015-12-24 16:00:00'},
{'benchmark_returns': 0.1983327869620195,
'returns': -0.07256857799999972,
'time': '2015-12-25 16:00:00'},
{'benchmark_returns': 0.16381148628608022,
'returns': -0.09874141619999965,
'time': '2015-12-28 16:00:00'},
{'benchmark_returns': 0.17450475343043137,
'returns': -0.10953141619999962,
'time': '2015-12-29 16:00:00'},
{'benchmark_returns': 0.17553505362244182,
'returns': -0.09542141619999955,
'time': '2015-12-30 16:00:00'},
{'benchmark_returns': 0.16486676345244233,
'returns': -0.13194141619999955,
'time': '2015-12-31 16:00:00'},
{'benchmark_returns': 0.08308590518116121,
'returns': -0.2182614161999996,
'time': '2016-01-04 16:00:00'},
{'benchmark_returns': 0.08611748544310727,
'returns': -0.2604254161999997,
'time': '2016-01-05 16:00:00'},
{'benchmark_returns': 0.10517179475171323,
'returns': -0.23950941619999977,
'time': '2016-01-06 16:00:00'},
{'benchmark_returns': 0.028545559562278555,
'returns': -0.31503941619999976,
'time': '2016-01-07 16:00:00'},
{'benchmark_returns': 0.04951997377417694,
'returns': -0.3083994161999998,
'time': '2016-01-08 16:00:00'},
{'benchmark_returns': -0.0032782278836697154,
'returns': -0.3332994161999998,
'time': '2016-01-11 16:00:00'},
{'benchmark_returns': 0.003983827409107299,
'returns': -0.3040834161999998,
'time': '2016-01-12 16:00:00'},
{'benchmark_returns': -0.014695827284222251,
'returns': -0.3401054161999998,
'time': '2016-01-13 16:00:00'},
{'benchmark_returns': 0.00581339078037435,
'returns': -0.28266941619999975,
'time': '2016-01-14 16:00:00'},
{'benchmark_returns': -0.02629450974882519,
'returns': -0.31055741619999977,
'time': '2016-01-15 16:00:00'},
{'benchmark_returns': -0.022547963596059817,
'returns': -0.28300141619999974,
'time': '2016-01-18 16:00:00'},
{'benchmark_returns': 0.006300441780233923,
'returns': -0.2571054161999997,
'time': '2016-01-19 16:00:00'},
{'benchmark_returns': -0.00891990196537562,
'returns': -0.28748341619999973,
'time': '2016-01-20 16:00:00'},
{'benchmark_returns': -0.03796500101468958,
'returns': -0.30183253919999975,
'time': '2016-01-21 16:00:00'},
{'benchmark_returns': -0.027939867934248075,
'returns': -0.30183253919999975,
'time': '2016-01-22 16:00:00'},
{'benchmark_returns': -0.02312243400615055,
'returns': -0.30183253919999975,
'time': '2016-01-25 16:00:00'},
{'benchmark_returns': -0.08193696436097964,
'returns': -0.30183253919999975,
'time': '2016-01-26 16:00:00'},
{'benchmark_returns': -0.08510904010365439,
'returns': -0.2809861215999997,
'time': '2016-01-27 16:00:00'},
{'benchmark_returns': -0.10902137092367958,
'returns': -0.3110661215999997,
'time': '2016-01-28 16:00:00'},
{'benchmark_returns': -0.08019482039994374,
'returns': -0.2759101215999997,
'time': '2016-01-29 16:00:00'},
{'benchmark_returns': -0.09425685695998987,
'returns': -0.29339412159999967,
'time': '2016-02-01 16:00:00'},
{'benchmark_returns': -0.07543670678593173,
'returns': -0.2589901215999997,
'time': '2016-02-02 16:00:00'},
{'benchmark_returns': -0.07939867934248113,
'returns': -0.25974212159999976,
'time': '2016-02-03 16:00:00'},
{'benchmark_returns': -0.06812157542265707,
'returns': -0.24583012159999962,
'time': '2016-02-04 16:00:00'},
{'benchmark_returns': -0.07466866482461476,
'returns': -0.2674501215999996,
'time': '2016-02-05 16:00:00'},
{'benchmark_returns': -0.08000124884871751,
'returns': -0.2745941215999995,
'time': '2016-02-15 16:00:00'},
{'benchmark_returns': -0.051799122683775845,
'returns': -0.2165021215999995,
'time': '2016-02-16 16:00:00'},
{'benchmark_returns': -0.04359418660921954,
'returns': -0.2187581215999993,
'time': '2016-02-17 16:00:00'},
{'benchmark_returns': -0.046597667775019946,
'returns': -0.22176612159999942,
'time': '2016-02-18 16:00:00'},
{'benchmark_returns': -0.04725643547354774,
'returns': -0.21424612159999934,
'time': '2016-02-19 16:00:00'},
{'benchmark_returns': -0.02625080004370972,
'returns': -0.20127412159999925,
'time': '2016-02-22 16:00:00'},
{'benchmark_returns': -0.03546418145771857,
'returns': -0.22233012159999943,
'time': '2016-02-23 16:00:00'},
{'benchmark_returns': -0.02916061755569077,
'returns': -0.22815812159999926,
'time': '2016-02-24 16:00:00'},
{'benchmark_returns': -0.08873070138466099,
'returns': -0.3054261215999996,
'time': '2016-02-25 16:00:00'},
{'benchmark_returns': -0.07958912877191326,
'returns': -0.3027625563999995,
'time': '2016-02-26 16:00:00'},
{'benchmark_returns': -0.1016188201501741,
'returns': -0.3655284546999995,
'time': '2016-02-29 16:00:00'},
{'benchmark_returns': -0.08500288796265931,
'returns': -0.34058045469999954,
'time': '2016-03-01 16:00:00'},
{'benchmark_returns': -0.04733761064019104,
'returns': -0.3073164546999996,
'time': '2016-03-02 16:00:00'},
{'benchmark_returns': -0.045124026288265395,
'returns': -0.30939545469999963,
'time': '2016-03-03 16:00:00'},
{'benchmark_returns': -0.03404986028504975,
'returns': -0.3462504546999996,
'time': '2016-03-04 16:00:00'},
{'benchmark_returns': -0.030631136920651225,
'returns': -0.3258384546999996,
'time': '2016-03-07 16:00:00'},
{'benchmark_returns': -0.029747576452957336,
'returns': -0.33501047349999946,
'time': '2016-03-08 16:00:00'},
{'benchmark_returns': -0.04091228398819835,
'returns': -0.33501047349999946,
'time': '2016-03-09 16:00:00'},
{'benchmark_returns': -0.05925787164957297,
'returns': -0.33501047349999946,
'time': '2016-03-10 16:00:00'},
{'benchmark_returns': -0.057656223169265663,
'returns': -0.33501047349999946,
'time': '2016-03-11 16:00:00'},
{'benchmark_returns': -0.04285424374404834,
'returns': -0.31370429189999927,
'time': '2016-03-14 16:00:00'},
{'benchmark_returns': -0.04001623503332852,
'returns': -0.3292252918999994,
'time': '2016-03-15 16:00:00'},
{'benchmark_returns': -0.035254999297522516,
'returns': -0.3134732533999993,
'time': '2016-03-16 16:00:00'},
{'benchmark_returns': -0.024586709127523032,
'returns': -0.2501820878999992,
'time': '2016-03-17 16:00:00'},
{'benchmark_returns': -0.009675455439516645,
'returns': -0.17529808789999923,
'time': '2016-03-18 16:00:00'},
{'benchmark_returns': 0.014514744220172071,
'returns': -0.1311010878999992,
'time': '2016-03-21 16:00:00'},
{'benchmark_returns': 0.0071309261774301635,
'returns': -0.15387508789999915,
'time': '2016-03-22 16:00:00'},
{'benchmark_returns': 0.010346711625220495,
'returns': -0.10041408789999917,
'time': '2016-03-23 16:00:00'},
{'benchmark_returns': -0.006587676985279178,
'returns': -0.13997908789999924,
'time': '2016-03-24 16:00:00'},
{'benchmark_returns': -0.001601648480307083,
'returns': -0.1526617933999993,
'time': '2016-03-25 16:00:00'},
{'benchmark_returns': -0.01037168859957216,
'returns': -0.1526617933999993,
'time': '2016-03-28 16:00:00'},
{'benchmark_returns': -0.02108681059648132,
'returns': -0.1526617933999993,
'time': '2016-03-29 16:00:00'},
{'benchmark_returns': 0.0041617883513636045,
'returns': -0.1526617933999993,
'time': '2016-03-30 16:00:00'},
{'benchmark_returns': 0.00472689239607238,
'returns': -0.1526617933999993,
'time': '2016-03-31 16:00:00'},
{'benchmark_returns': 0.005913298677781453,
'returns': -0.1526617933999993,
'time': '2016-04-01 16:00:00'},
{'benchmark_returns': 0.019213537520098578,
'returns': -0.1526617933999993,
'time': '2016-04-05 16:00:00'},
{'benchmark_returns': 0.01704054075149486,
'returns': -0.1526617933999993,
'time': '2016-04-06 16:00:00'},
{'benchmark_returns': 0.001979425217377706,
'returns': -0.1526617933999993,
'time': '2016-04-07 16:00:00'},
{'benchmark_returns': -0.005376293729218329,
'returns': -0.1526617933999993,
'time': '2016-04-08 16:00:00'},
{'benchmark_returns': 0.00847656067063185,
'returns': -0.16353062699999943,
'time': '2016-04-11 16:00:00'},
{'benchmark_returns': 0.004839288780655426,
'returns': -0.14017762699999947,
'time': '2016-04-12 16:00:00'},
{'benchmark_returns': 0.01824255764217364,
'returns': -0.1270306985999995,
'time': '2016-04-13 16:00:00'},
{'benchmark_returns': 0.022754023634462106,
'returns': -0.1270306985999995,
'time': '2016-04-14 16:00:00'},
{'benchmark_returns': 0.021623815545044556,
'returns': -0.1270306985999995,
'time': '2016-04-15 16:00:00'},
{'benchmark_returns': 0.007961410574626626,
'returns': -0.1270306985999995,
'time': '2016-04-18 16:00:00'},
{'benchmark_returns': 0.01103670054168826,
'returns': -0.1270306985999995,
'time': '2016-04-19 16:00:00'},
{'benchmark_returns': -0.006843690972384686,
'returns': -0.1270306985999995,
'time': '2016-04-20 16:00:00'},
{'benchmark_returns': -0.013222185797467922,
'returns': -0.1563453487999994,
'time': '2016-04-21 16:00:00'},
{'benchmark_returns': -0.008757551632089133,
'returns': -0.12768934879999938,
'time': '2016-04-22 16:00:00'},
{'benchmark_returns': -0.012775722380929944,
'returns': -0.12768934879999938,
'time': '2016-04-25 16:00:00'},
{'benchmark_returns': -0.0074275277478574875,
'returns': -0.12768934879999938,
'time': '2016-04-26 16:00:00'},
{'benchmark_returns': -0.01156121700307522,
'returns': -0.12768934879999938,
'time': '2016-04-27 16:00:00'},
{'benchmark_returns': -0.013228430041055894,
'returns': -0.12768934879999938,
'time': '2016-04-28 16:00:00'},
{'benchmark_returns': -0.014424202688146814,
'returns': -0.12768934879999938,
'time': '2016-04-29 16:00:00'},
{'benchmark_returns': 0.003306326979815477,
'returns': -0.08351134879999944,
'time': '2016-05-03 16:00:00'},
{'benchmark_returns': 0.0020325012878752435,
'returns': -0.10142134879999942,
'time': '2016-05-04 16:00:00'},
{'benchmark_returns': 0.0034249676079864955,
'returns': -0.09465534879999937,
'time': '2016-05-05 16:00:00'},
{'benchmark_returns': -0.022666604224230724,
'returns': -0.14440534879999944,
'time': '2016-05-06 16:00:00'},
{'benchmark_returns': -0.04287609859660624,
'returns': -0.18818534879999949,
'time': '2016-05-09 16:00:00'},
{'benchmark_returns': -0.04178647809051017,
'returns': -0.18539934879999942,
'time': '2016-05-10 16:00:00'},
{'benchmark_returns': -0.037509171232769756,
'returns': -0.20569734879999946,
'time': '2016-05-11 16:00:00'},
{'benchmark_returns': -0.03522065595778889,
'returns': -0.20450334879999943,
'time': '2016-05-12 16:00:00'},
{'benchmark_returns': -0.03996628108462508,
'returns': -0.21405534879999943,
'time': '2016-05-13 16:00:00'},
{'benchmark_returns': -0.033606518990305756,
'returns': -0.1929613487999995,
'time': '2016-05-16 16:00:00'},
{'benchmark_returns': -0.03650697013690496,
'returns': -0.17624534879999942,
'time': '2016-05-17 16:00:00'},
{'benchmark_returns': -0.042120545122465214,
'returns': -0.20609534879999947,
'time': '2016-05-18 16:00:00'},
{'benchmark_returns': -0.04385020059632516,
'returns': -0.1973393487999996,
'time': '2016-05-19 16:00:00'},
{'benchmark_returns': -0.0389422251362026,
'returns': -0.20990476599999963,
'time': '2016-05-20 16:00:00'},
{'benchmark_returns': -0.036132315521628544,
'returns': -0.20990476599999963,
'time': '2016-05-23 16:00:00'},
{'benchmark_returns': -0.043519255686164326,
'returns': -0.20990476599999963,
'time': '2016-05-24 16:00:00'},
{'benchmark_returns': -0.04487113442295376,
'returns': -0.2239296897999995,
'time': '2016-05-25 16:00:00'},
{'benchmark_returns': -0.043316317769556134,
'returns': -0.21129068979999965,
'time': '2016-05-26 16:00:00'},
{'benchmark_returns': -0.04385020059632516,
'returns': -0.2203484099999996,
'time': '2016-05-27 16:00:00'},
{'benchmark_returns': -0.042535787321063334,
'returns': -0.2203484099999996,
'time': '2016-05-30 16:00:00'},
{'benchmark_returns': -0.010424764670069697,
'returns': -0.2203484099999996,
'time': '2016-05-31 16:00:00'},
{'benchmark_returns': -0.01323779640643774,
'returns': -0.2203484099999996,
'time': '2016-06-01 16:00:00'},
{'benchmark_returns': -0.011192806631386665,
'returns': -0.2203484099999996,
'time': '2016-06-02 16:00:00'},
{'benchmark_returns': -0.00425232988338875,
'returns': -0.2203484099999996,
'time': '2016-06-03 16:00:00'},
{'benchmark_returns': -0.007543046254234298,
'returns': -0.2203484099999996,
'time': '2016-06-06 16:00:00'},
{'benchmark_returns': -0.008086295446385283,
'returns': -0.2203484099999996,
'time': '2016-06-07 16:00:00'},
{'benchmark_returns': -0.012163786509311714,
'returns': -0.2203484099999996,
'time': '2016-06-08 16:00:00'},
{'benchmark_returns': -0.042651305827440256,
'returns': -0.2203484099999996,
'time': '2016-06-13 16:00:00'},
{'benchmark_returns': -0.0396415804180521,
'returns': -0.2203484099999996,
'time': '2016-06-14 16:00:00'},
{'benchmark_returns': -0.02703133049220252,
'returns': -0.18693751919999957,
'time': '2016-06-15 16:00:00'},
{'benchmark_returns': -0.03380633478511985,
'returns': -0.20470351919999963,
'time': '2016-06-16 16:00:00'},
{'benchmark_returns': -0.028907725690379138,
'returns': -0.19676551919999952,
'time': '2016-06-17 16:00:00'},
{'benchmark_returns': -0.028186515555971736,
'returns': -0.2020575191999996,
'time': '2016-06-20 16:00:00'},
{'benchmark_returns': -0.030169062895143428,
'returns': -0.19563151919999966,
'time': '2016-06-21 16:00:00'},
{'benchmark_returns': -0.02153951825660716,
'returns': -0.2049706139999996,
'time': '2016-06-22 16:00:00'},
{'benchmark_returns': -0.026734728921775086,
'returns': -0.2049706139999996,
'time': '2016-06-23 16:00:00'},
{'benchmark_returns': -0.03927317004636355,
'returns': -0.2049706139999996,
'time': '2016-06-24 16:00:00'},
{'benchmark_returns': -0.025729405704116526,
'returns': -0.2049706139999996,
'time': '2016-06-27 16:00:00'},
{'benchmark_returns': -0.020777720538878164,
'returns': -0.2049706139999996,
'time': '2016-06-28 16:00:00'},
{'benchmark_returns': -0.01609765996971535,
'returns': -0.2049706139999996,
'time': '2016-06-29 16:00:00'},
{'benchmark_returns': -0.015307763155840592,
'returns': -0.2049706139999996,
'time': '2016-06-30 16:00:00'},
{'benchmark_returns': -0.015220343745609544,
'returns': -0.2049706139999996,
'time': '2016-07-01 16:00:00'},
{'benchmark_returns': 0.00054637131394486,
'returns': -0.2049706139999996,
'time': '2016-07-04 16:00:00'},
{'benchmark_returns': 0.0013830999547292944,
'returns': -0.2049706139999996,
'time': '2016-07-05 16:00:00'},
{'benchmark_returns': 0.004324138684650203,
'returns': -0.2049706139999996,
'time': '2016-07-06 16:00:00'},
{'benchmark_returns': 0.0021854852557798843,
'returns': -0.2049706139999996,
'time': '2016-07-07 16:00:00'},
{'benchmark_returns': -0.003331303954167142,
'returns': -0.2049706139999996,
'time': '2016-07-08 16:00:00'},
{'benchmark_returns': 0.00011864062817101839,
'returns': -0.2049706139999996,
'time': '2016-07-11 16:00:00'},
{'benchmark_returns': 0.02192666135905963,
'returns': -0.2049706139999996,
'time': '2016-07-12 16:00:00'},
{'benchmark_returns': 0.02495199737741771,
'returns': -0.2049706139999996,
'time': '2016-07-13 16:00:00'},
{'benchmark_returns': 0.02304438096130146,
'returns': -0.2049706139999996,
'time': '2016-07-14 16:00:00'},
{'benchmark_returns': 0.022894519115190803,
'returns': -0.2049706139999996,
'time': '2016-07-15 16:00:00'},
{'benchmark_returns': 0.018442373436987847,
'returns': -0.2097183659999996,
'time': '2016-07-18 16:00:00'},
{'benchmark_returns': 0.014136967483101559,
'returns': -0.20219836599999963,
'time': '2016-07-19 16:00:00'},
{'benchmark_returns': 0.010821274137904124,
'returns': -0.20896636599999963,
'time': '2016-07-20 16:00:00'},
{'benchmark_returns': 0.015476357732715273,
'returns': -0.20633436599999966,
'time': '2016-07-21 16:00:00'},
{'benchmark_returns': 0.006934232504409943,
'returns': -0.2213743659999996,
'time': '2016-07-22 16:00:00'},
{'benchmark_returns': 0.0087232082923554,
'returns': -0.2164863659999996,
'time': '2016-07-25 16:00:00'},
{'benchmark_returns': 0.020805819635024037,
'returns': -0.20708636599999952,
'time': '2016-07-26 16:00:00'},
{'benchmark_returns': 0.004773724222981945,
'returns': -0.24543836599999957,
'time': '2016-07-27 16:00:00'},
{'benchmark_returns': 0.0056791395432336245,
'returns': -0.24882236599999963,
'time': '2016-07-28 16:00:00'},
{'benchmark_returns': 0.0003059679358092815,
'returns': -0.25596636599999945,
'time': '2016-07-29 16:00:00'}]# 获取参数信息gt.get_orders() # 下单记录gt.get_params() # 参数gt.get_period_risks()['sharpe'] # 一段周期的策略评价gt.get_positions() # 仓位情况gt.get_risk() # 策略评价
{'__version': 101,
'algorithm_return': -0.25596636599999945,
'algorithm_volatility': 0.44060641455786104,
'alpha': -0.30655613599662984,
'annual_algo_return': -0.30644659027763277,
'annual_bm_return': 0.0003786869525803649,
'*g_excess_return': -0.0012277104878824253,
'*g_position_days': 100.0,
'*g_trade_return': -0.014509073186182733,
'benchmark_return': 0.000305967935811724,
'benchmark_volatility': 0.27131966491397386,
'beta': 1.0067928398349948,
'day_win_ratio': 0.45544554455445546,
'excess_return': -0.25619394680273944,
'excess_return_max_drawdown': 0.34103151813973,
'excess_return_max_drawdown_period': ['2015-10-08', '2016-01-08'],
'excess_return_sharpe': -1.00318519931828,
'information': -0.8875067382972899,
'lose_count': 5,
'max_drawdown': 0.40710094664061747,
'max_drawdown_period': ['2015-11-25', '2016-02-29'],
'max_leverage': 0.0,
'period_label': '2016-07',
'profit_loss_ratio': 0.5428085647999734,
'sharpe': -0.7862949308744958,
'sortino': -0.9160242244092318,
'trading_days': 202,
'treasury_return': 0.03232876712328767,
'turnover_rate': 0.04857168229979232,
'win_count': 5,
'win_ratio': 0.5}.dataframe tbody tr th:only-of-type { vertical-align: middle; } .dataframe tbody tr th { vertical-align: top; } .dataframe thead th { text-align: right; }
| one_month | three_month | six_month | twelve_month | |
|---|---|---|---|---|
| 2015-10 | 0.100515 | NaN | NaN | NaN |
| 2015-11 | 0.099841 | NaN | NaN | NaN |
| 2015-12 | -0.066961 | 0.129342 | NaN | NaN |
| 2016-01 | -0.237805 | -0.217839 | NaN | NaN |
| 2016-02 | 0.029845 | -0.267618 | NaN | NaN |
| 2016-03 | 0.069431 | -0.160558 | -0.051982 | NaN |
| 2016-04 | -0.116652 | -0.027126 | -0.239056 | NaN |
| 2016-05 | 0.036085 | -0.021231 | -0.283167 | NaN |
| 2016-06 | -0.074497 | -0.152957 | -0.288957 | NaN |
| 2016-07 | -0.047405 | -0.086557 | -0.111335 | NaN |




