From c9dd99a4b53a4fc2b59d66a93c3fb1f20414e8fc Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 4 Jan 2024 16:03:53 +0100 Subject: [PATCH] Enhance test to properly capture correct downloading of different futures types --- freqtrade/data/history/history_utils.py | 5 +++-- tests/data/test_history.py | 6 +++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/freqtrade/data/history/history_utils.py b/freqtrade/data/history/history_utils.py index d3a33e747..b4a21e1d0 100644 --- a/freqtrade/data/history/history_utils.py +++ b/freqtrade/data/history/history_utils.py @@ -317,12 +317,13 @@ def refresh_backtest_ohlcv_data(exchange: Exchange, pairs: List[str], timeframes # All exchanges need FundingRate for futures trading. # The timeframe is aligned to the mark-price timeframe. combs = ((CandleType.FUNDING_RATE, tf_funding_rate), (fr_candle_type, tf_mark)) - for funding_candle_type, tf in combs: + for candle_type_f, tf in combs: + logger.debug(f'Downloading pair {pair}, {candle_type_f}, interval {tf}.') _download_pair_history(pair=pair, process=process, datadir=datadir, exchange=exchange, timerange=timerange, data_handler=data_handler, timeframe=str(tf), new_pairs_days=new_pairs_days, - candle_type=funding_candle_type, + candle_type=candle_type_f, erase=erase, prepend=prepend) return pairs_not_available diff --git a/tests/data/test_history.py b/tests/data/test_history.py index 100916387..a48d34aee 100644 --- a/tests/data/test_history.py +++ b/tests/data/test_history.py @@ -508,8 +508,9 @@ def test_refresh_backtest_ohlcv_data( mocker.patch.object(Path, "exists", MagicMock(return_value=True)) mocker.patch.object(Path, "unlink", MagicMock()) + default_conf['trading_mode'] = trademode - ex = get_patched_exchange(mocker, default_conf) + ex = get_patched_exchange(mocker, default_conf, id='bybit') timerange = TimeRange.parse_timerange("20190101-20190102") refresh_backtest_ohlcv_data(exchange=ex, pairs=["ETH/BTC", "XRP/BTC"], timeframes=["1m", "5m"], datadir=testdatadir, @@ -521,6 +522,9 @@ def test_refresh_backtest_ohlcv_data( assert dl_mock.call_args[1]['timerange'].starttype == 'date' assert log_has_re(r"Downloading pair ETH/BTC, .* interval 1m\.", caplog) + if trademode == 'futures': + assert log_has_re(r"Downloading pair ETH/BTC, funding_rate, interval 8h\.", caplog) + assert log_has_re(r"Downloading pair ETH/BTC, mark, interval 4h\.", caplog) def test_download_data_no_markets(mocker, default_conf, caplog, testdatadir):