Overview: focus|radar pairing, selectable radar, performance chart
Layout regrouped by relationship, not size: the setup-in-focus card and the radar sit side by side (they are one decision surface), the four account ribbons move directly above the open positions they describe, and a new performance chart closes the page. - Radar rows are selectable: clicking one swaps the focus card to that setup - including below-gate rows, whose card shows a muted "rank N / below gate" badge and the disqualify reason in the footer, with a "back to top pick" reset. The row currently in focus is highlighted; ticker links still deep-link without selecting. - Performance chart (the mockup's missing piece): new GET /paper-trades/equity-curve computes, per benchmark trading day since the first paper trade, the book's cumulative P&L (realized + mark-to-market from stored OHLCV) vs the same cost basis riding SPY over each trade's window (benchmark_prices). Pure curve math in paper_trade_service with unit tests; hidden until there are 2+ points of data. Frontend renders both lines with crosshair readout, zero baseline, and direct end labels. Backend unit suite: 501 passed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,6 +9,7 @@ import { useTickerNames } from '../hooks/useTickers';
|
||||
import { Callout } from '../components/ui/Callout';
|
||||
import { Section } from '../components/ui/Section';
|
||||
import { OpenTradesPanel } from '../components/dashboard/OpenTradesPanel';
|
||||
import { PerfChart } from '../components/dashboard/PerfChart';
|
||||
import { PriceRail, RadarChart, radarAxesFromDimensions } from '../components/charts/horizon';
|
||||
import type { RadarAxis } from '../components/charts/horizon';
|
||||
import { SkeletonCard, SkeletonTable } from '../components/ui/Skeleton';
|
||||
@@ -67,21 +68,37 @@ interface RadarRow {
|
||||
reason: string | null;
|
||||
}
|
||||
|
||||
/** One radar row — compact enough for the half-width column. */
|
||||
function RadarSetupRow({ setup, rank, reason, name }: RadarRow & { name?: string }) {
|
||||
/** One radar row — compact enough for the half-width column; selecting it
|
||||
* swaps the focus card to this setup. */
|
||||
function RadarSetupRow({ setup, rank, reason, name, selected, onSelect }: RadarRow & {
|
||||
name?: string;
|
||||
selected?: boolean;
|
||||
onSelect?: () => void;
|
||||
}) {
|
||||
const qualified = reason === null;
|
||||
const prob = primaryTargetProbability(setup);
|
||||
return (
|
||||
<li
|
||||
className={`grid grid-cols-[20px_minmax(92px,116px)_44px_1fr_auto] items-center gap-2.5 px-2 py-2.5 ${
|
||||
qualified ? '' : 'opacity-60'
|
||||
}`}
|
||||
title={`R:R ${setup.rr_ratio.toFixed(1)}:1${prob != null ? ` · target prob ${Math.round(prob)}%` : ''}`}
|
||||
role="button"
|
||||
tabIndex={0}
|
||||
aria-pressed={selected}
|
||||
onClick={onSelect}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter' || e.key === ' ') {
|
||||
e.preventDefault();
|
||||
onSelect?.();
|
||||
}
|
||||
}}
|
||||
className={`grid cursor-pointer grid-cols-[20px_minmax(92px,116px)_44px_1fr_auto] items-center gap-2.5 rounded-lg px-2 py-2.5 transition-colors ${
|
||||
selected ? 'bg-blue-400/[0.08]' : 'hover:bg-white/[0.03]'
|
||||
} ${qualified ? '' : 'opacity-60'}`}
|
||||
title={`R:R ${setup.rr_ratio.toFixed(1)}:1${prob != null ? ` · target prob ${Math.round(prob)}%` : ''} · click to focus`}
|
||||
>
|
||||
<span className="num text-[11px] text-gray-500">{rank}</span>
|
||||
<span className="min-w-0">
|
||||
<Link
|
||||
to={`/ticker/${setup.symbol}`}
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
className="block font-medium text-blue-300 transition-colors hover:text-blue-200"
|
||||
>
|
||||
{setup.symbol}
|
||||
@@ -119,19 +136,27 @@ function convictionLabel(action: TradeSetup['recommended_action']): string {
|
||||
return '—';
|
||||
}
|
||||
|
||||
/** The one focal card: today's top qualified setup as a spatial price rail. */
|
||||
function FocusCard({ setup, name, gateNote }: {
|
||||
/** The focal card: a setup as a spatial price rail — the top pick by default,
|
||||
* or whichever radar row is selected. */
|
||||
function FocusCard({ setup, name, badge, badgeTone, footNote, onReset }: {
|
||||
setup: TradeSetup;
|
||||
name: string | undefined;
|
||||
gateNote: string;
|
||||
badge: string;
|
||||
badgeTone: 'ember' | 'muted';
|
||||
footNote: string;
|
||||
onReset?: () => void;
|
||||
}) {
|
||||
const prob = primaryTargetProbability(setup);
|
||||
return (
|
||||
<section className="glass p-6 sm:p-7" aria-label="Top qualified setup">
|
||||
<section className="glass p-6 sm:p-7" aria-label={`Setup in focus: ${setup.symbol}`}>
|
||||
<div className="flex flex-wrap items-start justify-between gap-6">
|
||||
<div className="flex items-start gap-4">
|
||||
<span className="num mt-2.5 whitespace-nowrap rounded-full border border-[#ff6a45]/40 px-2.5 py-1 text-[9.5px] font-semibold uppercase tracking-[0.2em] text-[#ff6a45]">
|
||||
top pick
|
||||
<span className={`num mt-2.5 whitespace-nowrap rounded-full border px-2.5 py-1 text-[9.5px] font-semibold uppercase tracking-[0.2em] ${
|
||||
badgeTone === 'ember'
|
||||
? 'border-[#ff6a45]/40 text-[#ff6a45]'
|
||||
: 'border-white/[0.15] text-gray-400'
|
||||
}`}>
|
||||
{badge}
|
||||
</span>
|
||||
<div>
|
||||
<div className="flex items-baseline gap-3">
|
||||
@@ -185,8 +210,16 @@ function FocusCard({ setup, name, gateNote }: {
|
||||
/>
|
||||
|
||||
<div className="mt-4 flex flex-wrap items-center justify-between gap-4 border-t border-white/[0.06] pt-4">
|
||||
<span className="text-xs text-gray-500">cleared the gate · {gateNote}</span>
|
||||
<span className="flex gap-2.5">
|
||||
<span className="text-xs text-gray-500">{footNote}</span>
|
||||
<span className="flex items-center gap-2.5">
|
||||
{onReset && (
|
||||
<button
|
||||
onClick={onReset}
|
||||
className="text-xs font-medium text-gray-400 transition-colors hover:text-gray-200"
|
||||
>
|
||||
← top pick
|
||||
</button>
|
||||
)}
|
||||
<Link
|
||||
to={`/ticker/${setup.symbol}`}
|
||||
className="rounded-lg border border-blue-500/35 bg-blue-500/15 px-4 py-1.5 text-[13px] font-semibold text-blue-300 transition-colors hover:bg-blue-500/25"
|
||||
@@ -276,6 +309,9 @@ export default function DashboardPage() {
|
||||
// Default open when nothing qualifies — the near-misses ARE the content then.
|
||||
const showBelow = belowChoice ?? radar.qualified.length === 0;
|
||||
|
||||
// Radar selection swaps the focus card; null = the top pick.
|
||||
const [focusId, setFocusId] = useState<number | null>(null);
|
||||
|
||||
const topWatchlist = useMemo(
|
||||
() =>
|
||||
[...(watchlist.data ?? [])]
|
||||
@@ -318,6 +354,13 @@ export default function DashboardPage() {
|
||||
|
||||
const topPick = topSetups[0];
|
||||
|
||||
// What the focus card shows: the selected radar row, else the top pick.
|
||||
const focusRow = focusId != null
|
||||
? [...radar.qualified, ...radar.below].find((r) => r.setup.id === focusId) ?? null
|
||||
: null;
|
||||
const focusSetup = focusRow?.setup ?? topPick;
|
||||
const focusIsTop = focusRow == null || (topPick != null && focusRow.setup.id === topPick.id);
|
||||
|
||||
return (
|
||||
<div className="space-y-8 animate-slide-up">
|
||||
{/* Hero — the verdict */}
|
||||
@@ -370,24 +413,129 @@ export default function DashboardPage() {
|
||||
)
|
||||
)}
|
||||
|
||||
{/* Focal setup */}
|
||||
{(trades.isLoading || activation.isLoading) && <SkeletonCard />}
|
||||
{trades.isError && <Callout variant="error">Failed to load setups</Callout>}
|
||||
{trades.data && activation.data && (
|
||||
topPick ? (
|
||||
<FocusCard
|
||||
setup={topPick}
|
||||
name={tickerNames.get(topPick.symbol.toUpperCase())}
|
||||
gateNote={activationSummary(activation.data)}
|
||||
/>
|
||||
) : (
|
||||
<Callout variant="empty">
|
||||
No qualified actionable setups right now — the radar below shows what's close and why it doesn't qualify.
|
||||
</Callout>
|
||||
)
|
||||
)}
|
||||
{/* Setup in focus | Radar — the decision pair */}
|
||||
<div className="grid items-start gap-8 xl:grid-cols-5">
|
||||
<div className="xl:col-span-3">
|
||||
{(trades.isLoading || activation.isLoading) && <SkeletonCard />}
|
||||
{trades.isError && <Callout variant="error">Failed to load setups</Callout>}
|
||||
{trades.data && activation.data && (
|
||||
focusSetup ? (
|
||||
<FocusCard
|
||||
setup={focusSetup}
|
||||
name={tickerNames.get(focusSetup.symbol.toUpperCase())}
|
||||
badge={
|
||||
focusIsTop
|
||||
? 'top pick'
|
||||
: focusRow && focusRow.reason === null
|
||||
? `rank ${focusRow.rank}`
|
||||
: `rank ${focusRow?.rank ?? '—'} · below gate`
|
||||
}
|
||||
badgeTone={focusIsTop ? 'ember' : 'muted'}
|
||||
footNote={
|
||||
focusRow && focusRow.reason !== null
|
||||
? `does not qualify: ${focusRow.reason}`
|
||||
: `cleared the gate · ${activationSummary(activation.data)}`
|
||||
}
|
||||
onReset={focusIsTop ? undefined : () => setFocusId(null)}
|
||||
/>
|
||||
) : (
|
||||
<Callout variant="empty">
|
||||
No qualified actionable setups right now — select a radar row to inspect what's close and why it doesn't qualify.
|
||||
</Callout>
|
||||
)
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Metric strip */}
|
||||
<div className="xl:col-span-2">
|
||||
<Section title="Radar" hint="ranked by strategy score · select a row to focus it">
|
||||
{trades.isLoading && <SkeletonTable rows={5} cols={5} />}
|
||||
{trades.data && radar.qualified.length === 0 && radar.below.length === 0 && (
|
||||
<Callout variant="empty">No live setups right now.</Callout>
|
||||
)}
|
||||
{(radar.qualified.length > 0 || radar.below.length > 0) && (
|
||||
<div className="glass px-4 py-2">
|
||||
{/* Qualified fingerprints — same axes, shapes compare at a glance */}
|
||||
{fingerprints.length > 0 && (
|
||||
<div className="flex flex-wrap items-end gap-4 border-b border-white/[0.06] px-2 pb-3 pt-1.5">
|
||||
{fingerprints.map((f) => (
|
||||
<figure key={f.symbol} className="text-center">
|
||||
<RadarChart axes={f.axes} size={82} labels={false} />
|
||||
<figcaption className="-mt-1">
|
||||
<Link to={`/ticker/${f.symbol}`} className="block text-[13px] font-semibold text-gray-200 hover:text-blue-200">
|
||||
{f.symbol}
|
||||
</Link>
|
||||
<span className={`num text-[9px] uppercase tracking-[0.14em] ${
|
||||
f.rank === 1 ? 'text-[#ff6a45]' : 'text-gray-500'
|
||||
}`}>
|
||||
{f.rank === 1 ? 'top pick' : `rank ${f.rank}`}
|
||||
</span>
|
||||
</figcaption>
|
||||
</figure>
|
||||
))}
|
||||
<p className="num mb-2 ml-auto max-w-[170px] text-right text-[10px] leading-relaxed text-gray-500">
|
||||
qualified fingerprints · hover a corner for scores
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Qualified rows — the actionable list */}
|
||||
{radar.qualified.length > 0 ? (
|
||||
<ul className="divide-y divide-white/[0.04]">
|
||||
{radar.qualified.map((row) => (
|
||||
<RadarSetupRow
|
||||
key={row.setup.id}
|
||||
{...row}
|
||||
name={tickerNames.get(row.setup.symbol.toUpperCase())}
|
||||
selected={focusSetup?.id === row.setup.id}
|
||||
onSelect={() => setFocusId(row.setup.id)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="px-2 py-2.5 text-xs text-gray-500">
|
||||
None clear the gate today — the closest candidates are below.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Below the gate, collapsed by default when there are qualified setups */}
|
||||
{radar.below.length > 0 && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setBelowChoice(!showBelow)}
|
||||
aria-expanded={showBelow}
|
||||
className="flex w-full items-center gap-2 border-t border-white/[0.06] px-2 py-2.5 text-left text-xs text-gray-500 transition-colors hover:text-gray-300"
|
||||
>
|
||||
<span className={`text-[9px] transition-transform ${showBelow ? 'rotate-90' : ''}`} aria-hidden="true">▶</span>
|
||||
{radar.below.length} below the gate — why each doesn't qualify
|
||||
</button>
|
||||
{showBelow && (
|
||||
<ul className="divide-y divide-white/[0.04] border-t border-white/[0.04]">
|
||||
{radar.below.map((row) => (
|
||||
<RadarSetupRow
|
||||
key={row.setup.id}
|
||||
{...row}
|
||||
name={tickerNames.get(row.setup.symbol.toUpperCase())}
|
||||
selected={focusSetup?.id === row.setup.id}
|
||||
onSelect={() => setFocusId(row.setup.id)}
|
||||
/>
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="flex justify-end border-t border-white/[0.04] px-2 py-2.5">
|
||||
<Link to="/signals" className="text-xs font-medium text-blue-300 transition-colors hover:text-blue-200">
|
||||
All setups →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Metric strip — the account ribbons, right above the positions they describe */}
|
||||
{(trades.isLoading || openTrades.isLoading) ? (
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-4">
|
||||
<SkeletonCard /><SkeletonCard /><SkeletonCard /><SkeletonCard />
|
||||
@@ -428,85 +576,11 @@ export default function DashboardPage() {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Open positions | Radar — side by side like the mockup */}
|
||||
<div className="grid items-start gap-8 xl:grid-cols-2">
|
||||
<OpenTradesPanel />
|
||||
|
||||
<Section title="Radar" hint="ranked by strategy score">
|
||||
{trades.isLoading && <SkeletonTable rows={5} cols={5} />}
|
||||
{trades.data && radar.qualified.length === 0 && radar.below.length === 0 && (
|
||||
<Callout variant="empty">No live setups right now.</Callout>
|
||||
)}
|
||||
{(radar.qualified.length > 0 || radar.below.length > 0) && (
|
||||
<div className="glass px-4 py-2">
|
||||
{/* Qualified fingerprints — same axes, shapes compare at a glance */}
|
||||
{fingerprints.length > 0 && (
|
||||
<div className="flex flex-wrap items-end gap-4 border-b border-white/[0.06] px-2 pb-3 pt-1.5">
|
||||
{fingerprints.map((f) => (
|
||||
<figure key={f.symbol} className="text-center">
|
||||
<RadarChart axes={f.axes} size={82} labels={false} />
|
||||
<figcaption className="-mt-1">
|
||||
<Link to={`/ticker/${f.symbol}`} className="block text-[13px] font-semibold text-gray-200 hover:text-blue-200">
|
||||
{f.symbol}
|
||||
</Link>
|
||||
<span className={`num text-[9px] uppercase tracking-[0.14em] ${
|
||||
f.rank === 1 ? 'text-[#ff6a45]' : 'text-gray-500'
|
||||
}`}>
|
||||
{f.rank === 1 ? 'top pick' : `rank ${f.rank}`}
|
||||
</span>
|
||||
</figcaption>
|
||||
</figure>
|
||||
))}
|
||||
<p className="num mb-2 ml-auto max-w-[170px] text-right text-[10px] leading-relaxed text-gray-500">
|
||||
qualified fingerprints · hover a corner for scores
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Qualified rows — the actionable list */}
|
||||
{radar.qualified.length > 0 ? (
|
||||
<ul className="divide-y divide-white/[0.04]">
|
||||
{radar.qualified.map((row) => (
|
||||
<RadarSetupRow key={row.setup.id} {...row} name={tickerNames.get(row.setup.symbol.toUpperCase())} />
|
||||
))}
|
||||
</ul>
|
||||
) : (
|
||||
<p className="px-2 py-2.5 text-xs text-gray-500">
|
||||
None clear the gate today — the closest candidates are below.
|
||||
</p>
|
||||
)}
|
||||
|
||||
{/* Below the gate, collapsed by default when there are qualified setups */}
|
||||
{radar.below.length > 0 && (
|
||||
<>
|
||||
<button
|
||||
onClick={() => setBelowChoice(!showBelow)}
|
||||
aria-expanded={showBelow}
|
||||
className="flex w-full items-center gap-2 border-t border-white/[0.06] px-2 py-2.5 text-left text-xs text-gray-500 transition-colors hover:text-gray-300"
|
||||
>
|
||||
<span className={`text-[9px] transition-transform ${showBelow ? 'rotate-90' : ''}`} aria-hidden="true">▶</span>
|
||||
{radar.below.length} below the gate — why each doesn't qualify
|
||||
</button>
|
||||
{showBelow && (
|
||||
<ul className="divide-y divide-white/[0.04] border-t border-white/[0.04]">
|
||||
{radar.below.map((row) => (
|
||||
<RadarSetupRow key={row.setup.id} {...row} name={tickerNames.get(row.setup.symbol.toUpperCase())} />
|
||||
))}
|
||||
</ul>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
<div className="flex justify-end border-t border-white/[0.04] px-2 py-2.5">
|
||||
<Link to="/signals" className="text-xs font-medium text-blue-300 transition-colors hover:text-blue-200">
|
||||
All setups →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</Section>
|
||||
</div>
|
||||
{/* Open positions — full width, right under their ribbons */}
|
||||
<OpenTradesPanel />
|
||||
|
||||
{/* Performance — the paper book vs the same dollars in SPY */}
|
||||
<PerfChart />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user