Tighten options position bar grouping and compact history table status layout.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -482,10 +482,10 @@
|
||||
'<button type="button" class="opt-pos-bar" aria-expanded="' + (expanded ? "true" : "false") + '">' +
|
||||
'<span class="opt-pos-bar-main">' +
|
||||
'<span class="opt-pos-bar-chevron" aria-hidden="true">▶</span>' +
|
||||
'<span class="opt-pos-bar-id-group">' +
|
||||
'<strong class="opt-pos-bar-title" title="' + inst + '">' + inst + "</strong>" +
|
||||
'<span class="pos-side-badge ' + sideCls + '">' + optTypeLabel(p.opt_type) + "</span>" +
|
||||
'<span class="opt-pos-bar-meta">行权 ' + fmt(p.strike, 0) + " · " + fmt(p.pos, 0) + "张</span>" +
|
||||
"</span>" +
|
||||
"</span></span>" +
|
||||
'<span class="opt-pos-bar-side">' +
|
||||
(expAttr
|
||||
? '<span class="opt-pos-bar-cd"><span class="opt-expiry-cd" data-opt-exp-ms="' + expAttr + '">—</span></span>'
|
||||
@@ -659,6 +659,15 @@
|
||||
return "已平";
|
||||
}
|
||||
|
||||
function optHistoryStatusHtml(h) {
|
||||
const s = optHistoryStatus(h);
|
||||
let cls = "opt-hist-status";
|
||||
if (s === "已平") cls += " opt-hist-status--closed";
|
||||
else if (s === "到期") cls += " opt-hist-status--expired";
|
||||
else cls += " opt-hist-status--open";
|
||||
return '<span class="' + cls + '">' + s + "</span>";
|
||||
}
|
||||
|
||||
async function refreshHistory() {
|
||||
const d = await apiJson("/api/options/history");
|
||||
const tbody = document.getElementById("opt-history-tbody");
|
||||
@@ -671,16 +680,18 @@
|
||||
list.forEach(function (h) {
|
||||
const tr = document.createElement("tr");
|
||||
const prem = h.status === "closed" ? h.premium_received : h.premium_paid;
|
||||
const premTxt = prem != null ? fmt(prem, 2) : "—";
|
||||
const pnl = h.realized_pnl;
|
||||
const pnlTxt = pnl != null ? fmt(pnl, 2) : "—";
|
||||
const pnlCls = pnl > 0 ? "pos-pnl-profit" : pnl < 0 ? "pos-pnl-loss" : "";
|
||||
const timeTxt = (h.closed_at || h.created_at || "—").replace("T", " ").slice(0, 19);
|
||||
tr.innerHTML =
|
||||
"<td><code>" + (h.inst_id || "") + "</code></td>" +
|
||||
'<td class="opt-hist-inst"><code>' + (h.inst_id || "") + "</code></td>" +
|
||||
"<td>" + fmt(h.sheets, 0) + "</td>" +
|
||||
"<td>" + fmt(prem, 4) + "</td>" +
|
||||
"<td>" + optHistoryStatus(h) + "</td>" +
|
||||
"<td>" + premTxt + "</td>" +
|
||||
"<td>" + optHistoryStatusHtml(h) + "</td>" +
|
||||
'<td class="' + pnlCls + '">' + pnlTxt + "</td>" +
|
||||
"<td>" + (h.closed_at || h.created_at || "—") + "</td>" +
|
||||
"<td class=\"opt-hist-time\">" + timeTxt + "</td>" +
|
||||
'<td><button type="button" class="btn-secondary btn-sm opt-history-del" data-id="' + h.id + '" data-status="' + (h.status || "") + '">删除</button></td>';
|
||||
tbody.appendChild(tr);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user