コード例 #1
0
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
0
ファイル: pb.py プロジェクト: Coderx7/CNN
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
コード例 #3
0
ファイル: au_OU.py プロジェクト: Coderx7/CNN
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