diff --git a/lib/common/static/options_panel.js b/lib/common/static/options_panel.js index 0898c9d..1bdfed0 100644 --- a/lib/common/static/options_panel.js +++ b/lib/common/static/options_panel.js @@ -866,10 +866,12 @@ return ( '
' + '委托' + - '' + + '' + '' + '" + - '' + (armed ? "监控中 · 达价限价平 · 无止损" : "达价限价平 · 无止损 · 到期即止损") + "" + + '' + + (armed ? "监控中 · 到位按买一限价平 · 无止损" : "目标=监控指数 · 到位按买一限价平 · 到期即止损") + + "" + "
" ); } diff --git a/lib/common/static/options_position_cards.js b/lib/common/static/options_position_cards.js index 8cc7308..cf64c96 100644 --- a/lib/common/static/options_position_cards.js +++ b/lib/common/static/options_position_cards.js @@ -115,7 +115,7 @@ '
按买盘回收' + fmtClosePreview(closePreview, p.premium_paid, hub) + "
" + "" + (p.target_index != null - ? '
委托目标指数 ' + fmt(p.target_index, 1) + "监控中 · 达价限价平
" + ? '
委托目标指数 ' + fmt(p.target_index, 1) + "监控中 · 到位按买一限价平
" : "") ); } diff --git a/lib/options/options_target_lib.py b/lib/options/options_target_lib.py index d526803..ae2853b 100644 --- a/lib/options/options_target_lib.py +++ b/lib/options/options_target_lib.py @@ -1,4 +1,4 @@ -"""期权目标位委托:指数达价后限价平仓(无止损,到期由结算收口).""" +"""期权目标位委托:指数目标价仅用于监控触发;触发后按买一限价平仓(无止损,到期结算).""" from __future__ import annotations import sqlite3 @@ -214,7 +214,7 @@ def close_option_by_bid_depth( *, sheets: int | None = None, ) -> dict[str, Any]: - """按买盘拆分限价卖出(最多5档),供目标位自动平仓复用.""" + """目标触发后仅用买一/买盘限价卖出(最多5档);无买一则等待下次轮询,不用标记价.""" from lib.exchange.okx_options_lib import ( _pos_side_from_position, invalidate_option_positions_cache, @@ -301,22 +301,13 @@ def close_option_by_bid_depth( preview = estimate_close_by_bids(book.get("bids") or [], remaining, ct_mult=ct_mult) levels = preview.get("levels") or [] if not levels: - # 无买盘时回退:报价买一 → 报价标记价 → 持仓标记价 + # 无买盘深度时仅允许真实买一价,不用标记价挂单 q2 = cfg["quote_option_contract"](ex, inst_id) - cur_mark = _safe_float(cur_pos.get("markPx")) if cur_pos else None - pos_mark = _safe_float(pos.get("markPx")) - fallback_px = ( - _safe_float(q2.get("bid")) - or _safe_float(q2.get("mark_px")) - or _safe_float(q.get("bid")) - or _safe_float(q.get("mark_px")) - or cur_mark - or pos_mark - ) - if fallback_px is None or fallback_px <= 0: - stopped_reason = "no_bid_depth" + bid_px = _safe_float(q2.get("bid")) or _safe_float(q.get("bid")) + if bid_px is None or bid_px <= 0: + stopped_reason = "no_bid" break - levels = [{"sheets": remaining, "px": fallback_px, "fallback": True}] + levels = [{"sheets": remaining, "px": bid_px}] level = levels[0] level_sheets = int(level.get("sheets") or 0) level_px = float(level.get("px") or 0) @@ -386,7 +377,11 @@ def close_option_by_bid_depth( "fully_closed": True, } return {"ok": False, "msg": mkt.get("msg") or "市价平仓失败", "stopped_reason": stopped_reason} - return {"ok": False, "msg": "暂无可用买盘深度,无法限价平仓", "stopped_reason": stopped_reason} + return { + "ok": False, + "msg": "暂无买一,等待盘口后按买一限价平仓", + "stopped_reason": stopped_reason or "no_bid", + } avg_bid = (total_received / (submitted_sheets * ct_mult)) if submitted_sheets > 0 and ct_mult > 0 else 0 prem_recv = round(total_received, 4) diff --git a/lib/options/templates/options_panel.html b/lib/options/templates/options_panel.html index 760a1a7..494663c 100644 --- a/lib/options/templates/options_panel.html +++ b/lib/options/templates/options_panel.html @@ -87,7 +87,7 @@ 目标杠杆 - 填写后进入右侧监控;达价限价平仓,无止损,到期即止损 + 目标价=监控指数;到位后按买一限价平仓;无止损,到期即止损