fix卖回VWAP必须落库并覆盖指数占位价,禁止预算反推开仓价。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-13 11:55:42 +08:00
parent dd979d9dd0
commit 11a083470d
7 changed files with 378 additions and 37 deletions
+10 -3
View File
@@ -495,9 +495,16 @@ def close_option_by_bid1(
row_budget = _safe_float(row["budget_usdt"])
row_open_idx = _safe_float(row["open_index_px"])
if (row_open_idx is None or row_open_idx <= 0) and row_budget and paid > 1e-12:
# 无开仓指数时用预算/已付反推
row_open_idx = float(row_budget) / paid
# 禁止 budget/premium 反推开仓价(会把缓冲算进均价,开仓价被抬飞)
if (row_open_idx is None or row_open_idx <= 0) and row.get("bridge_id") is not None:
try:
from lib.options.options_spot_bridge_lib import bridge_buy_vwap
bv = bridge_buy_vwap(conn, int(row["bridge_id"]))
if bv is not None and float(bv) > 0:
row_open_idx = float(bv)
except Exception:
pass
settled = settle_closed_pnl(
premium_paid=paid,
premium_received=recv,