当前位置: 首页>>代码示例>>Python>>正文


Python TradeAnalysis.order_winning_ratio方法代码示例

本文整理汇总了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
开发者ID:Coderx7,项目名称:CNN,代码行数:29,代码来源:pb.py

示例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
开发者ID:Coderx7,项目名称:CNN,代码行数:25,代码来源:au_OU.py


注:本文中的mewp.util.pair_trade_analysis.TradeAnalysis.order_winning_ratio方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。