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 <noreply@anthropic.com>
This commit is contained in:
@@ -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"}
|
||||
|
||||
@@ -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({
|
||||
? <span className="text-cyan-600 shrink-0">{r.surprisePct > 0 ? '+' : ''}{r.surprisePct.toFixed(1)}%</span>
|
||||
: <span className="text-red-800 shrink-0">surp?</span>}
|
||||
{r.score != null && <span className="text-violet-400 shrink-0">{r.score}%</span>}
|
||||
<span className="text-slate-700 shrink-0 ml-1" title="raw prediction_json">{r.rawPred}</span>
|
||||
</div>
|
||||
))}
|
||||
{debugInfo && (
|
||||
@@ -1167,6 +1169,19 @@ function ExplanationScore({
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
{/* DB state: show rows not in refresh (non-empty pred/actual but still 'vide' in snapshot) */}
|
||||
{debugInfo.db_state?.length > 0 && (
|
||||
<div className="mt-2 pt-1 border-t border-slate-800/40">
|
||||
<div className="text-slate-600 mb-0.5">DB state ({debugInfo.db_state.length} analyses)</div>
|
||||
{debugInfo.db_state.map((r: any, i: number) => (
|
||||
<div key={i} className="text-slate-700">
|
||||
#{r.event_id} {(r.event_name ?? '').slice(0, 18)}
|
||||
<span className={r.pred_empty ? 'text-red-800' : 'text-emerald-800'}> pred:{r.pred_empty ? '∅' : `[${(r.pred_keys ?? []).join(',')}]`}</span>
|
||||
<span className={r.actual_empty ? 'text-red-800' : 'text-emerald-800'}> act:{r.actual_empty ? '∅' : JSON.stringify(r.actual_keys)}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user