跳到主要内容

获取批量历史订单(3个月)

API说明

该接口返回过去三个月的历史订单记录,并支持通过“symbols”参数进行批量查询。用户可通过页码、每页数量和订单类型进行筛选。返回结果包含订单状态、保证金、杠杆以及订单数量等关键订单信息。

注意: 批量历史订单数据只能通过 RESTful API 获取。

注意事项

  1. 此接口仅返回已执行(即已进入交易)的订单。

认证

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

请求方法

GET

接口地址

/v1/perpum/orders/batchInsArchive

频率限制

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

请求参数

参数必填类型描述
pagefalseInteger当前页码, 默认值:500
pageSizefalseInteger每页结果数。默认值:500
注意:订单数量上限为 500 笔
originTypetrueString初始订单类型:plan/planTrigger/execute
execute:市价单
plan:用于不同计划订单,包括限价单、触发限价单、带SL/TP的限价单、带SL/TP的触发限价单、触发市价单、带SL/TP的触发市价单
planTrigger:计划触发订单
symbolstrueString使用逗号分隔的基础币种简称来指定多个交易品种。
例如:"BTC,ETH,1000PEPE"
注意:USDT 合约只需传入基础货币名称,如 BTCUSDT 传 BTC 即可。单次请求最多允许指定20个交易品种。

响应参数

参数类型描述
userIdLong合约账户用户ID
baseSizeBigDecimal基础货币订单规模
completeUsdtBigDecimalUSDT交易金额
createdDateLong订单创建的时间戳
currentPieceBigDecimal当前持有的合约数量
directionString交易方向:做多(long)/做空(short)
entrustUsdtBigDecimalUSDT订单规模
havShortfallBoolean表示用户是否有清算风险
hedgeIdLong关联对冲ID
indexPriceBigDecimal指数价格/最新价格
instrumentString交易品种的基础货币,例如BTC或ETH
leverageBigDecimal持仓杠杆率
liquidateByString开仓和平仓事件类型:Manual
marginBigDecimal持仓使用的保证金
openIdLong持仓ID
orderIdLongID(用户可忽略)
orderPriceBigDecimal用户设置的订单价格。注意:市价单情况下忽略
orderStatusString订单状态:unFinish:未成交part:部分成交Finish:完全成交Cancel:已取消
originalTypeString原始订单类型
posTypeString持仓类型:plan/planTrigger/execute
positionModelInteger持仓模式:0:逐仓,1:全仓
quantityBigDecimal基于quantityUnit 指定订单数量:
当 quantityUnit = 0 时,数量以计价货币计量(例如,BTC-USDT 中的 USDT);
当 quantityUnit = 1 时,数量以合约张数计量;
当 quantityUnit = 2 时,数量以基础货币计量(例如,BTC-USDT 中的 BTC)。
quantityUnitInteger用于指定订单数量的计量单位:
0:以计价货币计价(例如,BTC-USDT 合约中的 USDT);
1:以合约张数计价;
2:以基础货币计价(例如,BTC-USDT 合约中的 BTC)。
statusString状态:open/close
totalPieceString合约总数量
updatedDateDate最新交易更新的时间戳
thirdOrderIdString自定义订单ID
tradePieceInteger要交易的合约
stepMarginVersionInteger(用户可忽略)
idLong订单ID
cancelPieceInteger取消的合约数量
contractTypeInteger合约类型:1:U本位永续合约
sourceString来源:web/api
avgPriceString平均成交价格
triggerPriceString永续合约计划订单的触发价格
triggerTypeInteger指定触发价格满足时的订单类型:0:限价单,1:市价单
thirdOrderIdString用户分配的自定义订单ID

请求示例

以下Python代码展示了如何获取过去三个月的历史订单记录。

注意:完整代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。

params = {
"page" : 1,
"pageSize" : 5,
"originType" : "execute",
"symbols" : "BTC,ETH,XRP",
}

