From b33d06cb974e50db164ed1c73ca4d8ec7e673ffd Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Mon, 29 Jun 2026 23:31:15 +0200 Subject: [PATCH] debug: add db_state display + raw pred_json, expand YFINANCE_MAP YFINANCE_MAP now includes GBPUSD, USDJPY, USDCHF, AUDUSD, NZDUSD, USDCAD, XAGUSD, NASDAQ, DAX, FTSE, WTI, US30Y, DXY. Frontend diagnostic panel shows db_state rows after Recalculer and raw prediction_json prefix per event. Co-Authored-By: Claude Sonnet 4.6 --- backend/routers/causal_lab.py | 13 +++++++++++++ frontend/src/pages/InstrumentDashboard.tsx | 17 ++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/backend/routers/causal_lab.py b/backend/routers/causal_lab.py index 57fcb68..099209e 100644 --- a/backend/routers/causal_lab.py +++ b/backend/routers/causal_lab.py @@ -45,12 +45,25 @@ def _fetch_prices(event_date_str: str, instruments: list[str], lag_days: int = 0 """ YFINANCE_MAP = { "EURUSD": "EURUSD=X", + "GBPUSD": "GBPUSD=X", + "USDJPY": "USDJPY=X", + "USDCHF": "USDCHF=X", + "AUDUSD": "AUDUSD=X", + "NZDUSD": "NZDUSD=X", + "USDCAD": "USDCAD=X", "XAUUSD": "GC=F", + "XAGUSD": "SI=F", "SP500": "^GSPC", + "NASDAQ": "^IXIC", + "DAX": "^GDAXI", + "FTSE": "^FTSE", "BRENT": "BZ=F", + "WTI": "CL=F", "US2Y": "US2YT=RR", "US10Y": "^TNX", "EU10Y": "GE10YT=RR", + "US30Y": "^TYX", + "DXY": "DX-Y.NYB", } out: dict = {"mode": "none"} diff --git a/frontend/src/pages/InstrumentDashboard.tsx b/frontend/src/pages/InstrumentDashboard.tsx index 57025e9..df2ea72 100644 --- a/frontend/src/pages/InstrumentDashboard.tsx +++ b/frontend/src/pages/InstrumentDashboard.tsx @@ -1031,7 +1031,7 @@ function ExplanationScore({ // For each linked event, compute the comprehension score and collect scored ones const scored: number[] = [] const totalLinked: number[] = [] - const debugRows: {id?: number; name: string; pred: string; actual: string; score: number | null; reason: string; surprisePct?: number | null}[] = [] + const debugRows: {id?: number; name: string; pred: string; actual: string; score: number | null; reason: string; surprisePct?: number | null; rawPred?: string}[] = [] for (const ev of events) { if (!ev.template_id) continue @@ -1066,6 +1066,7 @@ function ExplanationScore({ actual: hasActual ? '✓' : '✗', score: null, reason, surprisePct: ev.surprise_pct ?? null, + rawPred: (ev.prediction_json ?? 'null').slice(0, 30), }) const s = comprehensionScore(ev, tmpl, inst) @@ -1146,6 +1147,7 @@ function ExplanationScore({ ? {r.surprisePct > 0 ? '+' : ''}{r.surprisePct.toFixed(1)}% : surp?} {r.score != null && {r.score}%} + {r.rawPred} ))} {debugInfo && ( @@ -1167,6 +1169,19 @@ function ExplanationScore({ ))} + {/* DB state: show rows not in refresh (non-empty pred/actual but still 'vide' in snapshot) */} + {debugInfo.db_state?.length > 0 && ( +
+
DB state ({debugInfo.db_state.length} analyses)
+ {debugInfo.db_state.map((r: any, i: number) => ( +
+ #{r.event_id} {(r.event_name ?? '').slice(0, 18)} + pred:{r.pred_empty ? '∅' : `[${(r.pred_keys ?? []).join(',')}]`} + act:{r.actual_empty ? '∅' : JSON.stringify(r.actual_keys)} +
+ ))} +
+ )} )}