From 3556450ff020cde6c77847f1d6e82da46dc52e60 Mon Sep 17 00:00:00 2001 From: dekun Date: Thu, 30 Jul 2026 13:09:30 +0800 Subject: [PATCH] Show in-position vs flat on control monitor cards with green/red. Co-authored-by: Cursor --- control/frontend/src/pages/Monitor.tsx | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/control/frontend/src/pages/Monitor.tsx b/control/frontend/src/pages/Monitor.tsx index a8126f6..4919cfd 100644 --- a/control/frontend/src/pages/Monitor.tsx +++ b/control/frontend/src/pages/Monitor.tsx @@ -37,6 +37,19 @@ function pnlClass(v: unknown): string { return n > 0 ? "pnl-pos" : "pnl-neg"; } +const OPEN_STATUSES = new Set([ + "open", + "half_open", + "option_closed_perp_pending", + "opening", +]); + +function hasOpenPosition(position: Record): boolean { + if (position.has_position === true) return true; + const st = String(position.status || "").toLowerCase(); + return OPEN_STATUSES.has(st); +} + export default function MonitorPage() { const [nodes, setNodes] = useState([]); const [err, setErr] = useState(""); @@ -163,6 +176,7 @@ export default function MonitorPage() { {nodes.map((n) => { const s = pickStrategy(n); const running = s.running === true || s.running === 1; + const inPos = hasOpenPosition(s.position); return (
+
+
持仓
+
+ {inPos ? "持仓中" : "无持仓"} +
+
轮次
{s.rounds ?? "-"}