feat: add error in case of non-available informative dataframe

This commit is contained in:
Matthias
2025-09-06 09:38:23 +02:00
parent 246891a8f6
commit 816ca2ea15
2 changed files with 18 additions and 3 deletions

View File

@@ -380,9 +380,10 @@ def test_informative_decorator(mocker, default_conf_usdt, trading_mode):
assert inf_pair in strategy.gather_informative_pairs()
def test_historic_ohlcv(pair, timeframe, candle_type):
return data[
(pair, timeframe or strategy.timeframe, CandleType.from_string(candle_type))
].copy()
return data.get(
(pair, timeframe or strategy.timeframe, CandleType.from_string(candle_type)),
pd.DataFrame(),
).copy()
mocker.patch(
"freqtrade.data.dataprovider.DataProvider.historic_ohlcv", side_effect=test_historic_ohlcv
@@ -405,3 +406,12 @@ def test_informative_decorator(mocker, default_conf_usdt, trading_mode):
for _, dataframe in analyzed.items():
for col in expected_columns:
assert col in dataframe.columns
# Test non-available pairs
del data[("ETH/BTC", "1h", CandleType.SPOT)]
with pytest.raises(
ValueError, match=r"Informative dataframe for \(ETH\/BTC, 1h, spot\) is empty.*"
):
strategy.advise_all_indicators(
{p: data[(p, strategy.timeframe, candle_def)] for p in ("XRP/USDT", "LTC/USDT")}
)