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

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
+10
View File
@@ -276,6 +276,11 @@ def rollback_bought_coin_to_usdt(
) -> dict[str, Any]:
"""买币后开期权失败:卖回 USDT 并关闭桥.卖光交易户可用标的币."""
_ = coin_amount # 兼容旧签名;定量以交易户可用为准
# 卖币(模拟盘)会另开连接写钱包,须先释放本连接事务锁
try:
conn.commit()
except Exception:
pass
sell = spot_market_sell_coin_to_usdt(ex, underlying=underlying)
if not sell.get("ok"):
update_bridge(
@@ -313,6 +318,11 @@ def sell_residual_after_option_flat(
if not underlying or str(b.get("underlying") or "").upper() == underlying.upper():
target = b
break
# 卖币(模拟盘)会另开连接写钱包,须先释放本连接事务锁,否则 database is locked
try:
conn.commit()
except Exception:
pass
sell = spot_market_sell_coin_to_usdt(ex, underlying=underlying)
if target is None:
if not sell.get("ok"):