Recover stuck opening and harden LIVE open/close reconcile.

Stamp open intent, recover opening from exchange option/perp state, skip resell/reopen when already flat, and persist Binance margin mode.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-29 20:32:45 +08:00
parent 44fd0371b9
commit e2a19a1614
8 changed files with 893 additions and 104 deletions
+29
View File
@@ -265,6 +265,35 @@ class OkxTradeClient:
return abs(float(pos))
return 0.0
def get_option_pos_sz(self, inst_id: str) -> float | None:
"""期权绝对持仓张数。"""
try:
rows = self._request(
"GET",
f"/api/v5/account/positions?instType=OPTION&instId={inst_id}",
)
except Exception as e:
logger.warning("okx get_option_pos_sz failed: %s", e)
return None
total = 0.0
for row in rows:
pos = safe_float(row.get("pos")) or 0.0
total += abs(float(pos))
return total
def any_option_pos_abs(self) -> float | None:
"""账户任意期权绝对持仓张数合计。"""
try:
rows = self._request("GET", "/api/v5/account/positions?instType=OPTION")
except Exception as e:
logger.warning("okx any_option_pos_abs failed: %s", e)
return None
total = 0.0
for row in rows:
pos = safe_float(row.get("pos")) or 0.0
total += abs(float(pos))
return total
def set_leverage(
self,
inst_id: str,