Restore position type badges; hide empty perp/options sections.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -159,15 +159,27 @@
|
||||
return { perp: perp, options: options };
|
||||
}
|
||||
|
||||
function sourceBadgeClass(source) {
|
||||
const s = String(source || "");
|
||||
if (s.indexOf("对冲") >= 0) return "is-hedge";
|
||||
if (s.indexOf("纯期权") >= 0 || s === "期权") return "is-opt";
|
||||
if (s.indexOf("顺势") >= 0) return "is-roll";
|
||||
if (s.indexOf("趋势") >= 0) return "is-trend";
|
||||
if (s.indexOf("关键位") >= 0) return "is-key";
|
||||
if (s.indexOf("下单") >= 0) return "is-order";
|
||||
return "is-none";
|
||||
}
|
||||
|
||||
function sourceTypeCell(source) {
|
||||
const s = String(source || "—");
|
||||
return `<span class="dash-pos-source ${sourceBadgeClass(s)}">${esc(s)}</span>`;
|
||||
}
|
||||
|
||||
function renderUnifiedPerpTable(rows) {
|
||||
if (!rows.length) {
|
||||
return `<div class="dash-pos-block">
|
||||
<div class="dash-ac-section-label">永续持仓</div>
|
||||
<div class="dash-empty dash-empty-inline">当前无永续持仓</div>
|
||||
</div>`;
|
||||
}
|
||||
if (!rows.length) return "";
|
||||
const body = rows
|
||||
.map(({ ac, ln }) => {
|
||||
const source = String((ln && ln.source) || "—");
|
||||
const symbol = esc((ln && (ln.symbol || ln.text)) || "—");
|
||||
const side = esc((ln && ln.side) || "—");
|
||||
const contracts =
|
||||
@@ -176,6 +188,7 @@
|
||||
const pct = floatPctText(pnl, ln && ln.notional_usdt);
|
||||
return `<tr>
|
||||
<td>${exchangeLinkCell(ac)}</td>
|
||||
<td>${sourceTypeCell(source)}</td>
|
||||
<td>${symbol}</td>
|
||||
<td>${side}</td>
|
||||
<td>${priceCell(ln && ln.entry_price_fmt, ln && ln.entry_price)}</td>
|
||||
@@ -191,7 +204,7 @@
|
||||
<div class="dash-table-wrap">
|
||||
<table class="dash-table dash-pos-table">
|
||||
<thead><tr>
|
||||
<th>交易所</th><th>合约</th><th>方向</th><th>开仓价</th><th>标记价</th><th>张数</th><th>盈利金额</th><th>浮盈</th>
|
||||
<th>交易所</th><th>类型</th><th>合约</th><th>方向</th><th>开仓价</th><th>标记价</th><th>张数</th><th>盈利金额</th><th>浮盈</th>
|
||||
</tr></thead>
|
||||
<tbody>${body}</tbody>
|
||||
</table>
|
||||
@@ -214,12 +227,7 @@
|
||||
}
|
||||
|
||||
function renderUnifiedOptionsTable(rows) {
|
||||
if (!rows.length) {
|
||||
return `<div class="dash-pos-block dash-options-block">
|
||||
<div class="dash-ac-section-label">期权持仓</div>
|
||||
<div class="dash-empty dash-empty-inline">当前无期权持仓</div>
|
||||
</div>`;
|
||||
}
|
||||
if (!rows.length) return "";
|
||||
const body = rows
|
||||
.map(({ ac, p }) => {
|
||||
const optType =
|
||||
@@ -228,11 +236,13 @@
|
||||
: (p.opt_type || "").toUpperCase() === "P"
|
||||
? "Put"
|
||||
: p.opt_type || "—";
|
||||
const source = String(p.source_label || p.source || "纯期权");
|
||||
const target = String(p.target_monitor_text || "—");
|
||||
const targetCls = target && target !== "—" ? "dash-target-monitor is-on" : "dash-target-monitor";
|
||||
const net = optionsNetPnl(p);
|
||||
return `<tr>
|
||||
<td>${exchangeLinkCell(ac)}</td>
|
||||
<td>${sourceTypeCell(source)}</td>
|
||||
<td title="${esc(p.inst_id || "")}">${esc(shortDashInst(p.inst_id))}</td>
|
||||
<td>${esc(optType)}</td>
|
||||
<td>${dashOptionsExpiryCd(p.exp_time_ms != null ? p.exp_time_ms : p.exp_time)}</td>
|
||||
@@ -247,7 +257,7 @@
|
||||
<div class="dash-table-wrap dash-options-table-wrap">
|
||||
<table class="dash-table dash-options-table">
|
||||
<thead><tr>
|
||||
<th>交易所</th><th>合约</th><th>类型</th><th>到期倒计时</th><th>指数</th><th>目标监控</th><th>净盈亏</th>
|
||||
<th>交易所</th><th>类型</th><th>合约</th><th>Call/Put</th><th>到期倒计时</th><th>指数</th><th>目标监控</th><th>净盈亏</th>
|
||||
</tr></thead>
|
||||
<tbody>${body}</tbody>
|
||||
</table>
|
||||
@@ -269,7 +279,9 @@
|
||||
|
||||
function renderAccounts(accounts, threshold) {
|
||||
const unified = collectUnifiedPositions(accounts);
|
||||
if (!unified.perp.length && !unified.options.length) {
|
||||
const perpHtml = renderUnifiedPerpTable(unified.perp);
|
||||
const optionsHtml = renderUnifiedOptionsTable(unified.options);
|
||||
if (!perpHtml && !optionsHtml) {
|
||||
elAccounts.innerHTML = '<div class="dash-empty">当前无持仓账户</div>';
|
||||
return;
|
||||
}
|
||||
@@ -281,8 +293,8 @@
|
||||
: "";
|
||||
elAccounts.innerHTML = `<article class="dash-ac-card dash-pos-unified-card">
|
||||
<div class="dash-ac-pos-body">
|
||||
${renderUnifiedPerpTable(unified.perp)}
|
||||
${renderUnifiedOptionsTable(unified.options)}
|
||||
${perpHtml}
|
||||
${optionsHtml}
|
||||
${alertNote}
|
||||
</div>
|
||||
</article>`;
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
<link rel="stylesheet" href="/assets/trade_stats_calendar.css?v=4" />
|
||||
<link rel="stylesheet" href="/assets/account_risk_badge.css?v=4" />
|
||||
<script src="/assets/account_risk_badge.js?v=4"></script>
|
||||
<link rel="stylesheet" href="/assets/dashboard.css?v=20260720-dash-pos-unified" />
|
||||
<link rel="stylesheet" href="/assets/dashboard.css?v=20260720-dash-pos-type" />
|
||||
</head>
|
||||
<body>
|
||||
<div class="app-bg" aria-hidden="true"></div>
|
||||
@@ -1385,7 +1385,7 @@
|
||||
<script src="/assets/archive.js?v=20260717-archive-cal-chart"></script>
|
||||
<script src="/assets/quotes.js?v=20260717-quotes-feed"></script>
|
||||
<script src="/assets/funds.js?v=20260717-funds-scroll-fix"></script>
|
||||
<script src="/assets/dashboard.js?v=20260720-dash-pos-unified"></script>
|
||||
<script src="/assets/dashboard.js?v=20260720-dash-pos-type"></script>
|
||||
<script src="/assets/strategy.js?v=8"></script>
|
||||
<script src="/assets/help.js?v=1"></script>
|
||||
<script src="/assets/logs.js?v=1"></script>
|
||||
|
||||
Reference in New Issue
Block a user