|
11 | 11 | from freqtrade.enums.candletype import CandleType |
12 | 12 | from freqtrade.exchange.exchange import timeframe_to_seconds |
13 | 13 | from freqtrade.exchange.exchange_types import OHLCVResponse |
14 | | -from freqtrade.util import dt_ts, format_ms_time |
| 14 | +from freqtrade.util import dt_ts, format_ms_time, format_ms_time_det |
15 | 15 |
|
16 | 16 |
|
17 | 17 | logger = logging.getLogger(__name__) |
@@ -180,15 +180,18 @@ async def get_ohlcv( |
180 | 180 | # Deepcopy the response - as it might be modified in the background as new messages arrive |
181 | 181 | candles = deepcopy(self.ccxt_object.ohlcvs.get(pair, {}).get(timeframe)) |
182 | 182 | refresh_date = self.klines_last_refresh[(pair, timeframe, candle_type)] |
183 | | - drop_hint = False |
184 | | - if refresh_date > candle_ts: |
185 | | - # Refreshed after candle was complete. |
186 | | - # logger.info(f"{candles[-1][0]} >= {candle_date}") |
187 | | - drop_hint = candles[-1][0] >= candle_ts |
| 183 | + received_ts = candles[-1][0] if candles else 0 |
| 184 | + drop_hint = received_ts >= candle_ts |
| 185 | + if received_ts > refresh_date: |
| 186 | + logger.warning( |
| 187 | + f"{pair}, {timeframe} - Candle date > last refresh " |
| 188 | + f"({format_ms_time(received_ts)} > {format_ms_time_det(refresh_date)}). " |
| 189 | + "This usually suggests a problem with time synchronization." |
| 190 | + ) |
188 | 191 | logger.debug( |
189 | 192 | f"watch result for {pair}, {timeframe} with length {len(candles)}, " |
190 | | - f"{format_ms_time(candles[-1][0])}, " |
191 | | - f"lref={format_ms_time(refresh_date)}, " |
| 193 | + f"r_ts={format_ms_time(received_ts)}, " |
| 194 | + f"lref={format_ms_time_det(refresh_date)}, " |
192 | 195 | f"candle_ts={format_ms_time(candle_ts)}, {drop_hint=}" |
193 | 196 | ) |
194 | 197 | return pair, timeframe, candle_type, candles, drop_hint |
0 commit comments