本文整理汇总了Python中mewp.simulate.report.Report类的典型用法代码示例。如果您正苦于以下问题:Python Report类的具体用法?Python Report怎么用?Python Report使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Report类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: run_simulation
def run_simulation(param, date_list):
algo = { 'class': ConstStopWinGuardAlgo }
algo['param'] = {'x': 'ni1609',
'y': 'ni1701',
'a': 1,
'b': 0,
'rolling': param[0],
'bollinger': 2,
'const': param[1],
'stop_win':param[2],
'block': 100,
'tracker': None
}
settings = { 'date': date_list,
'path': DATA_PATH,
'tickset': 'top',
'algo': algo,
'singletick': False}
settings['exe'] = PairExePlusTick(2)
runner = PairRunner(settings)
runner.run()
report = Report(runner)
temp = report.get_daily_pnl()
pnl_list = list(temp.daily_pnl)
return pnl_list
开发者ID:volpato30,项目名称:Backtest,代码行数:25,代码来源:stopwin_slipery.py
示例2: run_simulation
def run_simulation(params):
date = '2015-01-01'
dateend = '2015-05-01'
ma_diff = []
dates = [str(x).split(' ')[0] for x in pd.date_range(date, dateend).tolist()]
algo = { 'class': MyMM }
temp = {'item': 'au1506'}
temp['ma_diff_length'] = params[0]
temp['trigger_diff'] = params[1]
temp['ma_window'] = params[2]
temp['spread'] = params[3]
temp['inv_coef'] = params[4]
temp['chunk'] = params[5]
temp['gap'] = params[6]
algo['param'] = temp
settings = { 'date': dates, 'algo': algo, 'tickset': 'top', 'verbose' : True,
'path': DATA_PATH }
runner = SingleRunner(settings)
runner.run()
report = Report(runner)
pnl = report.get_final_pnl()
sharp_ratio = report.get_sharpie_ratio()
del runner._algo.volatility_finder
del runner._algo
runner.close()
del runner._me
del runner._price_table
del runner
return pnl, sharp_ratio
开发者ID:volpato30,项目名称:Backtest,代码行数:29,代码来源:grid_search_mm.py
示例3: run_simulation
def run_simulation(param, date_list, if_param):
order_win_list = []
daily_num_order = []
order_waiting_list = []
order_profit_list = []
master = MasterReport()
for date in date_list:
date_pair = get_best_pair(date, market, "cu")
if type(date_pair) != tuple:
continue
else:
runner = back_test(date_pair, date, param, if_param)
try:
report = Report(runner)
except IndexError:
print "WTF? {} has IndexError".format(date)
continue
report.print_report(to_file=False, to_screen=False, to_master=master)
order_win_list.append(runner._algo.tracker.order_winning_ratio())
temp = runner._algo.tracker.analyze_all_waiting()
order_waiting_list.append(temp[0])
daily_num_order.append(temp[2])
order_profit_list.append(runner._algo.tracker.analyze_all_profit()[0])
[overall, days] = master.print_report(to_file=False, print_days=True)
final_pnl = float(overall.final_pnl)
final_return = float(overall.final_return)
sharpe_ratio = float(overall.sharpe_ratio)
win_ratio = float(overall.win_ratio)
daily_draw_down = np.asarray(days.max_draw_down)
max_draw_down = daily_draw_down.max()
avg_draw_down = daily_draw_down.mean()
num_orders = sum(days.order_count)
order_win_list = np.asarray(order_win_list)
order_profit_list = np.asarray(order_profit_list)
order_waiting_list = np.asarray(order_waiting_list)
daily_num_order = np.asarray(daily_num_order)
if daily_num_order.sum() < 1:
order_win = -1
order_waiting = -1
order_profit = -1
else:
order_win = sum(order_win_list * daily_num_order / daily_num_order.sum())
order_waiting = sum(order_waiting_list * daily_num_order / daily_num_order.sum())
order_profit = sum(order_profit_list * daily_num_order / daily_num_order.sum())
return (
final_pnl,
final_return,
sharpe_ratio,
win_ratio,
max_draw_down,
avg_draw_down,
num_orders,
order_win,
order_waiting,
order_profit,
)
开发者ID:Coderx7,项目名称:CNN,代码行数:57,代码来源:cu.py
示例4: run_simulation
def run_simulation(param, date_list, product):
order_win_list = []
daily_num_order = []
order_waiting_list = []
order_profit_list = []
master = MasterReport()
tracker = get_tracker(date_list, product)
for date in date_list:
date_pair = get_best_pair(date, market, product)
if type(date_pair) != tuple:
continue
else:
runner, _ = back_test(date_pair, date, param, tracker)
try:
report = Report(runner)
except IndexError:
print 'WTF? {} has IndexError'.format(date)
continue
report.print_report(to_file=False, to_screen=False, to_master=master)
try:
[overall, days] = master.print_report(to_file=False, print_days=False)
except TypeError as inst:
if inst.args[0] == "'NoneType' object has no attribute '__getitem__'":
return ('NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA')
else:
raise Exception("god knows what happens")
#pnls
final_pnl = float(overall.final_pnl)
final_return = float(overall.final_return)
sharpe_ratio = float(overall.sharpe_ratio)
win_ratio = float(overall.win_ratio)
#max draw down
daily_draw_down = np.asarray(days.max_draw_down)
max_draw_down = daily_draw_down.max()
avg_draw_down = daily_draw_down.mean()
#num orders
num_orders = sum(days.order_count)
#order analysis
order_win = tracker.order_winning_ratio()
order_waiting = tracker.analyze_all_waiting()[0]
order_waiting_median = tracker.analyze_all_waiting()[3]
order_profit = tracker.analyze_all_profit()[0]
order_profit_median = tracker.analyze_all_profit()[3]
num_rounds = tracker.analyze_all_profit()[2]
return final_pnl, final_return, sharpe_ratio, win_ratio, max_draw_down,\
avg_draw_down, num_orders, num_rounds, order_win, order_waiting, order_waiting_median, \
order_profit, order_profit_median
开发者ID:Coderx7,项目名称:CNN,代码行数:55,代码来源:al.py
示例5: run_simulation
def run_simulation(param, date_list, product):
order_win_list = []
daily_num_order = []
order_waiting_list = []
order_profit_list = []
master = MasterReport()
for date in date_list:
date_pair = get_best_pair(date,market, product)
if type(date_pair) != tuple:
continue
else:
runner = back_test(date_pair, date, param)
try:
report = Report(runner)
except IndexError:
print 'WTF? {} has IndexError'.format(date)
continue
report.print_report(to_file=False, to_screen=False, to_master=master)
order_win_list.append(runner._algo.tracker.order_winning_ratio())
temp = runner._algo.tracker.analyze_all_waiting()
order_waiting_list.append(temp[0])
daily_num_order.append(temp[2])
order_profit_list.append(runner._algo.tracker.analyze_all_profit()[0])
try:
[overall, days] = master.print_report(to_file=False, print_days=False)
except TypeError as inst:
if inst.args[0] == "'NoneType' object has no attribute '__getitem__'":
return ('NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA', 'NA')
else:
raise Exception("god knows what happens")
final_pnl = float(overall.final_pnl)
final_return = float(overall.final_return)
sharpe_ratio = float(overall.sharpe_ratio)
win_ratio = float(overall.win_ratio)
daily_draw_down = np.asarray(days.max_draw_down)
max_draw_down = daily_draw_down.max()
avg_draw_down = daily_draw_down.mean()
num_orders = sum(days.order_count)
order_win_list = np.asarray(order_win_list)
order_profit_list = np.asarray(order_profit_list)
order_waiting_list = np.asarray(order_waiting_list)
daily_num_order= np.asarray(daily_num_order)
if daily_num_order.sum() < 1:
order_win = -1
order_waiting = -1
order_profit = -1
else:
order_win = sum(order_win_list * daily_num_order/daily_num_order.sum())
order_waiting = sum(order_waiting_list * daily_num_order/daily_num_order.sum())
order_profit = sum(order_profit_list * daily_num_order/daily_num_order.sum())
return final_pnl, final_return, sharpe_ratio, win_ratio, max_draw_down,\
avg_draw_down, num_orders, order_win, order_waiting, order_profit
开发者ID:Coderx7,项目名称:CNN,代码行数:53,代码来源:czce.py
示例6: run_simulation
def run_simulation(param, date_list, product):
pnl_list = []
order_win_list = []
order_profit_list = []
num_rounds_list = []
master = MasterReport()
for date in date_list:
date_pair = get_best_pair(date,market, product)
if type(date_pair) != tuple:
continue
else:
result = back_test(date_pair, date, param)
pnl_list.append(result[0])
order_win_list.append(result[1])
order_profit_list.append(result[2])
num_rounds_list.append(result[3])
runner = result[4]
try:
report = Report(runner)
except IndexError:
print 'WTF? {} has IndexError'.format(date)
continue
report.print_report(to_file=False, to_screen=False, to_master=master)
return pnl_list, order_win_list, order_profit_list, num_rounds_list, master
开发者ID:Coderx7,项目名称:CNN,代码行数:24,代码来源:pb.py
示例7: run_simulation
def run_simulation(p):
runner.run(algo_param={'rolling': p[0], 'bollinger': p[1], 'stop_win': p[2]})
report = Report(runner)
runner._algo.tracker.order_winning_ratio()
pnl = float(report.get_final_pnl())
final_return = float(report.get_final_return())
sharpe_ratio = float(report.get_sharpie_ratio())
avg_draw_down = float(report.get_avg_max_draw_down())
max_draw_down = float(report.get_max_max_draw_down()[0])
order_winning_ratio = float(runner._algo.tracker.order_winning_ratio())
waiting_time = float(runner._algo.tracker.analyze_all_waiting()[0])
avg_profit = float(runner._algo.tracker.analyze_all_profit()[0])
num_orders = int(runner._algo.tracker.analyze_all_profit()[2])
return pnl, final_return, sharpe_ratio, avg_draw_down, max_draw_down, \
order_winning_ratio, waiting_time, avg_profit, num_orders
开发者ID:Coderx7,项目名称:CNN,代码行数:16,代码来源:trailing_stopwin.py
注:本文中的mewp.simulate.report.Report类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论