api_url = "/v1/perpum/orders/batchInsArchive"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key) # 函数FuturesRestuflPrivate()在章节 (简介 > 认证和代码示例 > 合约 > RESTful私有接口)

注意:完整Java代码示例请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。

响应示例

以下是上述Python请求返回的示例响应。该响应包含过去三个月内5个订单。为简洁起见,下面仅显示三个订单:

{'code': 0, 
'data':
{'nextId': 0,
'prevId': 0,
'rows':
[{'avgPrice': '3027.94',
'base': 'eth',
'baseSize': '0',
'cancelPiece': 0,
'completeUsdt': '60.5588',
'contractType': 1,
'createdDate': 1763452322000,
'currentPiece': '2',
'direction': 'long',
'entrustUsdt': '60.5588',
'fee': 0.03633528,
'finalOrderStatus': 'finish',
'havShortfall': False,
'hedgeId': 23765440242368518,
'id': '33309107055452107',
'indexPrice': '3027.92',
'instrument': 'ETH',
'leverage': '3',
'liquidateBy': 'manual',
'margin': '0.030279400000002',
'openId': 2435521222639519743,
'orderId': 2776199686,
'orderPrice': '2147483647',
'orderStatus': 'finish',
'originalType': 'execute',
'posType': 'execute',
'positionModel': 0,
'quantity': '2',
'quantityUnit': 1,
'quote': 'usdt',
'source': 'web',
'status': 'open',
'stepMarginVersion': 0,
'thirdOrderId': '',
'totalPiece': '2',
'tradePiece': 2,
'updatedDate': 1763452322000,
'userId': 1162061},
{'avgPrice': '2.1602',
'base': 'xrp',
'baseSize': '0',
'cancelPiece': 0,
'completeUsdt': '21.602',
'contractType': 1,
'createdDate': 1763452306000,
'currentPiece': '1',
'direction': 'long',
'entrustUsdt': '21.602',
'fee': 0.0129612,
'finalOrderStatus': 'finish',
'havShortfall': False,
'hedgeId': 23765438112317446,
'id': '33309107055004625',
'indexPrice': '2.1603',
'instrument': 'XRP',
'leverage': '50',
'liquidateBy': 'manual',
'margin': '0.4328',
'openId': 2435521222639519647,
'orderId': 1760048126,
'orderPrice': '0',
'orderStatus': 'finish',
'originalType': 'execute',
'posType': 'execute',
'positionModel': 0,
'quantity': '0.4328',
'quantityUnit': 1,
'quote': 'usdt',
'source': 'web',
'status': 'close',
'stepMarginVersion': 0,
'thirdOrderId': '',
'totalPiece': '1',
'tradePiece': 1,
'updatedDate': 1763452306000,
'userId': 1162061}, .........
{'avgPrice': '104411.5',
'base': 'btc',
'baseSize': '0',
'cancelPiece': 0,
'completeUsdt': '626.469',
'contractType': 1,
'createdDate': 1762867068000,
'currentPiece': '6',
'direction': 'short',
'entrustUsdt': '626.469',
'fee': 0.3758814,
'finalOrderStatus': 'finish',
'havShortfall': False,
'hedgeId': 23688729854065670,
'id': '33309091808516140',
'indexPrice': '104410.3',
'instrument': 'BTC',
'leverage': '13',
'liquidateBy': 'manual',
'margin': '1.8100769230769376',
'openId': 2435521222639289274,
'orderId': 3060259335,
'orderPrice': '0',
'orderStatus': 'finish',
'originalType': 'execute',
'posType': 'execute',
'positionModel': 0,
'quantity': '50',
'quantityUnit': 0,
'quote': 'usdt',
'source': 'web', '
status': 'open',
'stepMarginVersion': 0,
'thirdOrderId': '',
'totalPiece': '6',
'tradePiece': 6,
'updatedDate': 1762867068000,
'userId': 1162061}],
'total': 27},
'msg': ''}