refactor backtesting to avoid recalculating indicators in hyperopt

This commit is contained in:
Janne Sinivirta
2017-11-15 20:06:37 +02:00
parent 1ccb266032
commit 1b6a60ecb2
2 changed files with 19 additions and 10 deletions

View File

@@ -9,7 +9,7 @@ import pytest
from hyperopt import fmin, tpe, hp, Trials, STATUS_OK
from pandas import DataFrame
from freqtrade.tests.test_backtesting import backtest, format_results
from freqtrade.tests.test_backtesting import backtest, format_results, preprocess
from freqtrade.vendor.qtpylib.indicators import crossed_above
logging.disable(logging.DEBUG) # disable debug logs that slow backtesting a lot
@@ -67,12 +67,13 @@ def buy_strategy_generator(params):
@pytest.mark.skipif(not os.environ.get('BACKTEST', False), reason="BACKTEST not set")
def test_hyperopt(backtest_conf, backdata, mocker):
mocked_buy_trend = mocker.patch('freqtrade.analyze.populate_buy_trend')
mocked_buy_trend = mocker.patch('freqtrade.tests.test_backtesting.populate_buy_trend')
processed = preprocess(backdata)
def optimizer(params):
mocked_buy_trend.side_effect = buy_strategy_generator(params)
results = backtest(backtest_conf, backdata, mocker)
results = backtest(backtest_conf, processed, mocker)
result = format_results(results)