跳到主要内容

获取订单信息

API说明

此接口提供当前未成交订单的信息。用户可以指定订单ID列表来查询特定订单。如果既未指定合约也未指定订单ID,响应将包括指定订单类型下的所有未成交订单。响应包括诸如合约、交易方向、数量、数量单位、保证金、杠杆、maker费用、taker费用、时间戳等详情。

注意:订单信息数据只能通过 RESTful API 获取。

注意事项

  1. 该接口仅用于获取未成交订单信息,不支持通过 orderId 批量查询全部订单记录,请勿混淆使用场景。
  2. 请求参数"positionType"可能会返回超出指定类型的额外数据。例如:如果设置为execute(市价单),响应可能还包括plan订单(限价单)。对于"planTrigger",只有在订单触发并下单后才会返回响应。对于"moveStopProfitLoss",响应按预期工作。

认证

这是一个私有接口,需要认证。有关使用RESTful API的详细信息,请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。

请求方法

GET

接口地址

v1/perpum/order

频率限制

该接口的调用频率限制为:每个 IP 和用户 ID 每秒最多请求10次。
此外,该接口还受到全局频率限制的约束。
有关"全局速率限制"和"API限频策略"的详细信息,请参阅“频率限制”部分,跳转

请求参数

参数必填类型描述
sourceIdsfalseString以逗号(,)分隔的订单ID列表。例如:"orderId1,orderId2,orderId3"
注意:订单ID数量不能超过20个。
positionTypetrueString订单类型:execute/plan/moveStop/stopProfitLoss
execute:市价单,
plan:计划单,
moveStop:追踪止损和止盈,
stopProfitLoss:止损和止盈
instrumentfalseString交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。
注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。

响应参数

参数类型描述
idString订单ID
baseSizeBigDecimal基础货币合约规模
contractTypeString合约类型:1:永续合约
userIdLong合约账户用户ID
feeBigDecimal手续费
createdDateLong订单创建时间戳
currentPieceBigDecimal当前合约数量
directionString交易方向:做多(long)/做空(short)
frozenFeeBigDecimal冻结手续费
indexPriceBigDecimal指数触发价格
instrumentString交易品种的基础货币,例如BTC或ETH
leverageBigDecimal持仓杠杆率
liquidateByString开仓和平仓事件类型:Manual
makerFeeBigDecimalmaker费用
takerFeeBigDecimaltaker费用
marginBigDecimal持仓使用的保证金
orderPriceBigDecimal用户指定的订单价格
totalPieceBigDecimal合约总数量
orderStatusString订单状态:unFinish:未成交,part:部分成交,Finish:完全成交,Cancel:已取消
originalTypeString原始订单类型
posTypeString持仓类型:plan/planTrigger/execute
positionMarginBigDecimal持仓保证金
positionModelInteger持仓持仓模式:0:逐仓,1:全仓
quantityBigDecimal根据quantityUnit指定订单大小:如果quantityUnit=0,数量以USDT计量;如果quantityUnit=1,数量以合约计量;如果quantityUnit=2,数量以加密货币计量
quantityUnitInteger用于指定订单数量的计量单位:
0:以计价货币计价(例如,BTC-USDT 合约中的 USDT);
1:以合约张数计价;
2:以基础货币计价(例如,BTC-USDT 合约中的 BTC)。s
statusString状态:open/close
stopLossPriceString止损价格
stopLossRateString止损率
stopProfitPriceString止盈价格
stopProfitRateString止盈率
stopLossOrderPriceString止损限价
stopProfitOrderPriceString止盈限价
updatedDateLong最后订单更新时间戳
sourceString来源:web/api
thirdOrderIdString用户分配的自定义订单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': ''}