feat: cockpit
This commit is contained in:
@@ -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<string, string> = {
|
||||
'^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<string, string> = {}
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user