Fix OKX abandon residual double-book and fill/residual ledger holes.
After dual-close leaves option pending, continue close_group instead of false residual; reject partial fills on wait timeout; LIVE residual settle allow_negative. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -191,15 +191,13 @@ class OkxTradeClient:
|
||||
if state in ("canceled", "failed"):
|
||||
raise RuntimeError(f"OKX 订单失败 state={state} {last}")
|
||||
time.sleep(0.3)
|
||||
# 超时兜底:已 filled 或已有成交量+均价则回填,避免「有仓无账」
|
||||
# 超时兜底:仅接受完全成交;部分成交不得当全成记账(会错张数/对冲)
|
||||
state = str(last.get("state") or "")
|
||||
avg = safe_float(last.get("avgPx"))
|
||||
acc = safe_float(last.get("accFillSz")) or 0.0
|
||||
if state == "filled" or (acc > 0 and avg and avg > 0):
|
||||
if state == "filled" and avg and avg > 0:
|
||||
logger.warning(
|
||||
"OKX fill wait timeout but using last fill data ordId=%s state=%s",
|
||||
"OKX fill wait timeout but order filled ordId=%s",
|
||||
ord_id,
|
||||
state,
|
||||
)
|
||||
return self._fill_from_order_row(inst_id, ord_id, last)
|
||||
raise RuntimeError(f"OKX 订单未完全成交 ordId={ord_id} last={last}")
|
||||
|
||||
Reference in New Issue
Block a user