fix(hub): recalc market floating PnL from live chart mark

Use plan margin x leverage x price change with latest K-line close instead of stale board snapshot floating_pnl.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-06-04 20:09:35 +08:00
parent e6361a7fcc
commit c9ca106b81
3 changed files with 108 additions and 26 deletions
+10 -1
View File
@@ -1380,7 +1380,15 @@
const planMargin =
trendPlan && trendPlan.plan_margin_capital != null
? num(trendPlan.plan_margin_capital)
: null;
: mo.margin_capital != null
? num(mo.margin_capital)
: null;
const leverage =
trendPlan && trendPlan.leverage != null
? num(trendPlan.leverage)
: mo.leverage != null
? num(mo.leverage)
: null;
return {
exchange_id: exchangeId || null,
symbol: (pos.symbol || "").trim(),
@@ -1394,6 +1402,7 @@
unrealized_pnl: upnl != null ? Number(upnl) : null,
notional_usdt: num(pos.notional_usdt),
plan_margin: planMargin,
leverage: leverage,
orders: orders,
};
}