diff --git a/lib/common/static/hedge_plan.js b/lib/common/static/hedge_plan.js index 7eace0d..7abe93b 100644 --- a/lib/common/static/hedge_plan.js +++ b/lib/common/static/hedge_plan.js @@ -149,6 +149,18 @@ return fmt(v, 2) + ":1"; } + function optionPrimaryLevOk(c, moneyKind) { + const idx = indexPx(); + const ask = Number(c && c.ask); + if (!(idx > 0) || !(ask > 0)) return true; + const kind = moneyKind || opMoneyKind(); + // 方案:杠杆门主要卡虚值;实/平列表不过滤,选用/启动再校验 + if (kind !== "otm") return true; + const minLev = numInput("hp-opt-leverage", 200); + const levFloor = Math.max(minLev, 180); + return idx / ask >= levFloor; + } + function matchesMoneyFilter(c) { const f = state.moneyFilter || "itm"; const m = (c.moneyness || "").toLowerCase(); @@ -159,10 +171,9 @@ if (idx && interval > 0 && Math.abs(Number(c.strike) - idx) > interval + 1e-9) { return false; } - const ask = Number(c.ask || 0); - const minLev = numInput("hp-opt-leverage", f === "otm" ? 200 : 100); - const levFloor = f === "otm" ? Math.max(minLev, 180) : minLev; - if (idx && ask > 0 && levFloor > 0 && idx / ask < levFloor) return false; + if (!optionPrimaryLevOk(c, f === "otm" ? "otm" : f === "atm" ? "atm" : "itm")) { + return false; + } } if (f === "itm") return m === "itm" || m === "atm"; if (f === "atm") return m === "atm"; @@ -1122,11 +1133,32 @@ tbody.innerHTML = '请选择到期日'; return; } - const list = (exp.contracts || []).filter(function (c) { - return String(c.opt_type || "").toUpperCase() === want && matchesMoneyFilter(c); + const sameType = (exp.contracts || []).filter(function (c) { + return String(c.opt_type || "").toUpperCase() === want; }); + const list = sameType.filter(matchesMoneyFilter); if (!list.length) { - tbody.innerHTML = '无匹配合约'; + const idx = indexPx(); + const interval = isOptionPrimary() ? numInput("hp-strike-interval", 15) : null; + let hint = "无匹配合约"; + if (isOptionPrimary() && sameType.length) { + hint = + "无匹配" + + (want === "C" ? "Call" : "Put") + + "(已滤 " + + sameType.length + + " 档)·检查间隔" + + (interval != null ? "≤" + interval : "") + + "点/虚实值" + + (state.moneyFilter === "otm" ? "/虚值杠杆门" : ""); + } else if (!sameType.length) { + hint = + "该到期无 " + + (want === "C" ? "Call" : "Put") + + (idx ? " · 指数 " + fmt(idx, 2) : "") + + " · 可换到期或点刷新链"; + } + tbody.innerHTML = '' + hint + ""; return; } list.forEach(function (c) { diff --git a/lib/hedge_plan/templates/hedge_plan_panel.html b/lib/hedge_plan/templates/hedge_plan_panel.html index 866643d..1f115c1 100644 --- a/lib/hedge_plan/templates/hedge_plan_panel.html +++ b/lib/hedge_plan/templates/hedge_plan_panel.html @@ -368,4 +368,4 @@ - +