Sell residual options at latest bid via IOC limit, not market.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -157,6 +157,36 @@ class OkxTradeClient:
|
||||
fill = self._wait_fill(inst_id, ord_id)
|
||||
return fill
|
||||
|
||||
def place_ioc(
|
||||
self,
|
||||
*,
|
||||
inst_id: str,
|
||||
side: str, # buy|sell
|
||||
sz: str,
|
||||
px: float | str,
|
||||
td_mode: str,
|
||||
pos_side: str | None = None,
|
||||
reduce_only: bool = False,
|
||||
) -> LiveFill:
|
||||
"""限价 IOC:残留回收等场景按指定买一/卖一吃单,不成交部分立即取消。"""
|
||||
body: dict[str, Any] = {
|
||||
"instId": inst_id,
|
||||
"tdMode": td_mode,
|
||||
"side": side,
|
||||
"ordType": "ioc",
|
||||
"sz": str(sz),
|
||||
"px": str(px),
|
||||
}
|
||||
if pos_side:
|
||||
body["posSide"] = pos_side
|
||||
if reduce_only:
|
||||
body["reduceOnly"] = True
|
||||
rows = self._request("POST", "/api/v5/trade/order", body)
|
||||
if not rows:
|
||||
raise RuntimeError("OKX IOC 下单无返回")
|
||||
ord_id = str(rows[0].get("ordId") or "")
|
||||
return self._wait_fill(inst_id, ord_id)
|
||||
|
||||
def _fill_from_order_row(self, inst_id: str, ord_id: str, row: dict[str, Any]) -> LiveFill:
|
||||
avg = safe_float(row.get("avgPx")) or 0.0
|
||||
sz = safe_float(row.get("accFillSz")) or safe_float(row.get("sz")) or 0.0
|
||||
|
||||
Reference in New Issue
Block a user