Show option top-of-book size and open option before perp.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-25 12:57:16 +08:00
parent 21ca5cbfe0
commit 32e8de85cc
3 changed files with 78 additions and 36 deletions
+12 -2
View File
@@ -6,6 +6,14 @@ function fmt(n: number | null | undefined, d = 2) {
return n.toFixed(d);
}
/** 卖一/买一 + 对应档量:8.80(12.5) / 7.20(8.0) */
function fmtTop(px: number | null | undefined, sz: number | null | undefined) {
if (px == null || Number.isNaN(px)) return "—";
if (sz == null || Number.isNaN(sz)) return fmt(px);
const s = sz >= 100 ? sz.toFixed(0) : sz >= 10 ? sz.toFixed(1) : sz.toFixed(2);
return `${fmt(px)}(${s})`;
}
function pnlClass(n: number | null | undefined) {
if (n == null || Number.isNaN(n) || n === 0) return "";
return n > 0 ? "pos-pnl-profit" : "pos-pnl-loss";
@@ -398,13 +406,15 @@ export default function PlanPage() {
<div className="kv">
<span>Call /</span>
<span className="mono">
{fmt(snap?.call?.ask)} / {fmt(snap?.call?.bid)}
{fmtTop(snap?.call?.ask, snap?.call?.ask_sz)} /{" "}
{fmtTop(snap?.call?.bid, snap?.call?.bid_sz)}
</span>
</div>
<div className="kv">
<span>Put /</span>
<span className="mono">
{fmt(snap?.put?.ask)} / {fmt(snap?.put?.bid)}
{fmtTop(snap?.put?.ask, snap?.put?.ask_sz)} /{" "}
{fmtTop(snap?.put?.bid, snap?.put?.bid_sz)}
</span>
</div>
<div className="kv">