Ejemplo n.º 1
0
    'a': 1,
    'b': 0,
    'rolling': 4000,
    'sd_coef': 3,
    'block': 100,
    'stop_win': 200,
}
settings = {
    'date': date_list,
    'path': DATA_PATH,
    'tickset': 'top',
    'algo': algo
}

runner = PairRunner(settings)
price_diff = get_price_diff(pair)
price_diff_std = np.nanstd(price_diff)
rolling_list = range(1000, 10000, 2000)
sd_coef_list = np.arange(2, 8)
stop_win_list = price_diff_std * np.arange(0.5, 3.5, 0.5)
final_profit = []
for r in rolling_list:
    for sd in sd_coef_list:
        for sw in stop_win_list:
            start_time = time.time()
            runner.run(algo_param={
                'rolling': r,
                'sd_coef': sd,
                'stop_win': sw
            })
            account = runner.account
Ejemplo n.º 2
0
algo['param'] = {'x': pair[0],
                 'y': pair[1],
                 'a': 1,
                 'b': 0,
                 'rolling': 4000,
                 'sd_coef': 3,
                 'block': 100,
                 'stop_win': 200,
                 }
settings = { 'date': date_list,
             'path': DATA_PATH,
             'tickset': 'top',
             'algo': algo}

runner = PairRunner(settings)
price_diff = get_price_diff(pair)
price_diff_std = np.nanstd(price_diff)
rolling_list = range(1000,10000,2000)
sd_coef_list = np.arange(2,8)
stop_win_list = price_diff_std * np.arange(0.5, 3.5, 0.5)
final_profit = []
for r in rolling_list :
    for sd in sd_coef_list :
        for sw in stop_win_list:
            start_time = time.time()
            runner.run(algo_param={'rolling': r,  'sd_coef': sd, 'stop_win': sw })
            account = runner.account
            history = account.history.to_dataframe(account.items)
            score = float(history[['pnl']].iloc[-1])
            final_profit.append(score)
            print("rolling {}, sd_coef {}, stop_win {}, backtest took {:.3f}s, score is {:.3f}".format(r, sd, sw, time.time() - start_time, score))