Exemple #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
Exemple #2
0
def get_tracker(date_list, product):
    pair = 0
    for date in date_list:
        pair = get_best_pair(date,market, product)
        if type(pair) != tuple:
            continue
        else:
            break
    return TradeAnalysis(Contract(pair[0]))