跳到内容

交易

撤销订单

Cancellation is free, best-effort, and idempotent. Today you can cancel one order at a time per request. Bulk cancel — by ID list, by market, or account-wide — is planned; see the workaround below until it ships. A race window exists in all modes: in-flight fills committed before your cancel reaches the matcher will still complete.

撤销单笔订单

已知订单 ID 时使用 DELETE 方式。响应将确认撤单;重复调用 DELETE 是安全的。

POST /api/v1/orders/:id/cancel
Authorization: Bearer $SATORIEX_TOKEN

202 Accepted  -> { "code": 0, "data": { ...full order object with status "cancelled" } }

批量撤单

计划中

支持三种批量模式:指定 ID 列表、某市场所有订单,或紧急全撤——账户所有未成交订单。

在此期间,在客户端循环调用单笔撤单接口。撤单免费且快速,因此对未成交订单列表进行紧密循环适合紧急平仓。

# Today: cancel one order at a time.
for id in "${ORDER_IDS[@]}"; do
  curl -X POST https://staging.satoriex.io/api/v1/orders/$id/cancel \
    -H "Authorization: Bearer $SATORIEX_TOKEN"
done

紧急全撤有频率限制,每隔数秒才能使用一次——用于紧急平仓,不适合常规流程。

哪些订单可以撤销

订单状态可撤销?备注
pending Flagged for cancel; the matcher skips it on next processing — the order has not yet been added to the book.
open Resting in the book; cancel removes it immediately. This is the common cancel case.
partial 是(仅剩余部分) 已成交份额保留在仓位中;仅撤销未成交的剩余部分。
filled 已结算——无法操作。
cancelled 幂等 重复调用返回相同的成功响应。

撤单不可追溯

若撤单请求在撮合发生后一毫秒到达,则交易已完成。请将策略设计为能够容忍该窗口——在关键场景中使用 IOC 或 FOK 有效期类型。