move testdata file loading to pytest fixture

This commit is contained in:
Janne Sinivirta
2017-11-07 19:24:51 +02:00
parent fbbde9de25
commit 0395c92260
3 changed files with 36 additions and 29 deletions

View File

@@ -63,13 +63,13 @@ def buy_strategy_generator(params):
@pytest.mark.skipif(not os.environ.get('BACKTEST', False), reason="BACKTEST not set")
def test_hyperopt(conf, pairs, mocker):
def test_hyperopt(conf, backdata, mocker):
mocked_buy_trend = mocker.patch('freqtrade.analyze.populate_buy_trend')
def optimizer(params):
mocked_buy_trend.side_effect = buy_strategy_generator(params)
results = backtest(conf, pairs, mocker)
results = backtest(conf, backdata, mocker)
result = format_results(results)
print(result)
@@ -129,7 +129,7 @@ def test_hyperopt(conf, pairs, mocker):
}
trials = Trials()
best = fmin(fn=optimizer, space=space, algo=tpe.suggest, max_evals=4, trials=trials)
print('\n\n\n\n====================== HYPEROPT BACKTESTING REPORT ================================')
print('\n\n\n\n==================== HYPEROPT BACKTESTING REPORT ==============================')
print('Best parameters {}'.format(best))
newlist = sorted(trials.results, key=itemgetter('loss'))
print('Result: {}'.format(newlist[0]['result']))