Show margin and premium in control positions; align exchange price digits.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -185,6 +185,8 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di
|
||||
"avg_px": pos.get("perp_entry_px"),
|
||||
"mark_px": pos.get("perp_mark_px"),
|
||||
"upl": pos.get("perp_upl"),
|
||||
"margin": pos.get("perp_margin"),
|
||||
"premium": None,
|
||||
}
|
||||
)
|
||||
if pos.get("option_side") or pos.get("option_inst_id"):
|
||||
@@ -197,6 +199,8 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di
|
||||
"avg_px": pos.get("option_entry_px"),
|
||||
"mark_px": pos.get("option_mark_px"),
|
||||
"upl": pos.get("option_upl"),
|
||||
"margin": None,
|
||||
"premium": pos.get("initial_premium"),
|
||||
}
|
||||
)
|
||||
|
||||
@@ -262,6 +266,7 @@ async def fleet_status(_tok: Annotated[str, Depends(require_fleet_token)]) -> di
|
||||
"group_id": pos.get("group_id"),
|
||||
"open_at_ms": pos.get("open_at_ms"),
|
||||
"initial_premium": pos.get("initial_premium"),
|
||||
"perp_margin": pos.get("perp_margin"),
|
||||
"exit_target_usdt": pos.get("exit_target_usdt"),
|
||||
"net_pnl": pos.get("net_pnl"),
|
||||
"perp_upl": pos.get("perp_upl"),
|
||||
|
||||
@@ -31,6 +31,17 @@ function fmt(v: unknown, digits = 4): string {
|
||||
return n.toFixed(digits);
|
||||
}
|
||||
|
||||
/** 价格按交易所常见精度:永续/指数 0.01;期权权利金 0.1 */
|
||||
function fmtExPx(kind: unknown, px: unknown): string {
|
||||
if (px == null || px === "") return "—";
|
||||
const n = Number(px);
|
||||
if (!Number.isFinite(n)) return String(px);
|
||||
if (String(kind || "").toLowerCase() === "option") {
|
||||
return (Math.round(n * 10) / 10).toFixed(1);
|
||||
}
|
||||
return (Math.round(n * 100) / 100).toFixed(2);
|
||||
}
|
||||
|
||||
function pnlClass(v: unknown): string {
|
||||
const n = Number(v);
|
||||
if (!Number.isFinite(n) || n === 0) return "pnl-flat";
|
||||
@@ -917,10 +928,14 @@ export default function MonitorPage() {
|
||||
{fmt(detail.strat.option_qty_eth, 4)} ETH
|
||||
</td>
|
||||
<td>{fmt(detail.strat.exit_target_usdt, 2)} USDT</td>
|
||||
<td>{fmt(detail.index_px, 2)}</td>
|
||||
<td className="mono">{fmtExPx("perp", detail.index_px)}</td>
|
||||
<td className="mono">
|
||||
{detail.pair
|
||||
? `${detail.pair.expiry_ymd || "?"} @ ${detail.pair.strike ?? "?"}`
|
||||
? `${detail.pair.expiry_ymd || "?"} @ ${
|
||||
detail.pair.strike != null
|
||||
? Math.round(Number(detail.pair.strike))
|
||||
: "?"
|
||||
}`
|
||||
: "—"}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -1077,8 +1092,28 @@ export default function MonitorPage() {
|
||||
</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)} @ ${fmt(detail.position.strike, 0)}`
|
||||
? ` · 到期 ${String(detail.position.expiry_ymd)} @ ${
|
||||
detail.position.strike != null
|
||||
? Math.round(Number(detail.position.strike))
|
||||
: "—"
|
||||
}`
|
||||
: ""}
|
||||
</p>
|
||||
{detailLegs.length ? (
|
||||
@@ -1092,6 +1127,8 @@ export default function MonitorPage() {
|
||||
<th>数量</th>
|
||||
<th>均价</th>
|
||||
<th>标记</th>
|
||||
<th>保证金</th>
|
||||
<th>权利金</th>
|
||||
<th>浮盈</th>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -1101,10 +1138,33 @@ export default function MonitorPage() {
|
||||
<td>{String(lg.kind || "—")}</td>
|
||||
<td>{String(lg.side || "—")}</td>
|
||||
<td className="mono">{String(lg.inst_id || "—")}</td>
|
||||
<td>{fmt(lg.qty, 4)}</td>
|
||||
<td>{fmt(lg.avg_px, 4)}</td>
|
||||
<td>{fmt(lg.mark_px, 4)}</td>
|
||||
<td className={pnlClass(lg.upl)}>{fmt(lg.upl, 2)}</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>
|
||||
))}
|
||||
</tbody>
|
||||
|
||||
Reference in New Issue
Block a user