本文整理汇总了Python中mewp.util.pair_trade_analysis.TradeAnalysis.order_winning_ratio方法的典型用法代码示例。如果您正苦于以下问题:Python TradeAnalysis.order_winning_ratio方法的具体用法?Python TradeAnalysis.order_winning_ratio怎么用?Python TradeAnalysis.order_winning_ratio使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mewp.util.pair_trade_analysis.TradeAnalysis
的用法示例。
在下文中一共展示了TradeAnalysis.order_winning_ratio方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: back_test
# 需要导入模块: from mewp.util.pair_trade_analysis import TradeAnalysis [as 别名]
# 或者: from mewp.util.pair_trade_analysis.TradeAnalysis import order_winning_ratio [as 别名]
def back_test(pair, date, param):
tracker = TradeAnalysis(Contract(pair[0]))
algo = { 'class': ConstantAlgo }
algo['param'] = {'x': pair[0],
'y': pair[1],
'a': 1,
'b': 0,
'rolling': param[0],
'bollinger': param[1],
'const': param[2],
'block': 100,
'tracker': tracker
}
settings = { 'date': date,
'path': DATA_PATH,
'tickset': 'top',
'algo': algo,
'singletick': True}
runner = PairRunner(settings)
runner.run()
account = runner.account
history = account.history.to_dataframe(account.items)
score = float(history[['pnl']].iloc[-1])
order_win = tracker.order_winning_ratio()
order_profit = tracker.analyze_all_profit()[0]
num_rounds = tracker.analyze_all_profit()[2]
return score, order_win, order_profit, num_rounds, runner
示例2: back_test
# 需要导入模块: from mewp.util.pair_trade_analysis import TradeAnalysis [as 别名]
# 或者: from mewp.util.pair_trade_analysis.TradeAnalysis import order_winning_ratio [as 别名]
def back_test(pair, date, param):
tracker = TradeAnalysis(Contract(pair[0]))
algo = {"class": OUAlgo}
algo["param"] = {
"x": pair[0],
"y": pair[1],
"a": 1,
"b": 0,
"rolling": param[0],
"bollinger": param[1],
"block": 100,
"tracker": tracker,
}
settings = {"date": date, "path": DATA_PATH, "tickset": "top", "algo": algo, "singletick": True}
runner = PairRunner(settings)
runner.run()
account = runner.account
history = account.history.to_dataframe(account.items)
score = float(history[["pnl"]].iloc[-1])
order_win = tracker.order_winning_ratio()
order_profit = tracker.analyze_all_profit()[0]
num_rounds = tracker.analyze_all_profit()[2]
return score, order_win, order_profit, num_rounds