From 6b99033164318f3ac848321d775234838b994a09 Mon Sep 17 00:00:00 2001 From: Matthias Date: Thu, 4 Jul 2024 15:21:16 +0200 Subject: [PATCH] Improve trades-cached handling --- freqtrade/exchange/exchange.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/freqtrade/exchange/exchange.py b/freqtrade/exchange/exchange.py index a407884b0..9d1825397 100644 --- a/freqtrade/exchange/exchange.py +++ b/freqtrade/exchange/exchange.py @@ -2703,7 +2703,11 @@ class Exchange: ) if not all_stored_ticks_df.empty: - if all_stored_ticks_df.iloc[0]["timestamp"] <= first_candle_ms: + if ( + all_stored_ticks_df.iloc[-1]["timestamp"] > first_candle_ms + and all_stored_ticks_df.iloc[0]["timestamp"] <= first_candle_ms + ): + # Use cache and populate further last_cached_ms = all_stored_ticks_df.iloc[-1]["timestamp"] from_id = all_stored_ticks_df.iloc[-1]["id"] # only use cached if it's closer than first_candle_ms @@ -2712,8 +2716,8 @@ class Exchange: if last_cached_ms > first_candle_ms else first_candle_ms ) - # doesn't go far enough else: + # Skip cache, it's too old all_stored_ticks_df = DataFrame( columns=DEFAULT_TRADES_COLUMNS + ["date"] )