Skip to content

Commit 75fb2a0

Browse files
committed
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 freqtrade#11213
1 parent 092a9ff commit 75fb2a0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

freqtrade/strategy/interface.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,8 +1160,12 @@ def get_latest_candle(
11601160
logger.warning(f"Empty candle (OHLCV) data for pair {pair}")
11611161
return None, None
11621162

1163-
latest_date_pd = dataframe["date"].max()
1164-
latest = dataframe.loc[dataframe["date"] == latest_date_pd].iloc[-1]
1163+
try:
1164+
latest_date_pd = dataframe["date"].max()
1165+
latest = dataframe.loc[dataframe["date"] == latest_date_pd].iloc[-1]
1166+
except Exception as e:
1167+
logger.warning(f"Unable to get latest candle (OHLCV) data for pair {pair} - {e}")
1168+
return None, None
11651169
# Explicitly convert to datetime object to ensure the below comparison does not fail
11661170
latest_date: datetime = latest_date_pd.to_pydatetime()
11671171

0 commit comments

Comments
 (0)