修复中控保本状态
This commit is contained in:
@@ -858,6 +858,24 @@ body.market-chart-fs-open {
|
||||
color: #4cd97f;
|
||||
}
|
||||
|
||||
.pos-breakeven-badge {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
margin-left: 6px;
|
||||
padding: 2px 8px;
|
||||
border-radius: 6px;
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
background: #1a3d2e;
|
||||
color: #4cd97f;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.data-table .td-symbol {
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.hub-pos-card .pos-grid {
|
||||
display: grid;
|
||||
grid-template-columns: repeat(3, 1fr);
|
||||
|
||||
@@ -414,9 +414,11 @@
|
||||
return calcRrRatio(side, entry, initSl || sl, tp);
|
||||
}
|
||||
|
||||
function isBreakevenSecured(side, entry, monitorOrder, cond) {
|
||||
function isBreakevenSecured(side, entry, monitorOrder, cond, pos) {
|
||||
const mo = monitorOrder || {};
|
||||
const p = pos || {};
|
||||
if (mo.sl_breakeven_secured === true || mo.sl_breakeven_secured === 1) return true;
|
||||
if (p.sl_breakeven_secured === true || p.sl_breakeven_secured === 1) return true;
|
||||
const { sl } = pickExTpslOrders(cond);
|
||||
const trig = sl && sl.trigger_price != null ? Number(sl.trigger_price) : NaN;
|
||||
const e = Number(entry);
|
||||
@@ -425,6 +427,10 @@
|
||||
return trig >= e;
|
||||
}
|
||||
|
||||
function breakevenBadgeHtml() {
|
||||
return `<span class="pos-breakeven-badge">已保本</span>`;
|
||||
}
|
||||
|
||||
async function loadMonitorBoard() {
|
||||
const box = document.getElementById("monitor-grid");
|
||||
const showLoading = !lastMonitorRows.length;
|
||||
@@ -955,7 +961,7 @@
|
||||
const tp = tpsl.tp;
|
||||
const tpMonitored = tpsl.tp_monitored;
|
||||
const rr = resolveSnapshotRr(mo, side, entry, sl, tp, tpMonitored);
|
||||
const beSecured = isBreakevenSecured(side, entry, mo, cond);
|
||||
const beSecured = isBreakevenSecured(side, entry, mo, cond, pos);
|
||||
const upnl = pos.unrealized_pnl;
|
||||
let pnlText = fmt(upnl, 2) + "U";
|
||||
if (pos.notional_usdt && upnl != null && Math.abs(Number(pos.notional_usdt)) > 1e-8) {
|
||||
@@ -979,14 +985,12 @@
|
||||
meta.push(
|
||||
`<span class="${beOn ? "pos-meta-on" : "pos-meta-off"}">移动保本:${beOn ? "开" : "关"}</span>`
|
||||
);
|
||||
if (beSecured) {
|
||||
meta.push(`<span class="pos-meta-item"><span class="pos-breakeven-badge">已保本</span></span>`);
|
||||
}
|
||||
const symBeBadge = beSecured ? ` ${breakevenBadgeHtml()}` : "";
|
||||
const mktAttrs = marketOpenBtnAttrs(exchangeId, exchangeKey, symbol, pos, monitorOrder, trendPlan);
|
||||
return `<div class="pos-card hub-pos-card">
|
||||
<div class="pos-card-head">
|
||||
<div class="pos-card-symbol">
|
||||
<button type="button" class="btn-open-market sym-link pos-symbol-link" ${mktAttrs} title="打开行情区(含入场/止盈止损)"><strong>${esc(symbol)}</strong></button>
|
||||
<button type="button" class="btn-open-market sym-link pos-symbol-link" ${mktAttrs} title="打开行情区(含入场/止盈止损)"><strong>${esc(symbol)}</strong></button>${symBeBadge}
|
||||
<span class="pos-side-badge ${sideCls}">${sideCn}</span>
|
||||
</div>
|
||||
<div class="pos-head-actions">
|
||||
@@ -1091,18 +1095,21 @@
|
||||
const symAttr = esc(x.symbol || "").replace(/"/g, """);
|
||||
const exKeyAttr = esc(exchangeKey || exchangeId || "").replace(/"/g, """);
|
||||
const sideAttr = esc((x.side || "").toLowerCase()).replace(/"/g, """);
|
||||
const side = sideAttr || "long";
|
||||
const contractsAttr = esc(String(x.contracts != null ? x.contracts : "")).replace(/"/g, """);
|
||||
const cond = condOrdersFromPosition(x);
|
||||
const reg = Array.isArray(x.regular_orders) ? x.regular_orders : [];
|
||||
const tpsl = resolvePositionTpsl(x, monitorOrder, trendPlan);
|
||||
const beSecured = isBreakevenSecured(side, tpsl.entry, monitorOrder, cond, x);
|
||||
const slAttr = esc(String(tpsl.sl)).replace(/"/g, """);
|
||||
const tpAttr = esc(String(tpsl.tp)).replace(/"/g, """);
|
||||
const mktAttrs = marketOpenBtnAttrs(exchangeId, exchangeKey, x.symbol, x, monitorOrder, trendPlan);
|
||||
const symBeBadge = beSecured ? ` ${breakevenBadgeHtml()}` : "";
|
||||
return `<div class="pos-block">
|
||||
<div class="table-scroll">
|
||||
<table class="data-table"><thead><tr><th>合约</th><th>方向</th><th>张数</th><th>浮盈</th><th>操作</th></tr></thead><tbody>
|
||||
<tr>
|
||||
<td><button type="button" class="btn-open-market sym-link" ${mktAttrs} title="打开行情区(含入场/止盈止损)">${esc(x.symbol)}</button></td>
|
||||
<td class="td-symbol"><button type="button" class="btn-open-market sym-link" ${mktAttrs} title="打开行情区(含入场/止盈止损)">${esc(x.symbol)}</button>${symBeBadge}</td>
|
||||
<td class="${sideDirCls(x.side)}">${renderDirectionHtml(x.side)}</td>
|
||||
<td>${fmt(x.contracts, 4)}</td>
|
||||
<td class="${pnlCls(x.unrealized_pnl)}">${fmt(x.unrealized_pnl, 2)}</td>
|
||||
|
||||
Reference in New Issue
Block a user