交易API#
使指定 Nonce 失效 POST /trade/noop#
使指定 nonce 失效。
被取消的 action 可成功上链,但执行失败并返回错误码 30004。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | Object | 是 | Noop 动作。 |
| > type | String | 是 | 固定为 noop。 |
| nonce | Number | 是 | 待失效的 nonce。 |
| signature | Object | 是 | EIP-712 签名。 |
| > Ecdsa | Object | 是 | ECDSA 签名。 |
| >> r | String | 是 | 签名的 r 值,0x 开头的十六进制字符串。 |
| >> s | String | 是 | 签名的 s 值,0x 开头的十六进制字符串。 |
| >> v | Number | 是 | 签名恢复值。 |
请求示例
{
"action": {
"type": "noop"
},
"nonce": 1,
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
成功响应
成功时返回 code="0"、msg="" 和 data=[],表示指定 nonce 已失效,且无业务数据返回。
成功结果仅由本次 API Response 确认;不保证曾取消某笔 pending action,也不能回滚已执行的 action。
响应示例
{
"code": "0",
"msg": "",
"data": []
}
下单 POST /trade/place-order#
支持批量下单,单次最多 30 笔。
- 不支持按计价币直接下单;市价单使用 IOC 激进限价单模拟。
size小数位不得超过instruments.sizeDecimals;超出精度时链上校验失败。vaultAddress为可选信封字段:操作母账户时省略;操作子账户时填写子账户地址。user仍为母账户地址,签名者仍为母账户授权的 Agent。marginMode表示该assetId当前的保证金模式,不是每张订单可独立选择的模式。同一账户、同一assetId的所有仓位和订单使用相同marginMode,不允许cross与isolated并存。- 切换保证金模式前,须先完成
/account/set-margin-mode流程。
Request Query String 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| mode | String | 否 | 响应模式:sync 表示同步等待链上回执;async 表示受理后立即返回 txHash。默认值为 sync。仅影响响应形态,不参与签名、不改变链上行为,也不进入 EIP-712 签名。 |
Request Body 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | Object | 是 | 业务动作对象。本字段及其所有子字段均进入 EIP-712 签名;字段名为链上 canonical 名称,上线后固定。 |
| > type | String | 是 | 固定为 placeOrder。 |
| > grouping | String | 否,默认 na | na:独立订单或 Trigger 订单;orderTpsl:订单附带 TPSL;positionTpsl:持仓附带 TPSL。 |
| > orders | Array | 是 | 订单列表,不能为空。 |
| >> assetId | String | 是 | 复合资产 ID,内含市场类型。 |
| >> side | String | 是 | buy 或 sell。 |
| >> marketType | String 或 Object | 否 | 市场类型。spot 为字符串;perp 为对象,包含 marginMode 和 positionSide。 |
| >>> marginMode | String | 否,仅 perp | cross 或 isolated。省略时沿用该 assetId 当前模式;新开仓默认 cross。 |
| >>> positionSide | String | 否,默认 net | oneWay 使用 net;hedge 使用 long 或 short。仅适用于 perp。 |
| >> clientOrderId | String | 普通订单必填;Trigger 或 TPSL 订单可选 | 34 字符格式:0x{region}{env}{30hex}。可重用,去重维度为 oid + block_height。 |
| >> price | String | 是 | Trigger Market 必须为 "0";其他类型必须大于 0。isTpLimit=true 时,该字段为止盈限价;触发或转换后,系统以该价格挂出 Reduce-Only GTC Limit 订单。 |
| >> size | String | 是 | 大于 0,以 base token 计量。Order-Attached TPSL 子订单固定为 "0",随母订单成交量解析;Position-Attached TPSL 的 Entire Position 使用 "0"。 |
| >> sizeType | String | 否,默认 base | base 表示按 token 数量下单。quote 表示按报价资产金额下单;当前 OpenAPI 不支持 quote。 |
| >> priceAmendType | String | 否,默认 noAmend | 价格超出允许价格带时的处理策略。当前 OpenAPI 仅支持 noAmend,超出价格带时直接拒单;clampToLimit 为底层保留能力,当前未开放,传入将被拒绝。 |
| >> reduceOnly | Boolean | 否,默认 false | 是否只减仓。附带 TPSL 子订单固定为 true。 |
| >> orderType | Object | 是 | 订单类型对象,只能包含一个键,键名即订单类型。限价单使用 limit,触发单使用 trigger;两者不可同时出现。子字段仅存在于对应对象中;将 tif、isMarket、triggerPx、tpsl、triggerPriceType、parentOrderId 或 isTpLimit 写在订单顶层会被拒绝。 |
| >>> tif | String 或 Object | Limit 订单必填 | gtc、ioc、fok 或 alo。 |
| >>> isMarket | Boolean | Trigger 订单必填 | true:触发后按市价执行,以 IOC 激进限价模拟;false:触发后按限价执行,price 为挂单限价。 |
| >>> triggerPx | String | Trigger 订单必填 | 触发价必须大于 0;isTpLimit=true 时固定为 "0"。该值为 sentinel,不代表触发价为零;止盈限价使用订单级 price。 |
| >>> tpsl | String | Trigger 订单必填 | 根据 grouping 使用不同枚举:na 使用 up 或 down;orderTpsl 与 positionTpsl 使用 tp 或 sl。 |
| >>> triggerPriceType | String | Trigger 订单必填 | mark 或 index。所有 Trigger 和 TPSL 均支持;isTpLimit=true 时传入 mark。 |
| >>> parentOrderId | String | 否 | 仅位于 orderType.trigger 内。省略时,母订单与 TPSL 子订单在同一 orders[] 内提交,链上自动将 orders[0] 的母订单 oid 回填到子订单。传入 oid 时表示事后为已挂盘且仍有效的母订单追加 TPSL;本次 orders[] 只携带 TPSL 子订单,grouping 仍为 orderTpsl。 |
| >>> isTpLimit | Boolean | 否,默认 false | TP Limit 子订单标记。为 true 时,tpsl 必须为 tp,且 isMarket 必须为 false。 |
| nonce | Number | 是 | 当前毫秒时间戳。参与签名哈希,服务端用于防重放。 |
| expiresAfter | Long | 否 | 动作有效截止时间,Unix 时间戳,毫秒。超过该时间后请求被拒绝;与订单 GTD 的有效期无关。 |
| user | String | 否 | 主体账户地址。网关从签名者与母账户的绑定关系中解析主体账户,因此可省略;显式传入时必须与绑定关系一致。 |
| vaultAddress | String | 否 | 操作母账户时省略;操作子账户时传入子账户地址。 |
| signature | Object | 是 | Agent 对完整 action 的 EIP-712 ECDSA 签名。r 和 s 为 0x 开头的十六进制字符串,v 为 0 或 1。 |
marketType 类型
prediction 和 spot 为字符串;perp 为对象。
{
"marketType": "spot"
}
{
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
}
}
perp marketType 子字段
| 子字段 | 类型 | 必填 | 取值 | 说明 |
|---|---|---|---|---|
| marginMode | String | 否,仅 perp | cross / isolated | 保证金模式。不传时沿用该 assetId 当前模式;新开仓默认 cross。 |
| positionSide | String | 否 | net / long / short / null | 仓位方向。买卖模式使用 net;开平模式使用 long 或 short。仅适用于 perp。 |
订单类型说明
- Trigger Order:不绑定母订单或持仓的独立策略订单。满足触发条件后,按用户设置的参数下单至订单簿。
- Order-Attached TPSL:绑定母订单的 TPSL 子订单,是否生效取决于母订单状态。母订单为 Reduce-Only 时,不允许附带 TPSL。
- Position-Attached TPSL:绑定关联持仓的 TPSL 子订单,订单状态取决于关联持仓状态。
下单形态
| 形态 | grouping | orderType | reduceOnly | side | size |
|---|---|---|---|---|---|
| 普通限价单 | na | limit,包含 tif | 可选 | 用户填写 | 用户填写,且大于 0。 |
| 市价单,IOC/FOK 模拟 | na | limit,tif 为 ioc 或 fok | 可选 | 用户填写 | 用户填写,且大于 0。 |
| 独立 Trigger 订单 | na | trigger | 可选 | 用户填写 buy 或 sell | 用户填写,且大于 0。 |
| 部分仓位 TPSL | positionTpsl | trigger | 自动为 true | 与仓位方向相反,自动确定 | 用户填写,且大于 0。 |
| Order-Attached TPSL | orderTpsl | trigger,TP 可使用 TP Limit | 自动为 true | 与母订单方向相反,自动确定 | "0",随母订单成交量解析。 |
| Entire Position TPSL | positionTpsl | trigger,SL 仅支持市价;TP 支持市价或 TP Limit | 自动为 true | 与仓位方向相反,自动确定 | "0",随当前持仓数量解析。 |
Trigger 和 TPSL 业务规则
- 独立 Trigger 订单的触发价格不得等于参考价格;否则订单会在提交后立即触发并被拒绝。
- Order-Attached TPSL 仅适用于非 Reduce-Only 的市价、限价和 Trigger 母订单。
- TPSL 触发价格方向:
- Position-Attached TPSL 与参考价格比较。
- Order-Attached TPSL 与母订单价格比较。
- 卖出方向:TP 高于基准价格,SL 低于基准价格。
- 买入方向:TP 低于基准价格,SL 高于基准价格。
- SL 不支持直接挂出限价订单。
- TP 可使用 Trigger 或 Limit。
- SL Trigger 可在触发后以市价或限价执行。
- 每个母订单最多附带 1 个 TP 和 1 个 SL,只能附带于非 Reduce-Only 的 Limit 或 Market 母订单。
- Position-Attached TPSL 分为 Entire Position 与 Partial Position:
- Entire Position:每个持仓最多 1 个 TP 和 1 个 SL;TP 和 SL 仅支持 Trigger Market;
size="0",随持仓数量变化。 - Partial Position:用户指定数量,
size>0且每张订单不得超过持仓数量;允许多笔 TP 和 SL。 - Partial Position TP 支持 Trigger Market、Trigger Limit 或 TP Limit。
- Partial Position SL 支持 Trigger Market 或 Trigger Limit。
- Entire Position:每个持仓最多 1 个 TP 和 1 个 SL;TP 和 SL 仅支持 Trigger Market;
- 未生效或未触发的 Trigger 订单和附带 TPSL 均计入每个地址的最大订单数。
- 关联订单的
oid均不相同,通过parentOrderId指向直接上一层订单:- 母订单 A ← TPSL 子订单 B,其中
B.parentOrderId=A。 - TPSL 子订单 B ← 触发后执行订单 C,其中
C.parentOrderId=B。 - 链上自动生成的触发后执行订单 C 不携带
clientOrderId。 - 用户提交的 TPSL 子订单 B 可携带
clientOrderId。
- 母订单 A ← TPSL 子订单 B,其中
- Position-Attached TP Limit 会即时转换为一张 Reduce-Only GTC Limit 挂单,不存在等待价格触发的阶段。
- 查询、撤单和改单均使用该真实挂单的
oid。
- 查询、撤单和改单均使用该真实挂单的
- 挂单
oid获取方式:mode=sync,默认模式:下单响应的statuses[].resting.oid直接返回挂单oid。mode=async:通过私有频道user-order-status或GET /trade/transaction查询。
请求示例:限价单和独立 Trigger 订单#
grouping="na"。
{
"action": {
"type": "placeOrder",
"grouping": "na",
"orders": [
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "buy",
"price": "95000",
"size": "0.1",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": false,
"clientOrderId": "0x030000277b000001a02462e725000101",
"orderType": {
"limit": {
"tif": "gtc"
}
}
},
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "sell",
"price": "0",
"size": "0.1",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": false,
"orderType": {
"trigger": {
"isMarket": true,
"triggerPx": "49000",
"triggerPriceType": "mark",
"tpsl": "down"
}
}
}
]
},
"nonce": 1704067200000,
"expiresAfter": 1704067260000,
"user": "0x742d35cc...",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
请求示例:Order-Attached TPSL 组合订单
grouping="orderTpsl",在同一批次提交。
TPSL 子订单为 orders[] 中的独立元素,可分别携带可选的 clientOrderId。子订单的 size 固定为 "0",并在母订单成交后根据母订单成交量解析。
{
"action": {
"type": "placeOrder",
"grouping": "orderTpsl",
"orders": [
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "buy",
"price": "95000",
"size": "0.1",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": false,
"clientOrderId": "0x030000277b000001a02462e725000201",
"orderType": {
"limit": {
"tif": "gtc"
}
}
},
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "sell",
"price": "0",
"size": "0",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": true,
"clientOrderId": "0x030000277b000001a02462e725000202",
"orderType": {
"trigger": {
"isMarket": true,
"triggerPx": "99000",
"triggerPriceType": "mark",
"tpsl": "tp"
}
}
},
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "sell",
"price": "0",
"size": "0",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": true,
"clientOrderId": "0x030000277b000001a02462e725000203",
"orderType": {
"trigger": {
"isMarket": true,
"triggerPx": "90000",
"triggerPriceType": "mark",
"tpsl": "sl"
}
}
}
]
},
"nonce": 1704067200000,
"user": "0x742d35cc...",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
** 请求示例:Order-Attached TPSL 组合订单,包含 TP Limit**
grouping="orderTpsl"。
TP Limit 子订单的 price 为止盈限价。母订单成交后,系统按该价格挂出 Reduce-Only 限价订单。
triggerPx固定为"0",仅作为 sentinel,不代表触发价格为零。isMarket必须为false。
{
"action": {
"type": "placeOrder",
"grouping": "orderTpsl",
"orders": [
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "buy",
"price": "95000",
"size": "0.1",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": false,
"clientOrderId": "0x030000277b000001a02462e725000301",
"orderType": {
"limit": {
"tif": "gtc"
}
}
},
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "sell",
"price": "105000",
"size": "0",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": true,
"orderType": {
"trigger": {
"isMarket": false,
"triggerPx": "0",
"triggerPriceType": "mark",
"tpsl": "tp",
"isTpLimit": true
}
}
},
{
"assetId": "102",
"marketType": {
"perp": {
"marginMode": "cross",
"positionSide": "long"
}
},
"side": "sell",
"price": "0",
"size": "0",
"sizeType": "base",
"priceAmendType": "noAmend",
"reduceOnly": true,
"orderType": {
"trigger": {
"isMarket": true,
"triggerPx": "90000",
"triggerPriceType": "mark",
"tpsl": "sl"
}
}
}
]
},
"nonce": 1704067200000,
"user": "0x742d35cc...",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
撤单(批量) POST /trade/cancel-order#
支持批量撤单,单次最多 30 笔。
- 每笔撤单必须提供
oid或clientOrderId之一。 assetId与marketType必须与目标订单一致。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | Object | 是 | 撤单动作。 |
| > type | String | 是 | 固定为 cancel。 |
| > cancels | Array | 是 | 待撤销订单列表。 |
| >> assetId | String | 是 | 产品 ID。 |
| >> marketType | String 或 Object | 是 | 市场类型,必须与目标订单一致。 |
| >> oid | String | 条件必填 | 订单 ID;与 clientOrderId 二选一。 |
| >> clientOrderId | String | 条件必填 | 客户订单 ID;与 oid 二选一。 |
| nonce | Number | 是 | 当前 nonce。 |
| user | String | 否 | 母账户地址。 |
| signature | Object | 是 | EIP-712 签名。 |
{
"action": {
"type": "cancel",
"cancels": [
{
"assetId": "102",
"marketType": "perp",
"clientOrderId": "0xdeadbeef00000000deadbeef00000001"
},
{
"assetId": "102",
"marketType": "perp",
"oid": "77738308"
}
]
},
"nonce": 1704067200000,
"user": "0x742d35cc...",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
改单(批量) POST /trade/modify-order#
修改已挂订单的价格、数量、触发参数或允许的订单类型。使用统一 modify action;modifies[] 包含 1 笔时为单笔改单,多笔时为批量改单。
- 单次最多 30 笔。
- 每笔使用
oid或clientOrderId定位。 - 改价或增大
size时,订单失去原排队优先级,并重新进入新价格或当前价格队列尾部。 - 减少
size时保留原排队优先级。 - 若新
size小于已成交数量,系统将改单数量调整为已成交数量。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | Object | 是 | 改单动作。 |
| > type | String | 是 | 固定为 modify。 |
| > modifies | Array | 是 | 改单列表。 |
| >> oid | String | 条件必填 | 订单 ID;与 clientOrderId 二选一。 |
| >> clientOrderId | String | 条件必填 | 客户订单 ID;与 oid 二选一。 |
| >> assetId | String | 是 | 产品 ID。 |
| >> price | String | 否 | 修改后的订单价格。 |
| >> size | String | 否 | 修改后的订单总量。 |
| >> orderType | Object | 否 | 修改订单类型或触发参数时必填,必须完整传入对应子结构。 |
| nonce | Number | 是 | 当前 nonce。 |
| user | String | 否 | 母账户地址。 |
| signature | Object | 是 | EIP-712 签名。 |
改单示例
{
"action": {
"type": "modify",
"modifies": [
{
"clientOrderId": "0xdeadbeef00000000deadbeef00000001",
"assetId": "102",
"price": "50100",
"size": "0.2",
"orderType": {
"limit": {
"tif": "gtc"
}
}
}
]
},
"nonce": 1704067200000,
"user": "0x742d35cc...",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
查询单笔订单 GET /trade/order#
通过 oid 或 clientOrderId 查询单笔订单。两个参数必须且只能提供一个。
本接口仅支持查询已产生链上订单记录的订单。下单失败且未产生 oid 的订单无法通过本接口查询,请使用 GET /trade/transaction 查询交易回执。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| oid | String | 二选一 | 链上订单 ID;与 clientOrderId 必须且只能提供一个。 |
| clientOrderId | String | 二选一 | 用户自定义订单 ID;与 oid 必须且只能提供一个。 |
| vaultAddress | String | 否 | 操作母账户时省略;操作子账户时填写子账户地址。 |
请求示例
GET /api/v5/exchangeos/trade/order?oid=77738308
GET /api/v5/exchangeos/trade/order?clientOrderId=0xdeadbeef00000000deadbeef00000001返回字段
| 字段 | 类型 | 说明 |
|---|---|---|
| oid | String | 链上订单 ID。 |
| clientOrderId | String | 用户自定义订单 ID。 |
| assetId | String | 标的 ID。 |
| side | String | buy 或 sell。 |
| marginMode | String | 保证金模式:cross 或 isolated。仅适用于 perp;spot 和 prediction 返回 null。 |
| reduceOnly | Boolean | 是否只减仓。 |
| orderType | String | 订单类型:limit 或 trigger。 |
| tif | String | gtc、ioc、fok 或 alo。Trigger 订单返回 null。 |
| price | String | 委托价格。 |
| size | String | 委托数量,以 base token 计。 |
| accFillSz | String | 累计已成交数量,以 base token 计。 |
| avgPx | String | 成交加权平均价;未成交时返回 null。 |
| state | String | open、partially_filled、filled、triggered、triggered_and_failed、canceled、failed 或 part_filled_canceled。 |
| triggerPx | String | 触发价格;非 Trigger 订单返回 null。 |
| triggerPriceType | String | mark 或 index;非 Trigger 订单返回 null。 |
| isMarket | Boolean | 触发后是否市价执行;非 Trigger 订单返回 null。 |
| tpsl | String | up、down、tp 或 sl;非 Trigger 订单返回 null。 |
| grouping | String | na、orderTpsl 或 positionTpsl。 |
| parentOrderId | String | 关联链中直接上一层订单的 oid;无上层时返回 null。 |
| cancelReason | String | 撤单原因;未撤单时返回 null。 |
| cTime | String | 下单时间,Unix 时间戳,毫秒。 |
| block_timestamp | String | 最近状态变更时间,Unix 时间戳,毫秒。 |
| block_height | String | 最近状态变更对应的链上区块高度。 |
| txHash | String | 链上受理交易哈希。 |
返回示例:普通限价单,部分成交
{
"code": "0",
"msg": "",
"data": [
{
"oid": "77738308",
"clientOrderId": "0xdeadbeef00000000deadbeef00000001",
"assetId": "102",
"side": "buy",
"marginMode": "cross",
"reduceOnly": false,
"orderType": "limit",
"tif": "gtc",
"price": "95000",
"size": "0.1",
"accFillSz": "0.04",
"avgPx": "94990",
"state": "partially_filled",
"triggerPx": null,
"triggerPriceType": null,
"isMarket": null,
"tpsl": null,
"grouping": "na",
"parentOrderId": null,
"cancelReason": null,
"cTime": "1704067200000",
"block_timestamp": "1704067210000",
"block_height": "11892975",
"txHash": "0x9a3b1f4c...e1f2a3"
}
]
}
返回示例:等待触发的 Trigger 订单
{
"code": "0",
"msg": "",
"data": [
{
"oid": "77738310",
"clientOrderId": "0xdeadbeef00000000deadbeef00000004",
"assetId": "102",
"side": "sell",
"marginMode": "cross",
"reduceOnly": true,
"orderType": "trigger",
"tif": null,
"price": "48000",
"size": "0.1",
"accFillSz": "0",
"avgPx": null,
"state": "open",
"triggerPx": "49000",
"triggerPriceType": "mark",
"isMarket": false,
"tpsl": "sl",
"grouping": "positionTpsl",
"parentOrderId": null,
"cancelReason": null,
"cTime": "1704067200000",
"block_timestamp": "1704067200000",
"txHash": "0x..."
}
]
}
查询未成交挂单 GET /trade/orders-pending#
查询母账户或指定子账户当前有效的普通挂单、独立 Trigger、Position TPSL,以及普通订单附带的 TP/SL。
仅支持 spot 和 perp,不包含 prediction Market 或 CeDeFi Swap。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pointBoard | Boolean | 否 | true 表示积分盘;false 表示实盘。 |
| assetId | String | 否 | 按产品 ID 过滤。 |
| vaultAddress | String | 否 | 操作母账户时省略;操作子账户时填写子账户地址。 |
请求示例
GET /api/v5/exchangeos/trade/orders-pending
GET /api/v5/exchangeos/trade/orders-pending?assetId=102
GET /api/v5/exchangeos/trade/orders-pending?vaultAddress=0x6d1a19e1e03b83163fb38d7336b58875e71c50c2响应数据字段
| 字段 | 类型 | 说明 |
|---|---|---|
| block_height | String | 查询对应的链上区块高度。 |
| block_timestamp | String | 查询对应的链上区块时间,Unix 时间戳,毫秒。 |
| data | Array | 未成交挂单列表;无挂单时返回空数组。 |
订单字段
| 字段 | 类型 | 说明 |
|---|---|---|
| oid | String | 链上订单 ID。 |
| clientOrderId | String | 用户自定义订单 ID;自动生成的执行子单返回空字符串。 |
| assetId | String | 产品 ID。 |
| assetStatus | String | 产品状态。 |
| side | String | 订单方向:buy 或 sell。 |
| positionSide | String | net、long 或 short;Spot 返回空字符串。 |
| marginMode | String | cross 或 isolated;Spot 返回空字符串。 |
| leverage | String | 杠杆倍数;仅支持整数。Equity 为 0 或 Spot 时返回空字符串。 |
| orderType | String | limit 或 trigger。 |
| tif | String | gtc、ioc、fok、alo 或 gtd;Trigger 订单返回空字符串。 |
| price | String | 委托价格;Trigger Market 返回空字符串。 |
| size | String | 委托数量,以 base token 计。 |
| accFillSz | String | 累计已成交数量。 |
| state | String | open 或 partially_filled。 |
| reduceOnly | Boolean | 是否只减仓。 |
| parentOrderId | String | 直接父订单 ID;无父订单时返回空字符串。 |
| attachAlgoOrds | Array | 母订单附带的 TP/SL 子订单,最多两笔;无子订单时返回空数组。 |
| triggerPx | String | 触发价格;不适用时返回空字符串。 |
| triggerPriceType | String | mark 或 index;不适用时返回空字符串。 |
| triggerCond | String | Gte 或 Lte;不适用时返回空字符串。 |
| isMarket | Boolean | 触发后是否市价执行。 |
| tpsl | String | up、down、tp 或 sl;不适用时返回空字符串。 |
| tpLimit | Boolean | 是否为 TP Limit。 |
attachAlgoOrds 字段
attachAlgoOrds 中的子订单继承上述订单字段。除此之外,以下字段含义如下:
| 字段 | 类型 | 说明 |
|---|---|---|
| isActive | Boolean | 子订单是否已生效。 |
| parentOrderId | String | 关联母订单 ID。 |
| tpLimit | Boolean | 是否为 TP Limit。 |
Response Example
{
"code": "0",
"msg": "",
"data": [
{
"block_height": "11892975",
"block_timestamp": "1785062091486",
"data": [
{
"oid": "39933954",
"clientOrderId": "0x01a3f09c7e12b84d6590ef31ca762b4d",
"assetId": "1502",
"assetStatus": "normal",
"side": "buy",
"positionSide": "long",
"marginMode": "isolated",
"orderType": "limit",
"tif": "gtc",
"price": "96.0500",
"size": "1.00",
"accFillSz": "0.50",
"state": "partially_filled",
"reduceOnly": false,
"parentOrderId": "",
"attachAlgoOrds": [
{
"oid": "39933955",
"assetId": "1502",
"side": "sell",
"positionSide": "long",
"marginMode": "isolated",
"price": "200.0000",
"size": "1.00",
"reduceOnly": true,
"triggerPx": "200.0000",
"triggerPriceType": "mark",
"triggerCond": "Gte",
"isMarket": false,
"tpsl": "tp",
"parentOrderId": "39933954",
"isActive": false,
"tpLimit": true
}
],
"triggerPx": "",
"triggerPriceType": "",
"triggerCond": "",
"isMarket": false,
"tpsl": "",
"tpLimit": false
}
]
}
]
}
查询订单操作历史 GET /trade/orders-history#
查询母账户或指定子账户的订单状态变更历史。同一订单从创建至终态的每次状态流转均返回一笔快照,以 oid + block_height 唯一识别。
分页规则
- 记录位于
data[0].data,按block_timestamp从新到旧返回。 - 使用游标令牌分页:响应中的
data[0].nextCursor用于下一页请求的cursor参数。 - 使用
data[0].hasMore判断是否继续查询;不得以返回笔数小于limit判断终点。 begin和end仅用于时间窗口过滤;与cursor同时传入时,由cursor确定起点。- 同一
oid的状态记录可能跨页返回。客户端应以oid、state和block_timestamp识别事件行并自行聚合。 - 未产生
oid的下单拒绝不在本接口中;请通过GET /trade/transaction按txHash查询交易回执。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pointBoard | Boolean | 否 | true 表示积分盘;false 表示实盘。 |
| assetId | String | 否 | 按产品 ID 过滤;不传时返回全部产品。 |
| state | String | 否 | 按订单状态过滤。 |
| begin | String | 否 | 时间窗口起点,筛选 block_timestamp 大于或等于此值。 |
| end | String | 否 | 时间窗口终点,筛选 block_timestamp 小于或等于此值。 |
| cursor | String | 否 | 续传令牌。首页不传;后续传入上一页的 nextCursor。 |
| limit | String | 否 | 返回记录数;默认值和最大值均为 100。 |
| vaultAddress | String | 否 | 操作母账户时省略;操作子账户时填写子账户地址。 |
请求示例
GET /api/v5/exchangeos/trade/orders-history?assetId=102&begin=1704000000000&end=1704067200000&limit=100
GET /api/v5/exchangeos/trade/orders-history?assetId=102&state=filled&limit=100
GET /api/v5/exchangeos/trade/orders-history?cursor=1&limit=100
GET /api/v5/exchangeos/trade/orders-history?vaultAddress=0x6d1a19e1e03b83163fb38d7336b58875e71c50c2&limit=100state 枚举
| 值 | 说明 |
|---|---|
| open | 成功创建或进入订单簿,包括未触发的 Trigger 和 TPSL 订单。 |
| partially_filled | 部分成交。 |
| modified | 原地修改,例如同价缩量,oid 不变。 |
| filled | 完全成交。 |
| triggered | 触发成功;生成的执行订单通过 children 关联。 |
| triggered_and_failed | 触发成功但执行订单未创建。 |
| failed | 执行订单创建后下单失败。 |
| canceled | 已撤销。 |
| part_filled_canceled | 部分成交,剩余部分已撤销。 |
cancelReason 枚举
canceled_by_user、ioc_remaining_canceled、insufficient_margin_canceled、exceed_position_tiers、reduce_only_canceled、master_order_canceled、related_positions_closed、delisting_canceled、canceled_to_modify、canceled
父子订单关联规则
parentOrderId只指向直接上一层订单,children只列出直接下一层订单。- 订单附带 TPSL 的关联链为:母订单 A ← TPSL 子订单 B ← 触发后执行订单 C。
- 用户提交的 Trigger 或 TPSL 订单可携带
clientOrderId;链上自动生成的执行订单没有clientOrderId。 - Position TPSL 没有母订单,
parentOrderId返回空字符串;触发后生成的执行订单的parentOrderId指向该 Position TPSL。 - 同一订单是否可同时返回非空
parentOrderId和非空children,以链上数据模型最终定义为准。
响应示例
开多 → 设置整仓 SL → 触发平仓,加上一笔 Spot 成交,共 5 条记录:
- 区块 12092400:订单 88001 开多后立即完全成交(taker,仅一条
filled记录,tradeId 776),持有 602 long 1.5@3000。 - 区块 12092405:设置整仓 SL 32733862(当 mark ≤ 2900 时触发,以市价平多),产生一条
open记录。 - 区块 12092410:订单 88004 Spot 卖出后立即成交(仅一条
filled记录,tradeId 779)。 - 区块 12092417:价格跌破 2900。32733862 从
open变为triggered,children=["90005"];链上自动生成执行订单 90005,以市价卖出 1.5 平仓并filled(tradeId 780,无clientOrderId,parentOrderId指向 SL 订单)。
{
"code": "0",
"msg": "",
"data": [
{
"nextCursor": "",
"hasMore": false,
"data": [
{
"oid": "90005",
"clientOrderId": "",
"assetId": "602",
"side": "sell",
"positionSide": "long",
"marginMode": "isolated",
"orderType": "limit",
"tif": "ioc",
"price": "",
"size": "1.500",
"accFillSz": "1.500",
"avgPx": "2895.000",
"state": "filled",
"reduceOnly": true,
"parentOrderId": "32733862",
"children": [],
"triggerPx": "",
"triggerPriceType": "",
"triggerCond": "",
"isMarket": false,
"tpsl": "",
"tpLimit": false,
"cancelReason": "",
"block_height": "12092417",
"block_timestamp": "1785218400074"
},
{
"oid": "32733862",
"clientOrderId": "0x01a2b3c4d5e6f7089a0b1c2d3e4f5060",
"assetId": "602",
"side": "sell",
"positionSide": "long",
"marginMode": "isolated",
"orderType": "trigger",
"tif": "",
"price": "",
"size": "0",
"accFillSz": "0",
"avgPx": "",
"state": "triggered",
"reduceOnly": true,
"parentOrderId": "",
"children": [
"90005"
],
"triggerPx": "2900.000",
"triggerPriceType": "mark",
"triggerCond": "Lte",
"isMarket": true,
"tpsl": "sl",
"tpLimit": false,
"cancelReason": "",
"block_height": "12092417",
"block_timestamp": "1785218400074"
},
{
"oid": "88004",
"clientOrderId": "0x01eac095b61842df730259ec48a3fb7d",
"assetId": "301",
"side": "sell",
"positionSide": "",
"marginMode": "",
"orderType": "limit",
"tif": "gtc",
"price": "80000.000000",
"size": "0.050000",
"accFillSz": "0.050000",
"avgPx": "80000.000000",
"state": "filled",
"reduceOnly": false,
"parentOrderId": "",
"children": [],
"triggerPx": "",
"triggerPriceType": "",
"triggerCond": "",
"isMarket": false,
"tpsl": "",
"tpLimit": false,
"cancelReason": "",
"block_height": "12092410",
"block_timestamp": "1785218399800"
},
{
"oid": "32733862",
"clientOrderId": "0x01a2b3c4d5e6f7089a0b1c2d3e4f5060",
"assetId": "602",
"side": "sell",
"positionSide": "long",
"marginMode": "isolated",
"orderType": "trigger",
"tif": "",
"price": "",
"size": "0",
"accFillSz": "0",
"avgPx": "",
"state": "open",
"reduceOnly": true,
"parentOrderId": "",
"children": [],
"triggerPx": "2900.000",
"triggerPriceType": "mark",
"triggerCond": "Lte",
"isMarket": true,
"tpsl": "sl",
"tpLimit": false,
"cancelReason": "",
"block_height": "12092405",
"block_timestamp": "1785218399500"
},
{
"oid": "88001",
"clientOrderId": "0x01b7c8d9e0f1a2b3c4d5e6f708192021",
"assetId": "602",
"side": "buy",
"positionSide": "long",
"marginMode": "isolated",
"orderType": "limit",
"tif": "gtc",
"price": "3000.000",
"size": "1.500",
"accFillSz": "1.500",
"avgPx": "3000.000",
"state": "filled",
"reduceOnly": false,
"parentOrderId": "",
"children": [],
"triggerPx": "",
"triggerPriceType": "",
"triggerCond": "",
"isMarket": false,
"tpsl": "",
"tpLimit": false,
"cancelReason": "",
"block_height": "12092400",
"block_timestamp": "1785218399000"
}
]
}
]
}
响应未返回完毕时的分页对象格式(data[0].data 内容与上述相同):
{
"code": "0",
"msg": "",
"data": [
{
"nextCursor": "1"
}
]
}
查询成交明细 GET /trade/fills#
查询母账户或指定子账户的成交明细。
分页规则
- 成交记录位于
data[0].data[]。 - 分页信息位于
data[0].hasMore和data[0].nextCursor。 - 记录按
block_timestamp从新到旧返回。 - 首页不传
cursor;后续请求原样传入上一页的nextCursor。 nextCursor为不透明令牌,不得解析、比较或自行构造。hasMore=false且nextCursor=""表示最后一页。- 同一
block_timestamp的成交数可能超过limit,不得以返回笔数判断是否到达末页。 begin和end仅用于时间窗口过滤,不能替代分页游标。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| pointBoard | Boolean | 否 | true 表示积分盘;false 表示实盘。 |
| assetId | String | 否 | 按产品 ID 过滤。 |
| begin | String | 否 | 时间窗口起点,Unix 时间戳,毫秒。 |
| end | String | 否 | 时间窗口终点,Unix 时间戳,毫秒。 |
| cursor | String | 否 | 续传令牌。 |
| limit | String | 否 | 返回记录数;默认值和最大值均为 100。 |
| vaultAddress | String | 否 | 操作母账户时省略;操作子账户时填写子账户地址。 |
请求示例
GET /api/v5/exchangeos/trade/fills?assetId=2&limit=100
GET /api/v5/exchangeos/trade/fills?assetId=2&begin=1785443440527&end=1786443440530&limit=100
GET /api/v5/exchangeos/trade/fills?assetId=2&cursor=1&limit=100
GET /api/v5/exchangeos/trade/fills?vaultAddress=0x6d1a19e1e03b83163fb38d7336b58875e71c50c2&limit=100响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| tradeId | String | 成交 ID。 |
| oid | String | 订单 ID。 |
| clientOrderId | String | 客户订单 ID。 |
| assetId | String | 产品 ID。 |
| side | String | 订单方向。 |
| execType | String | 成交角色,例如 maker 或 taker。 |
| price | String | 成交价格。 |
| size | String | 成交数量。 |
| fee | String | 手续费。 |
| feeTokenId | String | 手续费币种 ID。 |
| rebate | String | 返佣数量。 |
| rebateTokenId | String | 返佣币种 ID。 |
| closedPnl | String | 已实现盈亏。 |
| fillDir | String | 成交方向或业务类型。 |
| startPosition | String | 成交前持仓数量。 |
| block_timestamp | String | 区块时间,Unix 时间戳,毫秒。 |
| block_height | String | 区块高度。 |
fillDir 枚举
| 值 | 说明 |
|---|---|
| Buy | 买方成交。 |
| Sell | 卖方成交。 |
| BuySplit | 双方均为买方时的隐式拆分。 |
| SellMerge | 双方均为卖方时的隐式合并。 |
| BackstopLiquidation | 保险基金接管亏损仓位的清算成交。 |
| BackstopLiquidator | 保险基金作为流动性提供方完成的清算成交。 |
| Adl | 自动减仓成交。 |
| AdlOpponent | 自动减仓对手方成交。 |
| AdlPreviousPrice | 自动减仓前价格成交。 |
| AdlOpponentPreviousPrice | 自动减仓对手方前价格成交。 |
| NetLiquidation | 净清算成交。 |
| NetAdl | 净自动减仓成交。 |
| Settlement | 结算成交。 |
| Open | 永续开仓或同向加仓。 |
| Close | 永续平仓。 |
| ReverseOpen | 先平掉原持仓,再反向开仓。 |
| DecimalAdjustSettle | 精度调整的用户尾数结算成交;当前版本不会发出。 |
| DecimalAdjustTakeover | 精度调整中由 Liquidator 承接净尾仓的成交;当前版本不会发出。 |
分页响应示例
{
"code": "0",
"msg": "",
"data": [
{
"nextCursor": "1",
"hasMore": true,
"data": [
{
"tradeId": "2998",
"oid": "3597058",
"clientOrderId": "0x030000277b0000019ff053a147000002",
"assetId": "2",
"side": "buy",
"execType": "taker",
"price": "1.6",
"size": "0.3",
"fee": "0.00024",
"feeTokenId": "2393",
"rebate": "0.0002",
"rebateTokenId": "2393",
"closedPnl": "0",
"fillDir": "Buy",
"startPosition": "12.3",
"block_timestamp": "1786443440529",
"block_height": "12092410"
}
]
}
]
}
主子账户划转 POST /account/account-transfer#
在母账户与其所属子账户之间划转资产。
- 仅支持母账户转入子账户,以及子账户转回母账户。
- 不支持子账户之间直接划转。
- 划转方向由
isDeposit指定,不根据地址顺序推导。 - 请求必须由母账户已授权、状态为
active且未过期的 OpenAPI Agent 签名。 user为母账户地址,subAccountUser为该母账户下的子账户地址。- 仅可划转来源账户的可用资产;请求被拒绝时不会发生资产变动。
请求参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
| action | Object | 是 | 划转动作。 |
| > type | String | 是 | 固定为 subAccountTransfer。 |
| > subAccountUser | String | 是 | 子账户地址。 |
| > isDeposit | Boolean | 是 | true:母账户转入子账户;false:子账户转回母账户。 |
| > tokenId | String | 是 | 币种 ID。 |
| > amount | String | 是 | 划转数量。 |
| nonce | Number | 是 | 当前 nonce。 |
| expiresAfter | Number | 否 | 请求过期时间,Unix 时间戳,毫秒。 |
| user | String | 是 | 母账户地址。 |
| signature | Object | 是 | EIP-712 签名。 |
请求示例:母账户转入子账户
{
"action": {
"type": "subAccountTransfer",
"subAccountUser": "0x1111111111111111111111111111111111111111",
"isDeposit": true,
"tokenId": "0",
"amount": "0.5"
},
"nonce": 1704067200000,
"expiresAfter": 1704067260000,
"user": "0x2222222222222222222222222222222222222222",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
请求示例:子账户转回母账户
{
"action": {
"type": "subAccountTransfer",
"subAccountUser": "0x1111111111111111111111111111111111111111",
"isDeposit": false,
"tokenId": "0",
"amount": "0.5"
},
"nonce": 1704067200000,
"expiresAfter": 1704067260000,
"user": "0x2222222222222222222222222222222222222222",
"signature": {
"Ecdsa": {
"r": "0x...",
"s": "0x...",
"v": 1
}
}
}
成功响应示例
{
"code": "0",
"msg": "",
"data": [
{
"txHash": "0x9a3b1f4c...e1f2a3"
}
]
}
链上交易回执 GET /trade/transaction#
查询一笔已提交交易的链上确认结果及标准化执行回执。
GET /api/v5/exchangeos/trade/transaction
请求参数
| 参数 | 位置 | 类型 | 必填 | 说明 |
|---|---|---|---|---|
| txHash | Query | String | 是 | 交易哈希,格式为 0x 加 64 位十六进制字符。 |
请求示例
GET /api/v5/exchangeos/trade/transaction?txHash=0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef
OK-ACCESS-KEY: {{apiKey}}
OK-ACCESS-SIGN: {{sign}}
OK-ACCESS-TIMESTAMP: {{timestamp}}
OK-ACCESS-PASSPHRASE: {{passphrase}}标准响应结构
{
"code": "0",
"msg": "",
"data": [
{
"txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"blockHeight": "3588863",
"blockHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"txIndex": "12",
"status": "ok",
"response": {
"type": "order",
"data": {
"statuses": []
}
}
}
]
}
外层响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
| code | String | OpenAPI 查询结果。"0" 表示成功取得链上回执。 |
| msg | String | OpenAPI 查询结果说明;成功时为空字符串。 |
| data | Array | 成功时包含一个交易回执;接口错误时为空数组。 |
交易回执字段
| 字段 | 类型 | 必有 | 说明 |
|---|---|---|---|
| txHash | String | 是 | 交易哈希。 |
| blockHeight | String | 是 | 确认区块高度。以字符串输出,避免 JavaScript u64 精度丢失。 |
| blockHash | String | 是 | 确认区块哈希。 |
| txIndex | String | 是 | 交易在区块中的索引;以字符串输出。 |
| status | String | 是 | 整笔链上交易状态:ok 或 err。 |
| response | Object | 否 | 链上执行结果;Empty 成功时省略该字段。 |
状态语义
客户端需要分别判断以下三层状态。三层相互独立,不可用上层结果短路下层判断:
code:本次 OpenAPI 查询是否成功。data[0].status:整笔链上交易是否执行成功。data[0].response.data.statuses[]:批量下单、撤单或改单中每一项的执行结果。
例如,外层 code="0" 仅表示成功查到回执;若 status="err",链上交易仍然执行失败。
对于批量下单,当 status="ok" 时,不同订单仍可分别为 resting、filled 或 error。即使 statuses[] 全部为 error,交易仍然是执行成功的,所有订单仅被业务规则拒绝。订单成败必须逐项根据 statuses[] 判断,不可通过 status 推断。
resting 可表示未成交或部分成交的挂单状态。
response 标准联合类型#
整笔交易失败:status="err"#
此时 response 固定为错误对象,不包含 type 和 data:
{
"code": "0",
"msg": "",
"data": [
{
"txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"blockHeight": "3588863",
"blockHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"txIndex": "12",
"status": "err",
"response": {
"code": "30004",
"message": "Nonce validation failed"
}
}
]
}
| 字段 | 类型 | 说明 |
|---|---|---|
| response.code | String | 链上错误码。 |
| response.message | String | 链上错误原因。 |
无返回数据的成功:status="ok" + Empty
部分 Action 成功后没有额外数据。此时回执有效,response 字段会被省略:
{
"code": "0",
"msg": "",
"data": [
{
"txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"blockHeight": "3588863",
"blockHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"txIndex": "12",
"status": "ok"
}
]
}
客户端不能将缺少 response 视为异常,应以 status="ok" 判断该交易成功。
有返回数据的成功:status="ok" + {type,data}#
{
"type": "order",
"data": {}
}
当前 ExchangeOS OpenAPI 用户交易与账户设置可能出现的 response.type:
| type | data 含义 | 来源 Action |
|---|---|---|
| order | 批量下单结果。 | placeOrder |
| cancel | 批量撤单结果。 | cancel、cancelAll |
| modify | 批量改单结果。 | modify |
| createSubAccount | 创建成功的子账户地址。 | createSubAccount |
范围汇总
当前对外范围共有 16 个 OpenAPI ActionType,对应 14 个不同的链上 type:
- 有结构化
response:placeOrder、cancel、cancelAll、modify、createSubAccount。 - 成功后为 Empty:
reserveRequestWeight、subAccountTransfer、updateLeverage、updateMarginMode、updatePositionMode、updateIsolatedMargin。
各 type 的标准化示例均对应:
{
"status": "ok",
"response": {
"type": "<type>",
"data": {}
}
}
order
data.statuses 与原始下单批次数组按索引一一对应。每一项只会出现一个分支:resting、filled 或 error。
完整示例:
{
"code": "0",
"msg": "",
"data": [
{
"txHash": "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
"blockHeight": "3588863",
"blockHash": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
"txIndex": "12",
"status": "ok",
"response": {
"type": "order",
"data": {
"statuses": [
{
"resting": {
"oid": "3588863",
"clientOrderId": "0x030000277b0000019fd9e97db9000000"
}
},
{
"filled": {
"oid": "3588864",
"clientOrderId": "0x030000277b0000019fd9e97db9000001",
"avgPx": "0.65",
"totalSz": "100"
}
},
{
"error": {
"code": "30043",
"message": "order price is outside the permitted band [0.9813, 1.0375]"
}
}
]
}
}
}
]
}
resting字段
挂单成功,但没有成交。
| 字段 | 类型 | 必有 | 说明 |
|---|---|---|---|
| oid | String | 是 | 链上订单 ID。 |
| clientOrderId | String | 否 | 客户端订单 ID。 |
| adjustedSz | String | 否 | 链上调整后的订单数量。 |
filled字段
订单有成交,包括部分成交。
| 字段 | 类型 | 必有 | 说明 |
|---|---|---|---|
| oid | String | 是 | 链上订单 ID。 |
| clientOrderId | String | 否 | 客户端订单 ID。 |
| avgPx | String | 是 | 平均成交价格。 |
| totalSz | String | 是 | 总成交数量。 |
| adjustedSz | String | 否 | 链上调整后的订单数量。 |
error字段
| 字段 | 类型 | 说明 |
|---|---|---|
| code | String | 单项下单错误码。 |
| message | String | 单项下单错误原因。 |
cancel
data.statuses 与原始撤单批次数组按索引一一对应。成功项为字符串 "success",失败项为 error 对象。
{
"type": "cancel",
"data": {
"statuses": [
"success",
{
"error": {
"code": "30010",
"message": "order not found"
}
}
]
}
}
"success" 是链上标准联合类型的合法成员,不是缺少结构化数据。客户端应按数组元素类型解析:字符串表示成功,对象表示失败。
modify
data.statuses 与原始改单批次数组按索引一一对应。每项可能为:
"success"{"successWithAdjustment":{"adjustedSz":"..."}}{"error":{"code":"...","message":"..."}}
{
"type": "modify",
"data": {
"statuses": [
"success",
{
"successWithAdjustment": {
"adjustedSz": "60"
}
},
{
"error": {
"code": "30000",
"message": "invalid transaction"
}
}
]
}
}
解析建议
if envelope.code != "0":
if envelope.code == "80106":
retry_later()
else:
handle_query_error(envelope.code, envelope.msg)
return
receipt = envelope.data[0]
if receipt.status == "err":
handle_transaction_error(receipt.response.code, receipt.response.message)
return
if receipt.response is absent:
handle_empty_success()
return
switch receipt.response.type:
case "order":
case "cancel":
case "modify":
for status in receipt.response.data.statuses:
handle_positional_item(status)
case "createSubAccount":
handle_created_sub_account(receipt.response.data)注意事项
statuses[n]永远对应请求批次中的第n项。不要过滤成功或失败项后再关联原请求。- 联合类型中未激活的字段不会输出。例如,
resting项不会同时包含filled: null或error: null。 - 可选字段缺失时直接省略,不输出空字符串。
- ID、价格、数量、区块高度、索引和错误码均按字符串处理。
- 不要仅依据外层
code="0"判断链上交易成功。
- 使指定 Nonce 失效 POST /trade/noop下单 POST /trade/place-order请求示例:限价单和独立 Trigger 订单撤单(批量) POST /trade/cancel-order改单(批量) POST /trade/modify-order查询单笔订单 GET /trade/order查询未成交挂单 GET /trade/orders-pending查询订单操作历史 GET /trade/orders-history查询成交明细 GET /trade/fills主子账户划转 POST /account/account-transfer链上交易回执 GET /trade/transactionresponse 标准联合类型整笔交易失败:status="err"有返回数据的成功:status="ok" + {type,data}
