修复模拟盘卖币握锁导致 database is locked 与中控超时离线。
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -464,17 +464,12 @@ def maybe_sell_spot_after_close(
|
||||
pass
|
||||
parts = inst_id.split("-")
|
||||
underlying = (parts[0] if parts else "ETH").upper()
|
||||
conn = cfg["get_db"]()
|
||||
try:
|
||||
from lib.options.options_db import init_options_tables
|
||||
|
||||
init_options_tables(conn)
|
||||
return _spot_bridge.sell_residual_after_option_flat(conn, ex, underlying=underlying, inst_id=inst_id)
|
||||
finally:
|
||||
try:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
return _spot_bridge.sell_residual_after_option_flat(
|
||||
cfg["get_db"],
|
||||
ex,
|
||||
underlying=underlying,
|
||||
inst_id=inst_id,
|
||||
)
|
||||
|
||||
|
||||
def sweep_spot_after_options_flat(
|
||||
@@ -506,8 +501,6 @@ def sweep_spot_after_options_flat(
|
||||
except Exception as e:
|
||||
return {"ok": False, "msg": f"持仓查询失败: {e}"}
|
||||
|
||||
from lib.options.options_db import init_options_tables
|
||||
|
||||
sold: list[dict[str, Any]] = []
|
||||
for uly in ("BTC", "ETH"):
|
||||
if uly in live_uly:
|
||||
@@ -518,22 +511,14 @@ def sweep_spot_after_options_flat(
|
||||
continue
|
||||
except Exception:
|
||||
continue
|
||||
conn = cfg["get_db"]()
|
||||
try:
|
||||
init_options_tables(conn)
|
||||
out = _spot_bridge.sell_residual_after_option_flat(
|
||||
conn, exchange, underlying=uly, inst_id=None
|
||||
cfg["get_db"],
|
||||
exchange,
|
||||
underlying=uly,
|
||||
inst_id=None,
|
||||
)
|
||||
sold.append({"underlying": uly, **(out or {})})
|
||||
try:
|
||||
conn.commit()
|
||||
except Exception:
|
||||
pass
|
||||
except Exception as e:
|
||||
sold.append({"underlying": uly, "ok": False, "msg": str(e)})
|
||||
finally:
|
||||
try:
|
||||
conn.close()
|
||||
except Exception:
|
||||
pass
|
||||
return {"ok": True, "results": sold, "skipped": not sold}
|
||||
|
||||
Reference in New Issue
Block a user