feat(hub): show floating PnL on market page and drag stop-loss to place TP/SL
Pass unrealized PnL from monitor jump context, refresh from board snapshot, and let users drag the SL price line to call the same place-tpsl API as the monitor entrust dialog. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -1304,7 +1304,7 @@
|
||||
};
|
||||
}
|
||||
|
||||
function buildPositionMarketContext(pos, monitorOrder, trendPlan) {
|
||||
function buildPositionMarketContext(pos, monitorOrder, trendPlan, exchangeId) {
|
||||
const tpsl = resolvePositionTpsl(pos, monitorOrder, trendPlan);
|
||||
const cond = condOrdersFromPosition(pos);
|
||||
const reg = Array.isArray(pos.regular_orders) ? pos.regular_orders : [];
|
||||
@@ -1330,7 +1330,10 @@
|
||||
amount: num(o.amount),
|
||||
});
|
||||
});
|
||||
const upnl = resolveTrendFloatingPnl(pos, trendPlan);
|
||||
return {
|
||||
exchange_id: exchangeId || null,
|
||||
symbol: (pos.symbol || "").trim(),
|
||||
side: (pos.side || "long").toLowerCase(),
|
||||
entry: num(tpsl.entry),
|
||||
stop_loss: num(tpsl.sl),
|
||||
@@ -1338,6 +1341,8 @@
|
||||
tp_monitored: !!tpsl.tp_monitored,
|
||||
is_trend: !!tpsl.is_trend,
|
||||
contracts: num(pos.contracts),
|
||||
unrealized_pnl: upnl != null ? Number(upnl) : null,
|
||||
notional_usdt: num(pos.notional_usdt),
|
||||
orders: orders,
|
||||
};
|
||||
}
|
||||
@@ -1364,7 +1369,9 @@
|
||||
function marketOpenBtnAttrs(exchangeId, exchangeKey, symbol, pos, monitorOrder, trendPlan) {
|
||||
const symAttr = esc(symbol || "").replace(/"/g, """);
|
||||
const exKeyAttr = esc(exchangeKey || exchangeId || "").replace(/"/g, """);
|
||||
const ctxEnc = esc(encodePosCtx(buildPositionMarketContext(pos, monitorOrder, trendPlan))).replace(
|
||||
const ctxEnc = esc(
|
||||
encodePosCtx(buildPositionMarketContext(pos, monitorOrder, trendPlan, exchangeId))
|
||||
).replace(
|
||||
/"/g,
|
||||
"""
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user