Use bid1-only option closes with hard-disabled market exits.
Manual close checks liquidity only; target auto still requires 2x recycle hold once, then reuses the shared bid1 executor. Add /options/guide doc and update hedge-plan refs. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,7 +5,7 @@ from typing import Any
|
||||
|
||||
from lib.options.options_db import init_options_tables
|
||||
from lib.options.options_history_lib import enrich_position_row_display
|
||||
from lib.options.options_close_gate_lib import clear_close_gate, update_close_gate
|
||||
from lib.options.options_close_gate_lib import clear_close_gate, is_close_gate_passed, update_close_gate
|
||||
from lib.options.options_pricing_lib import estimate_close_by_bids, intrinsic_px_per_unit
|
||||
|
||||
|
||||
@@ -41,6 +41,7 @@ def attach_close_preview(
|
||||
_safe_float(row.get("strike") or row.get("stk")),
|
||||
_safe_float(row.get("idx_px") or row.get("idxPx")),
|
||||
)
|
||||
# 与实盘一致:只按买一估算本轮可平
|
||||
preview = estimate_close_by_bids(
|
||||
row["bid_depth"],
|
||||
target_sheets,
|
||||
@@ -48,23 +49,29 @@ def attach_close_preview(
|
||||
premium_paid=paid,
|
||||
mark_px=mark_px,
|
||||
intrinsic_px=intrinsic,
|
||||
max_levels=1,
|
||||
)
|
||||
# 残档时不累计 2×权利金门控;有效回收时刷新持续计时
|
||||
# 残档时不累计 2×门控;有效买一时刷新计时(仅自动平仓需要)
|
||||
if preview.get("bid_invalid") or preview.get("auto_close_blocked"):
|
||||
gate = update_close_gate(inst_id, recycle_usdc=None, premium_paid=paid)
|
||||
preview["close_gate"] = gate
|
||||
preview["close_gate_blocked"] = True
|
||||
preview["close_gate_msg"] = preview.get("bid_invalid_reason") or gate.get("msg")
|
||||
preview["manual_close_blocked"] = True
|
||||
preview["liquidity_ok"] = False
|
||||
else:
|
||||
gate = update_close_gate(
|
||||
inst_id,
|
||||
recycle_usdc=_safe_float(preview.get("total_received")),
|
||||
premium_paid=paid,
|
||||
)
|
||||
passed = bool(gate.get("passed") or is_close_gate_passed(inst_id) or gate.get("ready"))
|
||||
preview["close_gate"] = gate
|
||||
preview["close_gate_blocked"] = not gate.get("ready")
|
||||
preview["close_gate_blocked"] = not passed
|
||||
preview["close_gate_msg"] = gate.get("msg")
|
||||
if not gate.get("ready"):
|
||||
preview["manual_close_blocked"] = False
|
||||
preview["liquidity_ok"] = True
|
||||
if not passed:
|
||||
preview["auto_close_blocked"] = True
|
||||
row["close_preview"] = preview
|
||||
return row
|
||||
|
||||
Reference in New Issue
Block a user