Show option bid as price/size and option leverage on plan and trades.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-31 16:01:34 +08:00
parent dffcd77837
commit dffcc4eeb9
5 changed files with 75 additions and 1 deletions
+2
View File
@@ -273,6 +273,8 @@ export type PlanState = {
option_qty_eth?: number;
option_qty_contracts?: number;
option_mark_px?: number | null;
option_bid_sz?: number | null;
option_leverage?: number | null;
strike?: number | null;
expiry_ymd?: string | null;
expiry_ms?: number | null;
+14 -1
View File
@@ -14,6 +14,14 @@ function fmtTop(px: number | null | undefined, sz: number | null | undefined) {
return `${fmt(px)}(${s})`;
}
/** 持仓买一:价格/流动性张数,如 17.00/4000 */
function fmtBidLiq(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";
@@ -638,6 +646,9 @@ export default function PlanPage() {
<span className="pos-meta-item mono">
{fmt(pos?.option_qty_eth, 2)} ETH · {fmt(pos?.option_qty_contracts, 0)}
</span>
<span className="pos-meta-item mono" title="开仓指数÷开仓均价">
{fmt(pos?.option_leverage, 0)}x
</span>
</div>
<div className="pos-grid">
<div className="pos-cell">
@@ -646,7 +657,9 @@ export default function PlanPage() {
</div>
<div className="pos-cell">
<span className="pos-label"></span>
<span className="pos-value mono">{fmt(pos?.option_mark_px)}</span>
<span className="pos-value mono">
{fmtBidLiq(pos?.option_mark_px, pos?.option_bid_sz)}
</span>
</div>
<div className="pos-cell">
<span className="pos-label">
+18
View File
@@ -47,6 +47,7 @@ type Group = {
entry_index_px?: number | null;
close_index_px?: number | null;
move_points?: number | null;
option_leverage?: number | null;
exec_mode?: string | null;
expiry_settle?: ExpirySettle | null;
pnl_summary?: PnlSummary;
@@ -207,6 +208,9 @@ export default function TradesPage() {
{fmtTime(openMs)} · {fmtTime(closeMs)} · {" "}
{fmtHold(g.hold_ms)}
{g.move_points != null ? ` · 波动 ${fmtMovePoints(g.move_points)}` : ""}
{g.option_leverage != null
? ` · 期权杠杆 ${fmt(g.option_leverage, 0)}x`
: ""}
</span>
</div>
<div className={`trade-row-pnl mono ${pnlClass(listPnl)}`}>
@@ -255,6 +259,7 @@ export default function TradesPage() {
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
@@ -281,6 +286,11 @@ export default function TradesPage() {
<td className="mono">{fmtTime(openMs)}</td>
<td className="mono">{fmtTime(closeMs)}</td>
<td className="mono">{fmtHold(g.hold_ms)}</td>
<td className="mono">
{g.option_leverage != null
? `${fmt(g.option_leverage, 0)}x`
: "—"}
</td>
<td className="mono">{fmtMovePoints(g.move_points)}</td>
<td className={`mono ${pnlClass(listPnl)}`}>
{fmt(listPnl)}
@@ -402,6 +412,14 @@ export default function TradesPage() {
{fmtHold(selectedGroup.hold_ms)}
</span>
</div>
<div className="kv">
<span></span>
<span className="mono">
{selectedGroup.option_leverage != null
? `${fmt(selectedGroup.option_leverage, 0)}x`
: "—"}
</span>
</div>
<div className="kv">
<span></span>
<span className="mono">