fix: implement api resilience to handle data delays at open

This commit is contained in:
pie
2026-04-28 18:52:36 +01:00
parent dc111abf8c
commit be4df42e01
2 changed files with 22 additions and 4 deletions
+13 -1
View File
@@ -74,7 +74,19 @@ def run_ticker_lifecycle(client, yf_ticker, t212_ticker, tz):
if now.hour == 9 and now.minute >= 45:
logger.info(f"Evaluating opening candle for {yf_ticker}...")
if strategy.check_setup():
# Retry loop: wait for yfinance to publish the 09:30-09:45 candle (up to 3 minutes)
setup_found = False
max_retries = 12
for attempt in range(max_retries):
if strategy.check_setup():
setup_found = True
break
elif attempt < max_retries - 1:
logger.debug(f"Data not ready for {yf_ticker} yet, waiting 15s...")
time.sleep(15)
if setup_found:
params = strategy.get_trade_params()
params['ticker'] = t212_ticker