获取订单信息
API说明
此接口提供当前未成交订单的信息。用户可以指定订单ID列表来查询特定订单。如果既未指定合约也未指定订单ID,响应将包括指定订单类型下的所有未成交订单。响应包括诸如合约、交易方向、数量、数量单位、保证金、杠杆、maker费用、taker费用、时间戳等详情。
注意:订单信息数据只能通过 RESTful API 获取。
注意事项
- 该接口仅用于获取未成交订单信息,不支持通过 orderId 批量查询全部订单记录,请勿混淆使用场景。
- 请求参数"positionType"可能会返回超出指定类型的额外数据。例如:如果设置为execute(市价单),响应可能还包括plan订单(限价单)。对于"planTrigger",只有在订单触发并下单后才会返回响应。对于"moveStopProfitLoss",响应按预期工作。
认证
这是一个私有接口,需要认证。有关使用RESTful API的详细信息,请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
请求方法
GET
接口地址
频率限制
该接口的调用频率限制为:每个 IP 和用户 ID 每秒最多请求10次。
此外,该接口还受到全局频率限制的约束。
有关"全局速率限制"和"API限频策略"的详细信息,请参阅“频率限制”部分,跳转
请求参数
| 参数 | 必填 | 类型 | 描述 |
|---|---|---|---|
| sourceIds | false | String | 以逗号(,)分隔的订单ID列表。例如:"orderId1,orderId2,orderId3" 注意:订单ID数量不能超过20个。 |
| positionType | true | String | 订单类型:execute/plan/moveStop/stopProfitLoss execute:市价单, plan:计划单, moveStop:追踪止损和止盈, stopProfitLoss:止损和止盈 |
| instrument | false | String | 交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。 注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。 |
响应参数
| 参数 | 类型 | 描述 |
|---|---|---|
| id | String | 订单ID |
| baseSize | BigDecimal | 基础货币合约规模 |
| contractType | String | 合约类型:1:永续合约 |
| userId | Long | 合约账户用户ID |
| fee | BigDecimal | 手续费 |
| createdDate | Long | 订单创建时间戳 |
| currentPiece | BigDecimal | 当前合约数量 |
| direction | String | 交易方向:做多(long)/做空(short) |
| frozenFee | BigDecimal | 冻结手续费 |
| indexPrice | BigDecimal | 指数触发价格 |
| instrument | String | 交易品种的基础货币,例如BTC或ETH |
| leverage | BigDecimal | 持仓杠杆率 |
| liquidateBy | String | 开仓和平仓事件类型:Manual |
| makerFee | BigDecimal | maker费用 |
| takerFee | BigDecimal | taker费用 |
| margin | BigDecimal | 持仓使用的保证金 |
| orderPrice | BigDecimal | 用户指定的订单价格 |
| totalPiece | BigDecimal | 合约总数量 |
| orderStatus | String | 订单状态:unFinish:未成交,part:部分成交,Finish:完全成交,Cancel:已取消 |
| originalType | String | 原始订单类型 |
| posType | String | 持仓类型:plan/planTrigger/execute |
| positionMargin | BigDecimal | 持仓保证金 |
| positionModel | Integer | 持仓持仓模式:0:逐仓,1:全仓 |
| quantity | BigDecimal | 根据quantityUnit指定订单大小:如果quantityUnit=0,数量以USDT计量;如果quantityUnit=1,数量以合约计量;如果quantityUnit=2,数量以加密货币计量 |
| quantityUnit | Integer | 用于指定订单数量的计量单位: 0:以计价货币计价(例如,BTC-USDT 合约中的 USDT); 1:以合约张数计价; 2:以基础货币计价 (例如,BTC-USDT 合约中的 BTC)。s |
| status | String | 状态:open/close |
| stopLossPrice | String | 止损价格 |
| stopLossRate | String | 止损率 |
| stopProfitPrice | String | 止盈价格 |
| stopProfitRate | String | 止盈率 |
| stopLossOrderPrice | String | 止损限价 |
| stopProfitOrderPrice | String | 止盈限价 |
| updatedDate | Long | 最后订单更新时间戳 |
| source | String | 来源:web/api |
| thirdOrderId | String | 用户分配的自定义订单ID |
请求示例
以下Python代码展示了如何获取订单信息。
注意:完整代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
params = {
"positionType" : "execute",
# "instrument" : "btc",
"sourceIds" : "33308753606524437,33308753605637070,33308753616147587" }
api_url = "/v1/perpum/order"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # function FuturesRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface.)
注意:完整Java代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
响应示例
以下是上述Python请求返回的示例响应:
{'code': 0,
'data': [{'baseSize': 0.002,
'contractType': 1,
'createdDate': 1740905644000,
'currentPiece': 2,
'direction': 'long',
'fee': '0',
'frozenFee': '0.0168',
'id': 33308753605637070,
'indexPrice': 85880.1,
'instrument': 'BTC',
'leverage': 2,
'liquidateBy': 'manual',
'makerFee': '0.0001',
'margin': 84,
'orderPrice': 84000,
'orderStatus': 'unFinish',
'originalType': 'plan',
'posType': 'plan',
'positionMargin': 84,
'positionModel': 0,
'quantity': 100,
'quantityUnit': 0,
'source': 'api',
'status': 'open',
'stopLossPrice': 83000,
'stopLossRate': 0.02380952,
'stopProfitPrice': 95000,
'stopProfitRate': 0.2619048,
'takerFee': '0.0006',
'thirdOrderId': '103-12-53',
'totalPiece': 2,
'triggerPrice': 84400,
'triggerType': 1,
'updatedDate': 1740905777000,
'userId': 1162061}, {..........},{.......}],
'msg': ''}