Show both Call and Put legs for OO positions in control.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1196,40 +1196,74 @@ export default function MonitorPage() {
|
||||
|
||||
<section className="modal-section">
|
||||
<h4>持仓</h4>
|
||||
<p className="meta">
|
||||
状态:{String(detail.position.status || "flat")}
|
||||
{detail.position.net_pnl != null ? (
|
||||
<>
|
||||
{" · 净浮盈 "}
|
||||
<span className={pnlClass(detail.position.net_pnl)}>
|
||||
{fmt(detail.position.net_pnl, 2)} USDT
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{detail.position.perp_margin != null ? (
|
||||
<>
|
||||
{" · 保证金 "}
|
||||
<span className="mono">
|
||||
{fmt(detail.position.perp_margin, 2)} U
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{detail.position.initial_premium != null ? (
|
||||
<>
|
||||
{" · 权利金 "}
|
||||
<span className="mono">
|
||||
{fmt(detail.position.initial_premium, 2)} U
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{detail.position.expiry_ymd
|
||||
? ` · 到期 ${String(detail.position.expiry_ymd)} @ ${
|
||||
detail.position.strike != null
|
||||
? Math.round(Number(detail.position.strike))
|
||||
{(() => {
|
||||
const pos = detail.position;
|
||||
const isOo =
|
||||
String(pos.hedge_mode || detail.strat.hedge_mode || "")
|
||||
.toLowerCase() === "option_option" ||
|
||||
detailLegs.some(
|
||||
(lg) =>
|
||||
String(lg.side || "").toLowerCase() === "put" &&
|
||||
String(lg.kind || "") === "option",
|
||||
);
|
||||
const prem1 = Number(pos.initial_premium);
|
||||
const prem2 = Number(pos.initial_premium2);
|
||||
const premTotal =
|
||||
(Number.isFinite(prem1) ? prem1 : 0) +
|
||||
(Number.isFinite(prem2) ? prem2 : 0);
|
||||
const strikeLabel = isOo
|
||||
? `C@${
|
||||
pos.strike != null ? Math.round(Number(pos.strike)) : "—"
|
||||
} / P@${
|
||||
pos.strike2 != null
|
||||
? Math.round(Number(pos.strike2))
|
||||
: "—"
|
||||
}`
|
||||
: ""}
|
||||
</p>
|
||||
: pos.strike != null
|
||||
? String(Math.round(Number(pos.strike)))
|
||||
: "—";
|
||||
return (
|
||||
<p className="meta">
|
||||
状态:{String(pos.status || "flat")}
|
||||
{isOo ? (
|
||||
<>
|
||||
{" · "}
|
||||
<span className="mode-hedge-oo">期期</span>
|
||||
</>
|
||||
) : null}
|
||||
{pos.net_pnl != null ? (
|
||||
<>
|
||||
{" · 净浮盈 "}
|
||||
<span className={pnlClass(pos.net_pnl)}>
|
||||
{fmt(pos.net_pnl, 2)} USDT
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{pos.perp_margin != null && !isOo ? (
|
||||
<>
|
||||
{" · 保证金 "}
|
||||
<span className="mono">
|
||||
{fmt(pos.perp_margin, 2)} U
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{premTotal > 0 || pos.initial_premium != null ? (
|
||||
<>
|
||||
{" · 权利金 "}
|
||||
<span className="mono">
|
||||
{isOo && Number.isFinite(prem2)
|
||||
? `${fmt(prem1, 2)}+${fmt(prem2, 2)}=${fmt(premTotal, 2)}`
|
||||
: fmt(pos.initial_premium, 2)}{" "}
|
||||
U
|
||||
</span>
|
||||
</>
|
||||
) : null}
|
||||
{pos.expiry_ymd
|
||||
? ` · 到期 ${String(pos.expiry_ymd)} ${strikeLabel}`
|
||||
: ""}
|
||||
</p>
|
||||
);
|
||||
})()}
|
||||
{detailLegs.length ? (
|
||||
<div className="legs-table-wrap">
|
||||
<table className="legs-table">
|
||||
@@ -1247,40 +1281,56 @@ export default function MonitorPage() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{detailLegs.map((lg, i) => (
|
||||
<tr key={`${lg.inst_id || i}`}>
|
||||
<td>{String(lg.kind || "—")}</td>
|
||||
<td>{String(lg.side || "—")}</td>
|
||||
<td className="mono">{String(lg.inst_id || "—")}</td>
|
||||
<td className="mono">{fmt(lg.qty, 2)}</td>
|
||||
<td className="mono">
|
||||
{fmtExPx(lg.kind, lg.avg_px)}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{fmtExPx(lg.kind, lg.mark_px)}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{lg.kind === "perp"
|
||||
? fmt(
|
||||
lg.margin ?? detail.position.perp_margin,
|
||||
2,
|
||||
)
|
||||
: "—"}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{lg.kind === "option"
|
||||
? fmt(
|
||||
lg.premium ??
|
||||
detail.position.initial_premium,
|
||||
2,
|
||||
)
|
||||
: "—"}
|
||||
</td>
|
||||
<td className={`mono ${pnlClass(lg.upl)}`}>
|
||||
{fmt(lg.upl, 2)}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{detailLegs.map((lg, i) => {
|
||||
const kind = String(lg.kind || "");
|
||||
const side = String(lg.side || "").toLowerCase();
|
||||
const legLabel =
|
||||
kind === "perp"
|
||||
? "永续"
|
||||
: side === "call"
|
||||
? "Call"
|
||||
: side === "put"
|
||||
? "Put"
|
||||
: kind || "—";
|
||||
return (
|
||||
<tr key={`${lg.inst_id || i}`}>
|
||||
<td>
|
||||
{side === "put" ? (
|
||||
<span className="mode-hedge-oo">{legLabel}</span>
|
||||
) : (
|
||||
legLabel
|
||||
)}
|
||||
</td>
|
||||
<td>{String(lg.side || "—")}</td>
|
||||
<td className="mono">
|
||||
{String(lg.inst_id || "—")}
|
||||
</td>
|
||||
<td className="mono">{fmt(lg.qty, 2)}</td>
|
||||
<td className="mono">
|
||||
{fmtExPx(lg.kind, lg.avg_px)}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{fmtExPx(lg.kind, lg.mark_px)}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{kind === "perp"
|
||||
? fmt(
|
||||
lg.margin ?? detail.position.perp_margin,
|
||||
2,
|
||||
)
|
||||
: "—"}
|
||||
</td>
|
||||
<td className="mono">
|
||||
{kind === "option" || kind === "option2"
|
||||
? fmt(lg.premium, 2)
|
||||
: "—"}
|
||||
</td>
|
||||
<td className={`mono ${pnlClass(lg.upl)}`}>
|
||||
{fmt(lg.upl, 2)}
|
||||
</td>
|
||||
</tr>
|
||||
);
|
||||
})}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user