feat: macro regime + 30 historical events + regime confidence fix
- Add macro_regime (goldilocks/stagflation/recession/etc.) to every instrument snapshot via get_macro_gauges() + score_macro_scenarios() - RegimeCard now shows global macro cycle section (emoji + label + top-3 scenarios) above technical signals - Fix _detect_regime() confidence: capped at 85% max; add late-bull (dist_MA200 > 20%) and correction-in-bull (MA50 > MA200 but momentum < -3%) detection so regime no longer locks at 100% - Add macro_events_bootstrap.py with 30 curated historical events (FOMC 2022-2025, CPI surprises, Ukraine/Hamas/Iran geopolitics, BOJ pivots, Bitcoin ETF, Liberation Day tariffs, SVB crisis, etc.) - POST /api/timeline/bootstrap-macro endpoint (idempotent, deduplicates by name) - Fix event date filter in _get_relevant_events(): overlap logic instead of start-only filter — events extending into the chart window are now included - EventTimelineStrip: add "Signaux Techniques" fallback row for events not matched by any driver keyword (MA crossovers are now always visible) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -155,6 +155,21 @@ FORMAT JSON STRICT:
|
||||
raise HTTPException(500, str(e))
|
||||
|
||||
|
||||
@router.post("/bootstrap-macro")
|
||||
def bootstrap_macro(force: bool = False) -> Dict[str, Any]:
|
||||
"""
|
||||
Seed the market_events table with predefined historical macro + geopolitical events.
|
||||
Pass ?force=true to re-run even if events already exist.
|
||||
"""
|
||||
try:
|
||||
from services.macro_events_bootstrap import bootstrap_macro_events
|
||||
result = bootstrap_macro_events(force=force)
|
||||
return result
|
||||
except Exception as e:
|
||||
logger.error(f"[Timeline] bootstrap_macro failed: {e}")
|
||||
raise HTTPException(500, str(e))
|
||||
|
||||
|
||||
@router.get("/day/{ref_date}")
|
||||
def get_day_context(ref_date: str) -> Dict[str, Any]:
|
||||
from services.database import get_events_for_date, get_timeline_context
|
||||
|
||||
Reference in New Issue
Block a user