fix: 4 cycle errors — NameError _log, WHEAT/EUR/USD ticker normalization, 429 serial scoring

- auto_cycle.py: replace _log with logger (NameError at lines 484/489)
- auto_cycle.py: normalize underlying via _normalize_ticker before _resolve_ticker
  so WHEAT→ZW=F→WEAT and EUR/USD→EURUSD=X→FXE reach the IV watchlist correctly
- iv_engine.py: _resolve_ticker now strips slash-format forex (EUR/USD→EURUSD=X)
  before _PROXY lookup, fixing yfinance 500/404 spam from get_atm_iv
- database.py: _fetch in log_trade_entries uses _normalize_ticker (not _normalize_yf_ticker)
  so commodity aliases like WHEAT→ZW=F are applied at price-fetch time
- ai_analyzer.py: max_workers=1 for batch scorer — parallel workers both slept and
  retried simultaneously after 429, causing repeated bursts; sequential fixes the pattern
- journal.py + JournalDeBord.tsx: add price_warning field (no_price_data/no_entry_price/
  no_live_price) with visible ⚠ badge and amber color on affected ticker/price cells

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OpenSquared
2026-06-19 14:49:07 +02:00
parent fda6b6a297
commit d34b4043fb
6 changed files with 41 additions and 12 deletions

View File

@@ -468,7 +468,7 @@ def run_cycle_once(trigger: str = "auto") -> Dict[str, Any]:
# Auto-add any new underlying tickers to the IV watchlist
try:
from services.database import add_watchlist_ticker, get_watchlist_tickers
from services.database import _normalize_ticker, add_watchlist_ticker, get_watchlist_tickers
from services.iv_engine import _resolve_ticker, bootstrap_iv_history
existing = set(get_watchlist_tickers())
new_proxies = set()
@@ -476,17 +476,18 @@ def run_cycle_once(trigger: str = "auto") -> Dict[str, Any]:
for trade in (sp.get("trade_rankings") or sp.get("suggested_trades") or []):
underlying = trade.get("underlying") or sp.get("underlying") or ""
if underlying:
proxy = _resolve_ticker(underlying)
normalized = _normalize_ticker(underlying.upper()) # WHEAT→ZW=F, EUR/USD→EURUSD=X
proxy = _resolve_ticker(normalized) # ZW=F→WEAT, EURUSD=X→FXE
if proxy not in existing:
new_proxies.add(proxy)
for proxy in new_proxies:
if add_watchlist_ticker(proxy, added_by="cycle"):
_log.info(f"[Watchlist] Auto-added new ticker: {proxy}")
logger.info(f"[Watchlist] Auto-added new ticker: {proxy}")
log_system_event("INFO", "auto_cycle", f"Nouveau ticker ajouté à la watchlist IV: {proxy}", cycle_id=scoring_run_id, ticker=proxy)
if new_proxies:
bootstrap_iv_history(tickers=list(new_proxies), min_existing=0)
except Exception as _we:
_log.warning(f"[Watchlist] Auto-add failed: {_we}")
logger.warning(f"[Watchlist] Auto-add failed: {_we}")
gauges_summary = {
k: {"value": v.get("value"), "change_pct": v.get("change_pct"), "label": v.get("label")}