获取止损/止盈信息
API说明
此接口允许查询合约交易中已成交和未成交订单的止损(SL)和止盈(TP)信息。
注意 :待处理订单数据只能通过 RESTful API 获取。
注意事项
无
认证
这是一个私有接口,需要认证。有关使用RESTful API的详细信息,请参考简介 > 认证和代码示例 > 合约 > RESTful私有接口。
请求方法
GET
接口地址
频率限制
该接口的调用频率限制为:每个 IP 和用户 ID 每2秒最多请求10次。
此外,该接口还受到全局频率限制的约束。
有关"全局速率限制"和"API限频策略"的详细信息,请参阅“频率限制”部分,跳转
请求参数
| 参数 | 必填 | 类型 | 描述 |
|---|---|---|---|
| orderId | false | Long | 订单ID |
| openId | false | Long | 持仓ID |
| planOrderId | false | Long | 计划订单ID |
| stopFrom | true | Integer | 止损和止盈订单类型: 1:需要“plan”订单的订单 ID。 2:需要“execute”市场的仓位 ID。 3:需要“planTrigger”订单的计划订单 ID。 注意: 根据订单类型,必须指定相应的 ID。 |
| instrument | false | String | 交易品种的基础货币(例如,BTC或btc)。此参数不区分大小写。注意:对于以数字开头的交易品种(例如1000PEPE),大写和小写格式都有效。 |
响应参数
| 参数 | 类型 | 描述 |
|---|---|---|
| currentPiece | BigDecimal | 当前止损和止盈订单数量 |
| closePiece | BigDecimal | 批量止损和止盈订单中的合约数量 |
| direction | String | 交易方向:做多(long),做空(short) |
| createdDate | Long | 订单创建时间戳 |
| updatedDate | Long | 最新更新时间戳 |
| id | String | ID |
| indexPrice | BigDecimal | 触发时的指数价格 |
| instrument | String | 交易品种的基础货币,例如BTC或ETH |
| leverage | Integer | 持仓杠杆率 |
| openId | Long | 持仓ID |
| priceType | Integer | 止损和止盈触发价格类型:1:指数价格,2:最新价格,3:标记价格 |
| stopLossPrice | BigDecimal | 止损价格 |
| stopLossRate | BigDecimal | 止损率 |
| stopProfitPrice | BigDecimal | 止盈价格 |
| stopProfitRate | BigDecimal | 止盈率 |
| stopLossOrderPrice | String | 止损限价 |
| stopProfitOrderPrice | String | 止 盈限价 |
| stopProfitType | String | 触发后的永续合约计划订单类型:plan:限价,execute:市价 |
| stopLossType | String | 触发后的永续合约计划订单类型:plan:限价,execute:市价 |
| triggerStatus | Integer | 止盈和止损触发状态:0:未触发,1:已触发,2:已取消 |
| userId | Long | 合约账户用户ID |
| positionModel | Integer | 持仓持仓模式:0:逐仓,1:全仓 |
| stopType | Integer | 止损和止盈订单类型:1:限价单,2:市价单,3:计划单 |
| orderId | Long | 订单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': ''}