From 423b25146737abb1ae37aa1c6fab9499f64ec2ca Mon Sep 17 00:00:00 2001 From: kryofly Date: Wed, 17 Jan 2018 18:19:39 +0100 Subject: [PATCH] tests: speed up backtests --- freqtrade/tests/optimize/test_backtesting.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/freqtrade/tests/optimize/test_backtesting.py b/freqtrade/tests/optimize/test_backtesting.py index 5f899a48a..4ef4b1606 100644 --- a/freqtrade/tests/optimize/test_backtesting.py +++ b/freqtrade/tests/optimize/test_backtesting.py @@ -11,6 +11,13 @@ from freqtrade.optimize.backtesting import backtest, generate_text_table, get_ti import freqtrade.optimize.backtesting as backtesting +def trim_dictlist(dl, num): + new = {} + for pair, pair_data in dl.items(): + new[pair] = pair_data[num:] + return new + + def test_generate_text_table(): results = pd.DataFrame( { @@ -43,6 +50,7 @@ def test_backtest(default_conf, mocker): exchange._API = Bittrex({'key': '', 'secret': ''}) data = optimize.load_data(None, ticker_interval=5, pairs=['BTC_ETH']) + data = trim_dictlist(data, -200) results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 10, True) assert not results.empty @@ -54,18 +62,12 @@ def test_backtest_1min_ticker_interval(default_conf, mocker): # Run a backtesting for an exiting 5min ticker_interval data = optimize.load_data(None, ticker_interval=1, pairs=['BTC_UNITEST']) + data = trim_dictlist(data, -200) results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 1, True) assert not results.empty -def trim_dictlist(dl, num): - new = {} - for pair, pair_data in dl.items(): - new[pair] = pair_data[num:] - return new - - def load_data_test(what): data = optimize.load_data(None, ticker_interval=1, pairs=['BTC_UNITEST']) data = trim_dictlist(data, -100) @@ -125,6 +127,7 @@ def simple_backtest(config, contour, num_results): def test_backtest2(default_conf, mocker): mocker.patch.dict('freqtrade.main._CONF', default_conf) data = optimize.load_data(None, ticker_interval=5, pairs=['BTC_ETH']) + data = trim_dictlist(data, -200) results = backtest(default_conf['stake_amount'], optimize.preprocess(data), 10, True) assert not results.empty