This commit is contained in:
Dobromir Popov
2025-08-26 18:11:34 +03:00
parent f86457fc38
commit c39b70f6fa
4 changed files with 97 additions and 7 deletions

View File

@@ -1312,13 +1312,19 @@ class DataProvider:
# For 1s timeframe, try to generate from WebSocket ticks first
if timeframe == '1s':
# logger.info(f"Attempting to generate 1s candles from WebSocket ticks for {symbol}")
generated_df = self._generate_1s_candles_from_ticks(symbol, limit)
# Attempt to generate from WebSocket ticks, but throttle attempts to avoid spam
if not hasattr(self, '_last_1s_generation_attempt'):
self._last_1s_generation_attempt = {}
now_ts = time.time()
last_attempt = self._last_1s_generation_attempt.get(symbol, 0)
generated_df = None
if now_ts - last_attempt >= 1.5:
self._last_1s_generation_attempt[symbol] = now_ts
generated_df = self._generate_1s_candles_from_ticks(symbol, limit)
if generated_df is not None and not generated_df.empty:
# logger.info(f"Successfully generated 1s candles from WebSocket ticks for {symbol}")
return generated_df
else:
logger.info(f"Could not generate 1s candles from ticks for {symbol}; trying Binance API")
logger.debug(f"Could not generate 1s candles from ticks for {symbol}; trying Binance API")
# Convert symbol format
binance_symbol = symbol.replace('/', '').upper()