Set Trading Stop
Set the take profit, stop loss or trailing stop for the position.
tip
- Passing these parameters will create conditional orders by the system internally.
- The system will cancel these orders if the position is closed, and adjust the qty according to the size of the open position.
- Support USDT Perpetual, Inverse Perpetual, Inverse Future and USDC Perpetual. Note: USDC Perpetual does not have partial TP/SL mode.
info
New version of TP/SL function supports both holding entire position TP/SL orders and holding partial position TP/SL orders.
- Full position TP/SL orders: This API can be used to modify the parameters of existing TP/SL orders.
- Partial position TP/SL orders: This API can only add partial position TP/SL orders.
note
Under the new version of Tp/SL function, when calling this API to perform one-sided take profit or stop loss modification on existing TP/SL orders on the holding position, it will cause the paired tp/sl orders to lose binding relationship. This means that when calling the cancel API through the tp/sl order ID, it will only cancel the corresponding one-sided take profit or stop loss order ID.
HTTP Request
POST /contract/v3/private/position/trading-stop
Request Parameters
Parameter | Required | Type | Comments |
---|---|---|---|
symbol | true | string | Symbol name |
takeProfit | false | string | Cannot be less than 0, 0 means cancel TP. Partial TP/SL cannot be cancelled by set it 0 |
stopLoss | false | string | Cannot be less than 0, 0 means cancel SL. Partial TP/SL cannot be cancelled by set it 0 |
tpslMode | false | string | TP/SL mode. Full : entire position TP/SL, Partial : partial position TP/SL. As each contract has an initial full TP/SL mode, if it has been modified before, it may be partial. Therefore, if not provided, the system will automatically retrieve the current TP/SL mode configuration for the contract. |
tpSize | false | string | Take profit size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal |
slSize | false | string | Stop loss size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal |
tpTriggerBy | false | string | Take profit trigger price type. default: LastPrice |
slTriggerBy | false | string | Stop loss trigger price type. default: LastPrice |
trailingStop | false | string | Cannot be less than 0, 0 means cancel TS |
activePrice | false | string | Trailing stop trigger price. Trailing stop will be triggered when this price is reached only |
tpLimitPrice | false | string | The limit order price when take profit price is triggered. Only works when tpslMode=Partial and tpOrderType=Limit |
slLimitPrice | false | string | The limit order price when stop loss price is triggered. Only works when tpslMode=Partial and slOrderType=Limit |
tpOrderType | false | string | The order type when take profit is triggered. Market (default), Limit . For tpslMode=Full, it only supports tpOrderType=Market |
slOrderType | false | string | The order type when stop loss is triggered. Market (default), Limit . For tpslMode=Full, it only supports slOrderType=Market |
positionIdx | false | string | Used to identify positions in different position modes. For hedge-mode, this param is required
|
Response Parameters
None
Request Example
POST /contract/v3/private/position/trading-stop HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1670852788387
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json
{
"symbol": "SOLPERP",
"takeProfit": "19",
"stopLoss": "10",
"activePrice": null,
"trailingStop": null,
"tpTriggerBy": null,
"slTriggerBy": null,
"tpslMode": "Partial",
"tpOrderType": "Limit"
"slOrderType": "Limit"
"tpSize": "50",
"slSize": "50",
"tpLimitPrice": "18",
"slLimitPrice": "11",
"positionIdx": 0
}
Response Example
{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1670852788558
}