跳到主要内容

获取止损/止盈信息

API说明

此接口允许查询合约交易中已成交和未成交订单的止损(SL)和止盈(TP)信息。

注意 :待处理订单数据只能通过 RESTful API 获取。

注意事项

认证

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

请求方法

GET

接口地址

/v1/perpum/TPSL

频率限制

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

请求参数

参数必填类型描述
orderIdfalseLong订单ID
openIdfalseLong持仓ID
planOrderIdfalseLong计划订单ID
stopFromtrueInteger止损和止盈订单类型:
1:需要“plan”订单的订单 ID。
2:需要“execute”市场的仓位 ID。
3:需要“planTrigger”订单的计划订单 ID。
注意: 根据订单类型,必须指定相应的 ID。
instrumentfalseString交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。

响应参数

参数类型描述
currentPieceBigDecimal当前止损和止盈订单数量
closePieceBigDecimal批量止损和止盈订单中的合约数量
directionString交易方向:做多(long),做空(short)
createdDateLong订单创建时间戳
updatedDateLong最新更新时间戳
idStringID
indexPriceBigDecimal触发时的指数价格
instrumentString交易品种的基础货币,例如BTC或ETH
leverageInteger持仓杠杆率
openIdLong持仓ID
priceTypeInteger止损和止盈触发价格类型:1:指数价格,2:最新价格,3:标记价格
stopLossPriceBigDecimal止损价格
stopLossRateBigDecimal止损率
stopProfitPriceBigDecimal止盈价格
stopProfitRateBigDecimal止盈率
stopLossOrderPriceString止损限价
stopProfitOrderPriceString止盈限价
stopProfitTypeString触发后的永续合约计划订单类型:plan:限价,execute:市价
stopLossTypeString触发后的永续合约计划订单类型:plan:限价,execute:市价
triggerStatusInteger止盈和止损触发状态:0:未触发,1:已触发,2:已取消
userIdLong合约账户用户ID
positionModelInteger持仓持仓模式:0:逐仓,1:全仓
stopTypeInteger止损和止盈订单类型:1:限价单,2:市价单,3:计划单
orderIdLong订单ID

请求示例

以下Python代码展示了如何获取已成交订单的止损和止盈信息。

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

params = {
"openId" : "2435521222632076385", # 持仓ID
"stopFrom" : "2", # 2: 持仓
}
api_url = "/v1/perpum/TPSL"
method = "GET"
response_code, response_data = FuturesRestfulPrivate(params, api_url, method, sec_key, api_key)
print(f"Response Code: {response_code}") # function FuturesRestfulPrivate() is defined in section (Introduction > Authentication & Code Snippet > Futures > RESTful Private Interface)

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

响应示例

以下是上述Python请求返回的示例响应:

{'code': 0,
'data': [{'closePiece': 2,
'createdDate': 1740771128000,
'currentPiece': 2,
'direction': 'long',
'id': 33308288734471132,
'indexPrice': 84530.2,
'instrument': 'BTC',
'leverage': 2,
'openId': 2435521222632076385,
'positionModel': 0,
'priceType': 2,
'stopLossPrice': 82000,
'stopLossRate': 0.05404302,
'stopLossType': 'execute',
'stopProfitPrice': 95000,
'stopProfitRate': 0.2544624,
'stopProfitType': 'execute',
'stopType': 2,
'triggerStatus': 0,
'updatedDate': 1740771128000,
'userId': 1162061}],
'msg': ''}