feat: add error in case of non-available informative dataframe
This commit is contained in:
@@ -133,6 +133,11 @@ def _create_and_merge_informative_pair(
|
|||||||
|
|
||||||
inf_metadata = {"pair": asset, "timeframe": timeframe}
|
inf_metadata = {"pair": asset, "timeframe": timeframe}
|
||||||
inf_dataframe = strategy.dp.get_pair_dataframe(asset, timeframe, candle_type)
|
inf_dataframe = strategy.dp.get_pair_dataframe(asset, timeframe, candle_type)
|
||||||
|
if inf_dataframe.empty:
|
||||||
|
raise ValueError(
|
||||||
|
f"Informative dataframe for ({asset}, {timeframe}, {candle_type}) is empty. "
|
||||||
|
"Can't populate informative indicators."
|
||||||
|
)
|
||||||
inf_dataframe = populate_indicators_fn(strategy, inf_dataframe, inf_metadata)
|
inf_dataframe = populate_indicators_fn(strategy, inf_dataframe, inf_metadata)
|
||||||
|
|
||||||
formatter: Any = None
|
formatter: Any = None
|
||||||
|
|||||||
@@ -380,9 +380,10 @@ def test_informative_decorator(mocker, default_conf_usdt, trading_mode):
|
|||||||
assert inf_pair in strategy.gather_informative_pairs()
|
assert inf_pair in strategy.gather_informative_pairs()
|
||||||
|
|
||||||
def test_historic_ohlcv(pair, timeframe, candle_type):
|
def test_historic_ohlcv(pair, timeframe, candle_type):
|
||||||
return data[
|
return data.get(
|
||||||
(pair, timeframe or strategy.timeframe, CandleType.from_string(candle_type))
|
(pair, timeframe or strategy.timeframe, CandleType.from_string(candle_type)),
|
||||||
].copy()
|
pd.DataFrame(),
|
||||||
|
).copy()
|
||||||
|
|
||||||
mocker.patch(
|
mocker.patch(
|
||||||
"freqtrade.data.dataprovider.DataProvider.historic_ohlcv", side_effect=test_historic_ohlcv
|
"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 _, dataframe in analyzed.items():
|
||||||
for col in expected_columns:
|
for col in expected_columns:
|
||||||
assert col in dataframe.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")}
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user