获取未成交订单
API说明
此接口允许查询指定合约和订单类型的未成交订单详情,包括合约、方向、数量、数量单位、保证金、杠杆、maker费用、taker费用和时间戳。
注意:当前订单数据可通过RESTful和Websocket接口获取。本页是RESTful接口的描述。如需了解Websocket接口,请参见 跳转
注意事项
-
此接口不支持在单个请求中检索所有交易品种未成交订单。
-
如果指定合约没有未成交订单,将返回以下响应:
{'code': 0, 'data': {'nextId': 0, 'prevId': 0, 'rows': [], 'total': 0}, 'msg': ''}
- 请求参数 "positionType" 为必填项,但其行为可能存在异常,例如,指定"execute"可能仍会返回"plan"订单。相较而言,设 置为 "planTrigger" 或 "moveStopProfitLoss" 时,筛选逻辑能够按预期生效。
认证
这是一个私有接口,需要认证。有关使用RESTful API的详细信息,请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
请求方法
GET
接口地址
频率限制
该接口的调用频率限制为:每个 IP 和用户 ID 每秒最多请求10次。
此外,该接口还受到全局频率限制的约束。
有关"全局速率限制"和"API限频策略"的详细信息,请参阅“频率限制”部分,跳转
请求参数
| 参数 | 必填 | 类型 | 描述 |
|---|---|---|---|
| instrument | true | String | 交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。 |
| positionType | true | String | 订单类型:plan/execute/planTrigger/moveStopProfitLoss plan:计划订单, execute:市价单, planTrigger:计划触发订单, moveStopProfitLoss:追踪止损/止盈 |
| page | false | Integer | 当前页码 |
| pageSize | false | Integer | 每页记录数 |
响应参数
| 参数 | 类型 | 描述 |
|---|---|---|
| id | String | 订单ID |
| userId | Long | 合约合约用户ID |
| baseSize | BigDecimal | 基础货币订单规模 |
| createdDate | timestamp | 订单创建时间戳 |
| currentPiece | BigDecimal | 以合约数量计的订单规模 |
| direction | String | 订单方向:做多(long),做空(short) |
| frozenFee | BigDecimal | 冻结订单费用 |
| indexPrice | BigDecimal | 指数触发价格 |
| instrument | String | 交易品种的基础货币,例如BTC或ETH |
| leverage | BigDecimal | 持仓杠杆率 |
| liquidateBy | String | 开仓和平仓事件类型:planClose/manual |
| margin | BigDecimal | 持仓使用的保证金 |
| orderPrice | BigDecimal | 用户指定的订单价格 |
| orderStatus | String | 订单状态:unFinish:未成交,part:部分成交,Finish:完全成交,Cancel:已取消 |
| originalType | String | 原始订单类型 |
| posType | String | 持仓类型:plan/planTrigger/execute |
| positionMargin | BigDecimal | 持仓保证金 |
| positionModel | Integer | 持仓持仓模式:0:逐仓,1:全仓 |
| quantity | String | 基于quantityUnit 指定订单数量: 当 quantityUnit = 0 时,数量以计价货币计量(例如,BTC-USDT 中的 USDT); 当 quantityUnit = 1 时,数量以合约张数计量; 当 quantityUnit = 2 时,数量以基础货币计量(例如,BTC-USDT 中的 BTC)。 |
| quantityUnit | BigDecimal | 用于指定订单数量的计量单位: 0:以计价货币计价(例如,BTC-USDT 合约中的 USDT); 1:以合约张数计价; 2:以基础货币计价(例如,BTC-USDT 合约中的 BTC)。 |
| status | String | 状态:open(开仓),close(平仓) |
| takerFee | BigDecimal | taker费用 |
| totalPiece | BigDecimal | 合约总数量 |
| updatedDate | String | 最后订单更新时间戳 |
| primaryId | Long | CoinW数据库ID(用户可忽略) |
| contractType | Integer | 合约类型:1:U本位永续合约 |
| total | Integer | 当前订单总数 |
| openId | Long | 持仓ID |
请求示例
以下Python代码展示了如何查询未成交订单。
注意:完整代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
params = {
"instrument" : "BTC",
"positionType" : "plan",
}
api_url = "/v1/perpum/orders/open"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # the function FuturesRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface)
注意:完整Java代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
响应示例
以下是上述Python请求返回的示例响应:
{'code': 0,
'data': {'nextId': 0,
'prevId': 0,
'rows': [{'baseSize': 0.001,
'contractType': 1,
'createdDate': 1740053261000,
'currentPiece': 1,
'direction': 'long',
'fee': 0,
'frozenFee': 0.00954,
'id': 33308741701971947,
'indexPrice': 97299.7,
'instrument': 'BTC',
'leverage': 1,
'liquidateBy': 'manual',
'makerFee': 0.0001,
'margin': 95.4,
'orderPrice': 95400,
'orderStatus': 'unFinish',
'originalType': 'plan',
'posType': 'plan',
'positionMargin': 95.4,
'positionModel': 0,
'primaryId': 2874310689,
'processStatus': 1,
'quantity': 100,
'quantityUnit': 0,
'source': 'api',
'status': 'open',
'takerFee': 0.0006,
'totalPiece': 1,
'updatedDate': 1740053261000,
'userId': 1162061}],
'total': 1},
'msg': ''}