"use client"; import Link from "next/link"; import { ConfidenceMeter } from "@/components/ui/confidence"; import { FreshnessLabel } from "@/components/ui/freshness"; import { LivePrice } from "@/components/ui/price"; import { StatusBadge } from "@/components/ui/status-badge"; import { ASSET_CLASS_LABEL } from "@/lib/format"; import { useLiveQuote, useMarketStream } from "@/lib/stream"; import type { Exchange, Instrument, InstrumentCoverage, Quote } from "@/lib/types"; import { CoverageBadge } from "@/components/market/coverage-badge"; /** Sticky quote header: symbol, name, live price + change, status badge, freshness, confidence. */ export function InstrumentHeader({ instrument: i, quote, exchange, coverage }: { instrument: Instrument; quote: Quote | null; exchange: (Exchange & { status?: Exchange["status"] }) | null; coverage?: InstrumentCoverage }) { useMarketStream([`quotes:${i.id}`, `events:${i.id}`]); const live = useLiveQuote(i.id); const sources = live && quote && live.received >= Date.parse(quote.updated_at) ? live.sources : quote?.source_count; const conf = live && quote && live.received >= Date.parse(quote.updated_at) ? live.confidence : quote?.confidence; return (
{ASSET_CLASS_LABEL[i.asset_class] ?? i.asset_class} {exchange && ( <> · {exchange.name} {exchange.status && } )} {i.country && i.country !== "XX" && ( <> · {i.country} )}

{i.symbol} {i.name}

{coverage && }
); } function classHref(c: string) { switch (c) { case "EQUITY": return "/stocks"; case "ETF": case "ETN": return "/etfs"; case "INDEX": return "/indices"; case "CRYPTO": return "/crypto"; case "FOREX": return "/forex"; case "TREASURY": case "BOND": case "INTEREST_RATE": return "/rates"; case "COMMODITY": case "FUTURE": return "/commodities"; default: return "/markets"; } }