feat: cockpit

This commit is contained in:
OpenSquared
2026-07-24 21:47:05 +02:00
parent 22b23c0f06
commit 27678e6b8d

View File

@@ -213,33 +213,18 @@ export default function Dashboard() {
const lastCycle = (cycleStatusData as any)?.last_cycle ?? null const lastCycle = (cycleStatusData as any)?.last_cycle ?? null
const openPositions: any[] = (openPositionsData as any) ?? [] const openPositions: any[] = (openPositionsData as any) ?? []
// Trades Overview shows each position's trading-side underlying (yfinance/futures // Trades Overview shows each position's trading-side underlying ticker (^GSPC, ^NDX,
// convention: ^GSPC, ^NDX, GC=F, HG=F, EURUSD=X...), which reads as noise next to the // GC=F, EURUSD=X...) — the Watchlist's own `ticker` column holds that exact same raw
// Cockpit's own friendly Watchlist names for the exact same instrument (SP500, NASDAQ, // value (confirmed via logging: a Watchlist row's ticker IS "^GSPC"/"GC=F"/etc.), it's
// GOLD, COPPER, EURUSD). Rename to the Watchlist ticker when one plausibly matches — // the row's `name` column that holds the friendly label ("SP500", "GOLD"...) shown
// suffix-stripped (EURUSD=X -> EURUSD) or via a small curated root-ticker alias table — // elsewhere in the Cockpit. So this is a plain ticker -> name lookup, the same one
// and only if that name is actually in the current Watchlist (not just "known"), so this // nameByTicker already does for the Wavelets Signal card below — no alias table or
// stays tied to what's configured rather than a static list. // suffix-stripping needed, those were solving a mismatch that didn't actually exist.
const UNDERLYING_ALIASES: Record<string, string> = { const nameByUnderlyingTicker: Record<string, string> = {}
'^GSPC': 'SP500', '^NDX': 'NASDAQ', '^DJI': 'DOW', '^RUT': 'RUSSELL2000', for (const w of ((watchlistItems as any[]) ?? [])) nameByUnderlyingTicker[String(w.ticker).trim().toUpperCase()] = w.name || w.ticker
'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',
}
const underlyingDisplayName = (underlying: string): string => { const underlyingDisplayName = (underlying: string): string => {
if (!underlying) return underlying if (!underlying) return underlying
const upper = underlying.trim().toUpperCase() return nameByUnderlyingTicker[underlying.trim().toUpperCase()] || underlying
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
} }
// Patterns from the last cycle only (filter by created_at >= cycle started_at) // Patterns from the last cycle only (filter by created_at >= cycle started_at)