fix(options): expose chain DTE in env UI and show nearest expiries for OO

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-08-10 17:54:03 +08:00
parent a90876d772
commit 860ebef4a7
6 changed files with 45 additions and 16 deletions
+14 -9
View File
@@ -1120,12 +1120,17 @@
if (!sel) return;
const prev = sel.value;
const isPoSel = sel.id === "hp-exp-select";
// 永期以期权为主:到期下拉按「最低剩余小时」过滤;期期下拉不过滤,保证明天到期可见
const minH = isPoSel && isOptionPrimary() ? numInput("hp-min-hours", 36) : 0;
sel.innerHTML = '<option value="">选择到期日</option>';
let firstOk = null;
let skippedNear = 0;
(chain.expiries || []).forEach(function (e) {
const h = hoursFromExpMs(e.exp_time);
if (minH > 0 && h != null && h < minH) return;
if (minH > 0 && h != null && h < minH) {
skippedNear += 1;
return;
}
const opt = document.createElement("option");
opt.value = String(e.exp_time);
const dt = new Date(Number(e.exp_time) < 1e12 ? Number(e.exp_time) * 1000 : Number(e.exp_time));
@@ -1137,18 +1142,18 @@
if (!sel.value && firstOk) {
sel.value = String(firstOk.exp_time);
}
if (isPoSel && skippedNear > 0 && minH > 0) {
const tip = document.createElement("option");
tip.disabled = true;
tip.textContent = "(已隐藏 " + skippedNear + " 个不足 " + minH + "h 的到期 · 可改左侧最低剩余小时)";
sel.appendChild(tip);
}
}
async function loadChain() {
let url =
// 拉完整链(按 CHAIN_MAX_DTE);永期「最低剩余小时」只在左侧到期下拉里过滤,不影响期期看到明天到期
const url =
"/api/hedge-plan/options-chain?underlying=" + encodeURIComponent(state.underlying);
if (isOptionPrimary()) {
url +=
"&option_primary=1&min_hours=" +
encodeURIComponent(String(numInput("hp-min-hours", 36))) +
"&strike_interval=" +
encodeURIComponent(String(numInput("hp-strike-interval", 15)));
}
const d = await apiJson(url);
state.chain = d;
const idx = $("hp-index-line");