Add index-over-ask leverage column to options chain list.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-01 10:26:11 +08:00
parent f6ea0dc399
commit 747434a65e
5 changed files with 32 additions and 5 deletions
+9
View File
@@ -3138,6 +3138,15 @@ html[data-theme="light"] .settings-side-export-label {
font-variant-numeric: tabular-nums;
white-space: nowrap;
}
.opt-chain-lev {
font-variant-numeric: tabular-nums;
white-space: nowrap;
font-weight: 600;
color: #b8c8ff;
}
html[data-theme="light"] .opt-chain-lev {
color: #1a4a8a;
}
.opt-be-dist-up {
color: #5ee89a;
}
+18 -1
View File
@@ -341,7 +341,7 @@
}
function strikeTableColspan() {
return state.chainView === "t" ? 9 : 8;
return 9;
}
function syncChainViewUI() {
@@ -817,6 +817,20 @@
return "约 " + Number(v).toFixed(1) + "×";
}
/** 链上展示:指数 ÷ 卖一(每1币). */
function calcAskLeverage(indexPx, askPx) {
if (indexPx == null || askPx == null) return null;
const idx = Number(indexPx);
const ask = Number(askPx);
if (!Number.isFinite(idx) || !Number.isFinite(ask) || ask <= 0) return null;
return Math.round((idx / ask) * 10) / 10;
}
function fmtChainLeverage(v) {
if (v === null || v === undefined || Number.isNaN(Number(v))) return "—";
return Number(v).toFixed(1) + "×";
}
function fmtUsdcSigned(v) {
if (v === null || v === undefined || Number.isNaN(Number(v))) return "—";
const n = Number(v);
@@ -946,16 +960,19 @@
return;
}
let matchedSelected = false;
const indexPx = state.chain && state.chain.index_px;
list.forEach(function (c) {
const tr = document.createElement("tr");
tr.className = "opt-strike-row";
tr.setAttribute("data-inst", c.inst_id);
if (c.moneyness) tr.classList.add("opt-row-" + c.moneyness);
const chainLev = calcAskLeverage(indexPx, c.ask);
tr.innerHTML =
"<td>" + c.strike + "</td>" +
"<td>" + moneynessBadge(c) + "</td>" +
"<td><code>" + c.inst_id + "</code></td>" +
"<td class=\"opt-px-sz\">" + fmtPxSz(c.ask, c.ask_sz, c.ask_estimated) + "</td>" +
'<td class="opt-chain-lev">' + fmtChainLeverage(chainLev) + "</td>" +
"<td class=\"opt-px-sz\">" + fmtPxSz(c.bid, c.bid_sz) + "</td>" +
"<td>" + (c.expiry_be_px != null ? fmt(c.expiry_be_px, 0) : "—") + "</td>" +
'<td class="' + distBeClass(c.dist_expiry_be) + '">' + fmtDist(c.dist_expiry_be) + "</td>" +