Enhance test to properly capture correct downloading of different futures types

This commit is contained in:
Matthias
2024-01-04 16:03:53 +01:00
parent 67d3dca49c
commit c9dd99a4b5
2 changed files with 8 additions and 3 deletions

View File

@@ -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

View File

@@ -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):