fix: catch error when getting the last candle fails

It's unknown when this actually happens - but this should be the safer bet than crashing completely.

closes #11213
This commit is contained in:
Matthias
2025-01-09 18:21:51 +01:00
parent 092a9ff5db
commit 75fb2a0c86

View File

@@ -1160,8 +1160,12 @@ class IStrategy(ABC, HyperStrategyMixin):
logger.warning(f"Empty candle (OHLCV) data for pair {pair}")
return None, None
latest_date_pd = dataframe["date"].max()
latest = dataframe.loc[dataframe["date"] == latest_date_pd].iloc[-1]
try:
latest_date_pd = dataframe["date"].max()
latest = dataframe.loc[dataframe["date"] == latest_date_pd].iloc[-1]
except Exception as e:
logger.warning(f"Unable to get latest candle (OHLCV) data for pair {pair} - {e}")
return None, None
# Explicitly convert to datetime object to ensure the below comparison does not fail
latest_date: datetime = latest_date_pd.to_pydatetime()