跳到主要内容

获取未成交订单

API说明

此接口允许查询指定合约和订单类型的未成交订单详情,包括合约、方向、数量、数量单位、保证金、杠杆、maker费用、taker费用和时间戳。

注意:当前订单数据可通过RESTful和Websocket接口获取。本页是RESTful接口的描述。如需了解Websocket接口,请参见 跳转

注意事项

  1. 此接口不支持在单个请求中检索所有交易品种未成交订单。

  2. 如果指定合约没有未成交订单,将返回以下响应:

{'code': 0, 'data': {'nextId': 0, 'prevId': 0, 'rows': [], 'total': 0}, 'msg': ''}
  1. 请求参数 "positionType" 为必填项,但其行为可能存在异常,例如,指定"execute"可能仍会返回"plan"订单。相较而言,设置为 "planTrigger" 或 "moveStopProfitLoss" 时,筛选逻辑能够按预期生效。

认证

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

请求方法

GET

接口地址

/v1/perpum/orders/open

频率限制

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

请求参数

参数必填类型描述
instrumenttrueString交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。
positionTypetrueString订单类型:plan/execute/planTrigger/moveStopProfitLoss
plan:计划订单,
execute:市价单,
planTrigger:计划触发订单,
moveStopProfitLoss:追踪止损/止盈
pagefalseInteger当前页码
pageSizefalseInteger每页记录数

响应参数

参数类型描述
idString订单ID
userIdLong合约合约用户ID
baseSizeBigDecimal基础货币订单规模
createdDatetimestamp订单创建时间戳
currentPieceBigDecimal以合约数量计的订单规模
directionString订单方向:做多(long),做空(short)
frozenFeeBigDecimal冻结订单费用
indexPriceBigDecimal指数触发价格
instrumentString交易品种的基础货币,例如BTC或ETH
leverageBigDecimal持仓杠杆率
liquidateByString开仓和平仓事件类型:planClose/manual
marginBigDecimal持仓使用的保证金
orderPriceBigDecimal用户指定的订单价格
orderStatusString订单状态:unFinish:未成交,part:部分成交,Finish:完全成交,Cancel:已取消
originalTypeString原始订单类型
posTypeString持仓类型:plan/planTrigger/execute
positionMarginBigDecimal持仓保证金
positionModelInteger持仓持仓模式:0:逐仓,1:全仓
quantityString基于quantityUnit 指定订单数量:
当 quantityUnit = 0 时,数量以计价货币计量(例如,BTC-USDT 中的 USDT);
当 quantityUnit = 1 时,数量以合约张数计量;
当 quantityUnit = 2 时,数量以基础货币计量(例如,BTC-USDT 中的 BTC)。
quantityUnitBigDecimal用于指定订单数量的计量单位:
0:以计价货币计价(例如,BTC-USDT 合约中的 USDT);
1:以合约张数计价;
2:以基础货币计价(例如,BTC-USDT 合约中的 BTC)。
statusString状态:open(开仓),close(平仓)
takerFeeBigDecimaltaker费用
totalPieceBigDecimal合约总数量
updatedDateString最后订单更新时间戳
primaryIdLongCoinW数据库ID(用户可忽略)
contractTypeInteger合约类型:1:U本位永续合约
totalInteger当前订单总数
openIdLong持仓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': ''}