chore: improve variable naming

This commit is contained in:
Matthias
2025-01-05 09:55:17 +01:00
parent f6bf6c52c5
commit 2fe9ceab8d

View File

@@ -2394,28 +2394,28 @@ class Exchange:
min_date = int(date_minus_candles(timeframe, candle_limit - 5).timestamp()) min_date = int(date_minus_candles(timeframe, candle_limit - 5).timestamp())
if self._exchange_ws: if self._exchange_ws:
candle_date = dt_ts(timeframe_to_prev_date(timeframe)) candle_ts = dt_ts(timeframe_to_prev_date(timeframe))
prev_candle_date = dt_ts(date_minus_candles(timeframe, 1)) prev_candle_ts = dt_ts(date_minus_candles(timeframe, 1))
candles = self._exchange_ws.ccxt_object.ohlcvs.get(pair, {}).get(timeframe) candles = self._exchange_ws.ccxt_object.ohlcvs.get(pair, {}).get(timeframe)
half_candle = int(candle_date - (candle_date - prev_candle_date) * 0.5) half_candle = int(candle_ts - (candle_ts - prev_candle_ts) * 0.5)
last_refresh_time = int( last_refresh_time = int(
self._exchange_ws.klines_last_refresh.get((pair, timeframe, candle_type), 0) self._exchange_ws.klines_last_refresh.get((pair, timeframe, candle_type), 0)
) )
if ( if (
candles candles
and candles[-1][0] >= prev_candle_date and candles[-1][0] >= prev_candle_ts
and last_refresh_time >= half_candle and last_refresh_time >= half_candle
): ):
# Usable result, candle contains the previous candle. # Usable result, candle contains the previous candle.
# Also, we check if the last refresh time is no more than half the candle ago. # Also, we check if the last refresh time is no more than half the candle ago.
logger.debug(f"reuse watch result for {pair}, {timeframe}, {last_refresh_time}") logger.debug(f"reuse watch result for {pair}, {timeframe}, {last_refresh_time}")
return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type, candle_date) return self._exchange_ws.get_ohlcv(pair, timeframe, candle_type, candle_ts)
logger.info( logger.info(
f"Failed to reuse watch {pair}, {timeframe}, {candle_date < last_refresh_time}," f"Failed to reuse watch {pair}, {timeframe}, {candle_ts < last_refresh_time},"
f" {candle_date}, {last_refresh_time}, " f" {candle_ts}, {last_refresh_time}, "
f"{format_ms_time(candle_date)}, {format_ms_time(last_refresh_time)} " f"{format_ms_time(candle_ts)}, {format_ms_time(last_refresh_time)} "
) )
# Check if 1 call can get us updated candles without hole in the data. # Check if 1 call can get us updated candles without hole in the data.