fix: implement api resilience to handle data delays at open
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user