修复币本位平仓/到期后未自动卖回,并消除模拟盘卖币时数据库锁定。

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-10-07 10:47:25 +08:00
parent 474e0742f7
commit 265317672c
6 changed files with 156 additions and 4 deletions
+19
View File
@@ -829,6 +829,25 @@ class SimBroker:
forget_close_gate_for_inst(inst_id)
except Exception:
pass
try:
from lib.options.options_margin_mode_lib import margin_mode_from_inst_id
from lib.options.options_spot_bridge_lib import sell_residual_after_option_flat
if margin_mode_from_inst_id(inst_id) == "coin":
uly = inst_id.split("-")[0].upper() if "-" in inst_id else "ETH"
conn_s = self.get_db()
try:
sell_residual_after_option_flat(
conn_s,
exchange,
underlying=uly,
inst_id=inst_id,
)
conn_s.commit()
finally:
conn_s.close()
except Exception:
pass
settled.append(
{
"inst_id": inst_id,