def gen_config_file(filename):
sim_config = {}
sim_config['sim_class'] = 'bktest_dtchan_vecsim.DTChanSim'
sim_config['sim_func'] = 'run_vec_sim'
sim_config['scen_keys'] = ['param', 'chan']
sim_config['sim_name'] = 'DTChan_VecSim'
sim_config['products'] = ['m', 'RM', 'y', 'p', 'a', 'rb', 'SR', 'TA', 'MA', 'i', 'ru', 'j' ]
sim_config['start_date'] = '20150102'
sim_config['end_date'] = '20170428'
sim_config['param'] = [
(0.5, 0, 0.5, 0.0), (0.6, 0, 0.5, 0.0), (0.7, 0, 0.5, 0.0), (0.8, 0, 0.5, 0.0), \
(0.9, 0, 0.5, 0.0), (1.0, 0, 0.5, 0.0), (1.1, 0, 0.5, 0.0), \
(0.5, 1, 0.5, 0.0), (0.6, 1, 0.5, 0.0), (0.7, 1, 0.5, 0.0), (0.8, 1, 0.5, 0.0), \
(0.9, 1, 0.5, 0.0), (1.0, 1, 0.5, 0.0), (1.1, 1, 0.5, 0.0), \
(0.2, 2, 0.5, 0.0), (0.25,2, 0.5, 0.0), (0.3, 2, 0.5, 0.0), (0.35, 2, 0.5, 0.0),\
(0.4, 2, 0.5, 0.0), (0.45, 2, 0.5, 0.0),(0.5, 2, 0.5, 0.0), \
(0.2, 4, 0.5, 0.0), (0.25, 4, 0.5, 0.0),(0.3, 4, 0.5, 0.0), (0.35, 4, 0.5, 0.0),\
(0.4, 4, 0.5, 0.0), (0.45, 4, 0.5, 0.0),(0.5, 4, 0.5, 0.0),\
]
sim_config['chan'] = [3, 5, 10, 15, 20]
sim_config['pos_class'] = 'strat.TradePos'
sim_config['proc_func'] = 'dh.day_split'
sim_config['offset'] = 1
chan_func = {'high': {'func': 'pd.rolling_max', 'args':{}},
'low': {'func': 'pd.rolling_min', 'args':{}},
}
config = {'capital': 10000,
'use_chan': True,
'trans_cost': 0.0,
'close_daily': False,
'unit': 1,
'min_range': 0.0035,
'proc_args': {'minlist':[1500]},
'chan_func': chan_func,
}
sim_config['config'] = config
with open(filename, 'w') as outfile:
json.dump(sim_config, outfile)
return sim_config
评论列表
文章目录