From 27678e6b8d4b0046e33e9302f32fdce49ad053c3 Mon Sep 17 00:00:00 2001 From: OpenSquared Date: Fri, 24 Jul 2026 21:47:05 +0200 Subject: [PATCH] feat: cockpit --- frontend/src/pages/Dashboard.tsx | 35 +++++++++----------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/frontend/src/pages/Dashboard.tsx b/frontend/src/pages/Dashboard.tsx index 7deddde..ae542b7 100644 --- a/frontend/src/pages/Dashboard.tsx +++ b/frontend/src/pages/Dashboard.tsx @@ -213,33 +213,18 @@ export default function Dashboard() { const lastCycle = (cycleStatusData as any)?.last_cycle ?? null const openPositions: any[] = (openPositionsData as any) ?? [] - // Trades Overview shows each position's trading-side underlying (yfinance/futures - // convention: ^GSPC, ^NDX, GC=F, HG=F, EURUSD=X...), which reads as noise next to the - // Cockpit's own friendly Watchlist names for the exact same instrument (SP500, NASDAQ, - // GOLD, COPPER, EURUSD). Rename to the Watchlist ticker when one plausibly matches — - // suffix-stripped (EURUSD=X -> EURUSD) or via a small curated root-ticker alias table — - // and only if that name is actually in the current Watchlist (not just "known"), so this - // stays tied to what's configured rather than a static list. - const UNDERLYING_ALIASES: Record = { - '^GSPC': 'SP500', '^NDX': 'NASDAQ', '^DJI': 'DOW', '^RUT': 'RUSSELL2000', - 'GC=F': 'GOLD', 'SI=F': 'SILVER', 'HG=F': 'COPPER', 'PL=F': 'PLATINUM', - 'CL=F': 'CRUDE', 'BZ=F': 'BRENT', 'NG=F': 'NATGAS', - 'ZW=F': 'WHEAT', 'ZC=F': 'CORN', 'ZS=F': 'SOYBEANS', - } + // Trades Overview shows each position's trading-side underlying ticker (^GSPC, ^NDX, + // GC=F, EURUSD=X...) — the Watchlist's own `ticker` column holds that exact same raw + // value (confirmed via logging: a Watchlist row's ticker IS "^GSPC"/"GC=F"/etc.), it's + // the row's `name` column that holds the friendly label ("SP500", "GOLD"...) shown + // elsewhere in the Cockpit. So this is a plain ticker -> name lookup, the same one + // nameByTicker already does for the Wavelets Signal card below — no alias table or + // suffix-stripping needed, those were solving a mismatch that didn't actually exist. + const nameByUnderlyingTicker: Record = {} + for (const w of ((watchlistItems as any[]) ?? [])) nameByUnderlyingTicker[String(w.ticker).trim().toUpperCase()] = w.name || w.ticker const underlyingDisplayName = (underlying: string): string => { if (!underlying) return underlying - const upper = underlying.trim().toUpperCase() - const watchlistTickers = new Set(((watchlistItems as any[]) ?? []).map(w => String(w.ticker).trim().toUpperCase())) - const baseTicker = upper.replace(/(=X|=F)$/, '') - let resolved = underlying - if (watchlistTickers.has(upper)) resolved = upper - else if (watchlistTickers.has(baseTicker)) resolved = baseTicker - else { - const alias = UNDERLYING_ALIASES[upper] - if (alias && watchlistTickers.has(alias)) resolved = alias - } - console.warn(`[TradesOverview] raw=${underlying} upper=${upper} baseTicker=${baseTicker} resolved=${resolved} watchlistTickers=[${Array.from(watchlistTickers).join('|')}]`) - return resolved + return nameByUnderlyingTicker[underlying.trim().toUpperCase()] || underlying } // Patterns from the last cycle only (filter by created_at >= cycle started_at)