diff --git a/control/frontend/src/pages/Monitor.tsx b/control/frontend/src/pages/Monitor.tsx index 2f4ad52..2e89dd8 100644 --- a/control/frontend/src/pages/Monitor.tsx +++ b/control/frontend/src/pages/Monitor.tsx @@ -31,6 +31,12 @@ function fmt(v: unknown, digits = 4): string { return n.toFixed(digits); } +function pnlClass(v: unknown): string { + const n = Number(v); + if (!Number.isFinite(n) || n === 0) return "pnl-flat"; + return n > 0 ? "pnl-pos" : "pnl-neg"; +} + export default function MonitorPage() { const [nodes, setNodes] = useState([]); const [err, setErr] = useState(""); @@ -357,9 +363,14 @@ export default function MonitorPage() {

持仓

状态:{String(detail.position.status || "flat")} - {detail.position.net_pnl != null - ? ` · 净浮盈 ${fmt(detail.position.net_pnl, 2)} USDT` - : ""} + {detail.position.net_pnl != null ? ( + <> + {" · 净浮盈 "} + + {fmt(detail.position.net_pnl, 2)} USDT + + + ) : null} {detail.position.expiry_ymd ? ` · 到期 ${String(detail.position.expiry_ymd)} @ ${fmt(detail.position.strike, 0)}` : ""} @@ -387,7 +398,7 @@ export default function MonitorPage() { {fmt(lg.qty, 4)} {fmt(lg.avg_px, 4)} {fmt(lg.mark_px, 4)} - {fmt(lg.upl, 2)} + {fmt(lg.upl, 2)} ))} diff --git a/control/frontend/src/styles.css b/control/frontend/src/styles.css index 952c2a6..1c858fa 100644 --- a/control/frontend/src/styles.css +++ b/control/frontend/src/styles.css @@ -386,3 +386,18 @@ td { text-align: left; white-space: nowrap; } + +.pnl-pos { + color: var(--ok); + font-variant-numeric: tabular-nums; +} + +.pnl-neg { + color: var(--bad); + font-variant-numeric: tabular-nums; +} + +.pnl-flat { + color: var(--muted); + font-variant-numeric: tabular-nums; +}