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:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user