diff --git a/lib/common/static/instance_theme.css b/lib/common/static/instance_theme.css index d090b07..95c4f41 100644 --- a/lib/common/static/instance_theme.css +++ b/lib/common/static/instance_theme.css @@ -3034,6 +3034,7 @@ html[data-theme="light"] .opt-be-dist-down { .options-chain-toolbar .btn-secondary.active, .opt-uly-btn.active, .opt-type-btn.active, +.opt-money-btn.active, .opt-pos-tab.active { border-color: #5b8cff; color: #cfe0ff; @@ -3681,6 +3682,7 @@ html[data-theme="light"] .options-page-wrap .options-stat-item .v { html[data-theme="light"] .options-chain-toolbar .btn-secondary.active, html[data-theme="light"] .opt-uly-btn.active, html[data-theme="light"] .opt-type-btn.active, +html[data-theme="light"] .opt-money-btn.active, html[data-theme="light"] .opt-pos-tab.active { border-color: rgba(0, 95, 140, 0.45) !important; color: #004d6e !important; diff --git a/lib/common/static/options_panel.js b/lib/common/static/options_panel.js index b30f9b7..241353a 100644 --- a/lib/common/static/options_panel.js +++ b/lib/common/static/options_panel.js @@ -11,6 +11,7 @@ const state = { underlying: root.dataset.defaultUnderly || "ETH", optType: "C", + moneyFilter: "itm", chain: panelCache.chain || null, selectedInst: null, orderQuote: null, @@ -116,6 +117,22 @@ return url; } + function matchesMoneyFilter(moneyness) { + const m = (moneyness || "").toLowerCase(); + if (state.moneyFilter === "otm") return m === "otm"; + return m === "itm" || m === "atm"; + } + + function moneyFilterLabel() { + return state.moneyFilter === "otm" ? "虚值" : "实值"; + } + + function filterChainContracts(contracts) { + return (contracts || []).filter(function (c) { + return c.opt_type === state.optType && matchesMoneyFilter(c.moneyness); + }); + } + function moneynessBadge(c) { const m = (c && c.moneyness) || ""; const label = (c && c.moneyness_label) || "—"; @@ -145,7 +162,7 @@ exps.forEach(function (e) { const o = document.createElement("option"); o.value = String(e.exp_time); - o.textContent = expLabel(e.exp_time) + " (" + e.contracts.length + ")"; + o.textContent = expLabel(e.exp_time) + " (" + filterChainContracts(e.contracts).length + ")"; sel.appendChild(o); }); const idx = state.chain && state.chain.index_px; @@ -155,7 +172,7 @@ if (el) el.textContent = String(Math.round(dte)); } document.getElementById("opt-index-line").textContent = - "指数 " + state.underlying + " ≈ " + fmt(idx, 2) + " · 实值=价内 · 虚值=价外"; + "指数 " + state.underlying + " ≈ " + fmt(idx, 2) + " · 实值含平值 · 虚值=价外"; } function fmtPxSz(px, sz, estimated) { @@ -286,11 +303,9 @@ return String(e.exp_time) === String(expMs); }); if (!exp) return; - const list = (exp.contracts || []).filter(function (c) { - return c.opt_type === state.optType; - }); + const list = filterChainContracts(exp.contracts); if (!list.length) { - tbody.innerHTML = '该到期日暂无报价'; + tbody.innerHTML = '该到期日暂无' + moneyFilterLabel() + "合约"; state.selectedInst = null; return; } @@ -805,6 +820,17 @@ document.querySelectorAll(".opt-type-btn").forEach(function (b) { b.classList.remove("active"); }); btn.classList.add("active"); state.optType = btn.getAttribute("data-type"); + renderExpiries(); + renderStrikes(); + }); + }); + + document.querySelectorAll(".opt-money-btn").forEach(function (btn) { + btn.addEventListener("click", function () { + document.querySelectorAll(".opt-money-btn").forEach(function (b) { b.classList.remove("active"); }); + btn.classList.add("active"); + state.moneyFilter = btn.getAttribute("data-money") || "itm"; + renderExpiries(); renderStrikes(); }); }); diff --git a/lib/options/templates/options_panel.html b/lib/options/templates/options_panel.html index 2b63d99..20f2998 100644 --- a/lib/options/templates/options_panel.html +++ b/lib/options/templates/options_panel.html @@ -14,6 +14,8 @@ + +
@@ -139,4 +141,4 @@ - +