fix: weekend-aware cycle — IVGate, pandas MultiIndex, ticker aliases, day/session in AI prompt
- auto_cycle.py: detect weekend/market session, build cycle_meta with day_of_week/is_weekend/market_note; IVGate skips iv_rank>=99 on weekends to avoid artificial weekend option premium cascade; inject portfolio context (open trades + price moves + concentration) before AI scoring; pass portfolio_context_block + run_id to both AI scorer and suggester - ai_analyzer.py: _build_temporal_news_block injects market session banner (WEEKEND warning, pre/after-market note, or open session label) so AI knows markets are closed and defers execution to Monday - iv_engine.py: add WHEAT/EUR/USD ticker aliases; skip saving IV snapshots on weekends to protect history; resolve aliases before slash-format conversion in _resolve_ticker - technical_indicators.py: fix pandas MultiIndex from yfinance>=0.2 (droplevel+squeeze); use period proportional to lookback instead of fixed period=1d - database.py: asset_class ticker-based fallback (_asset_class_from_ticker); one-time backfill migration for all NULL asset_class rows; ai_call_logs table + save/get helpers; normalize_ticker public function Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -105,13 +105,16 @@ def compute_indicators(ticker: str, horizon_days: int, enabled_indicators: Optio
|
||||
lookback = cal["ma_slow"] * 2 + 50
|
||||
try:
|
||||
df = yf.download(ticker, period=f"{lookback}d", interval="1d", progress=False, auto_adjust=True)
|
||||
# yfinance ≥0.2 returns MultiIndex columns when group_by is not set — flatten
|
||||
if df is not None and isinstance(df.columns, pd.MultiIndex):
|
||||
df.columns = df.columns.droplevel(1)
|
||||
except Exception as e:
|
||||
return {"error": f"yfinance download failed: {e}"}
|
||||
|
||||
if df is None or len(df) < cal["ma_slow"]:
|
||||
return {"error": f"Not enough data for {ticker} (got {len(df) if df is not None else 0} rows)"}
|
||||
|
||||
closes = df["Close"].dropna()
|
||||
closes = df["Close"].squeeze().dropna()
|
||||
price = float(closes.iloc[-1])
|
||||
enabled = set(enabled_indicators) if enabled_indicators else {"rsi", "ma", "bollinger", "atr"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user