From f742d21690fd4e5e5eb4de0337d60501d0d81b97 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 2 Apr 2022 16:12:19 +0200 Subject: [PATCH] Add test showing #6629 --- tests/optimize/test_backtesting.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/optimize/test_backtesting.py b/tests/optimize/test_backtesting.py index 736071af9..cc5cf9e43 100644 --- a/tests/optimize/test_backtesting.py +++ b/tests/optimize/test_backtesting.py @@ -832,6 +832,36 @@ def test_backtest_1min_timeframe(default_conf, fee, mocker, testdatadir) -> None assert len(results['results']) == 1 +def test_backtest_trim_no_data_left(default_conf, fee, mocker, testdatadir) -> None: + default_conf['use_sell_signal'] = False + mocker.patch('freqtrade.exchange.Exchange.get_fee', fee) + mocker.patch("freqtrade.exchange.Exchange.get_min_pair_stake_amount", return_value=0.00001) + mocker.patch("freqtrade.exchange.Exchange.get_max_pair_stake_amount", return_value=float('inf')) + patch_exchange(mocker) + backtesting = Backtesting(default_conf) + backtesting._set_strategy(backtesting.strategylist[0]) + timerange = TimeRange('date', None, 1517227800, 0) + backtesting.required_startup = 100 + backtesting.timerange = timerange + data = history.load_data(datadir=testdatadir, timeframe='5m', pairs=['UNITTEST/BTC'], + timerange=timerange) + df = data['UNITTEST/BTC'] + df.loc[:, 'date'] = df.loc[:, 'date'] - timedelta(days=1) + # Trimming 100 candles, so after 2nd trimming, no candle is left. + df = df.iloc[:100] + data['XRP/USDT'] = df + processed = backtesting.strategy.advise_all_indicators(data) + min_date, max_date = get_timerange(processed) + + backtesting.backtest( + processed=deepcopy(processed), + start_date=min_date, + end_date=max_date, + max_open_trades=10, + position_stacking=False, + ) + + def test_processed(default_conf, mocker, testdatadir) -> None: patch_exchange(mocker) backtesting = Backtesting(default_conf)