From 6ab27cebcde0363efe2d9b8f06f03952bf0ae146 Mon Sep 17 00:00:00 2001 From: dekun Date: Sun, 9 Aug 2026 09:18:36 +0800 Subject: [PATCH] fix(hedge): show option list by interval; leverage only at start Keep capital/select params on one row, reload chain when interval changes, and stop filtering the chain by option leverage. Co-authored-by: Cursor --- lib/common/static/hedge_plan.js | 42 ++++++++----------- lib/common/static/instance_theme.css | 31 ++++++++++++-- .../templates/hedge_plan_panel.html | 12 +++--- 3 files changed, 52 insertions(+), 33 deletions(-) diff --git a/lib/common/static/hedge_plan.js b/lib/common/static/hedge_plan.js index 2f96525..de1a7ff 100644 --- a/lib/common/static/hedge_plan.js +++ b/lib/common/static/hedge_plan.js @@ -149,31 +149,17 @@ 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(); if (!isOptionPrimary() && f === "otm") return false; + // 列表只按间隔+虚实值;期权杠杆仅启动/计算时由后端校验 if (isOptionPrimary()) { const idx = indexPx(); const interval = numInput("hp-strike-interval", 15); if (idx && interval > 0 && Math.abs(Number(c.strike) - idx) > interval + 1e-9) { 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"; @@ -441,7 +427,7 @@ updatePerpPnlHint(); } - /** 以期权为主:按类型/间隔/杠杆自动匹配最近合约. */ + /** 以期权为主:按类型/间隔自动匹配最近合约. */ function autoMatchPoOption(force) { if (!isOptionPrimary()) return; const want = optTypeForDirection(getDirection()); @@ -1111,7 +1097,7 @@ return; } if (isOptionPrimary() && !matchesMoneyFilter(c)) { - alert("不符合当前间隔/杠杆/虚实值过滤"); + alert("不符合当前间隔/虚实值过滤"); return; } state.selected = c; @@ -1163,8 +1149,7 @@ sameType.length + " 档)·检查间隔" + (interval != null ? "≤" + interval : "") + - "点/虚实值" + - (state.moneyFilter === "otm" ? "/虚值杠杆门" : ""); + "点/虚实值"; } else if (!sameType.length) { hint = "该到期无 " + @@ -1759,7 +1744,6 @@ if ($("hp-opt-leverage")) { $("hp-opt-leverage").addEventListener("input", function () { state.opLevTouched = true; - renderListStrikes(); }); } if ($("hp-opt-perp-ratio")) { @@ -1772,14 +1756,24 @@ void loadMarket(); }); } + let _poChainReloadTimer = null; + function schedulePoChainReload() { + if (_poChainReloadTimer) clearTimeout(_poChainReloadTimer); + _poChainReloadTimer = setTimeout(function () { + _poChainReloadTimer = null; + void loadChain(); + }, 350); + } ["hp-premium-budget", "hp-strike-interval", "hp-min-hours", "hp-opt-target-pts", "hp-perp-target-pts"].forEach( function (id) { const el = $(id); if (!el) return; el.addEventListener("input", function () { - if (id === "hp-min-hours" && state.chain) fillExpSelect($("hp-exp-select"), state.chain); - if (id === "hp-strike-interval" || id === "hp-premium-budget") renderListStrikes(); - if (state.selected && (id === "hp-premium-budget" || id === "hp-strike-interval")) { + if (id === "hp-min-hours" || id === "hp-strike-interval") { + schedulePoChainReload(); + } + if (id === "hp-premium-budget") renderListStrikes(); + if (state.selected && id === "hp-premium-budget") { const sized = computeOpSizing(state.selected.ask, state.selected.ct_mult || 0.01); if (sized && $("hp-sheets")) $("hp-sheets").value = String(sized.sheets); void loadMarket(); @@ -1805,7 +1799,7 @@ if (isOptionPrimary()) { autoMatchPoOption(true); if (!state.selected) { - alert("当前选约条件下无匹配合约,请调整类型/间隔/杠杆或换到期"); + alert("当前选约条件下无匹配合约,请调整类型/间隔或换到期"); } return; } diff --git a/lib/common/static/instance_theme.css b/lib/common/static/instance_theme.css index ba843ba..ceb377d 100644 --- a/lib/common/static/instance_theme.css +++ b/lib/common/static/instance_theme.css @@ -3511,13 +3511,38 @@ html[data-theme="light"] .opt-be-dist-down { .hedge-plan-page-wrap .hp-po-fields--section { margin: 0; } +.hedge-plan-page-wrap .hp-po-fields--capital { + grid-template-columns: repeat(3, minmax(0, 1fr)); +} +.hedge-plan-page-wrap .hp-po-fields--select { + grid-template-columns: minmax(72px, 0.9fr) minmax(72px, 0.9fr) minmax(0, 1.6fr) minmax(72px, 0.9fr); + align-items: end; +} .hedge-plan-page-wrap .hp-po-field--type { - grid-column: 1 / -1; + min-width: 0; } .hedge-plan-page-wrap .hp-po-type-seg { display: flex; - flex-wrap: wrap; - gap: 6px; + flex-wrap: nowrap; + gap: 4px; +} +.hedge-plan-page-wrap .hp-po-type-seg .hp-money-btn { + flex: 1 1 0; + padding: 4px 6px; + font-size: 0.72rem; + white-space: nowrap; +} +@media (max-width: 720px) { + .hedge-plan-page-wrap .hp-po-fields--capital, + .hedge-plan-page-wrap .hp-po-fields--select { + grid-template-columns: 1fr 1fr; + } + .hedge-plan-page-wrap .hp-po-field--type { + grid-column: 1 / -1; + } + .hedge-plan-page-wrap .hp-po-type-seg { + flex-wrap: wrap; + } } .hedge-plan-page-wrap .hp-po-right-stack { display: flex; diff --git a/lib/hedge_plan/templates/hedge_plan_panel.html b/lib/hedge_plan/templates/hedge_plan_panel.html index 1712324..b14e8be 100644 --- a/lib/hedge_plan/templates/hedge_plan_panel.html +++ b/lib/hedge_plan/templates/hedge_plan_panel.html @@ -90,7 +90,7 @@

资金与杠杆配置

-
+

选约条件

-
+
- +