Skip to main content

Set Trading Stop

Set the take profit, stop loss or trailing stop for the position.

Unified account covers: USDT perpetual / USDC contract / Inverse contract
Classic account covers: USDT perpetual / Inverse contract

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.

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 /v5/position/trading-stop

Request Parameters

ParameterRequiredTypeComments
categorytruestringProduct type
  • Unified account: linear, inverse
  • Classic account: linear, inverse. Please note that category is not involved with business logic
symboltruestringSymbol name
takeProfitfalsestringCannot be less than 0, 0 means cancel TP
stopLossfalsestringCannot be less than 0, 0 means cancel SL
trailingStopfalsestringTrailing stop by price distance. Cannot be less than 0, 0 means cancel TS
tpTriggerByfalsestringTake profit trigger price type
slTriggerByfalsestringStop loss trigger price type
activePricefalsestringTrailing stop trigger price. Trailing stop will be triggered when this price is reached only
tpslModetruestringTP/SL mode. Full: entire position TP/SL, Partial: partial position TP/SL
tpSizefalsestringTake profit size. Valid in TP/SL partial mode. Note: the value of tpSize and slSize must equal
slSizefalsestringStop loss size. Valid in TP/SL partial mode. Note: the value of tpSize and slSize must equal
tpLimitPricefalsestringThe limit order price when take profit price is triggered. Only works when tpslMode=Partial and tpOrderType=Limit
slLimitPricefalsestringThe limit order price when stop loss price is triggered. Only works when tpslMode=Partial and slOrderType=Limit
tpOrderTypefalsestringThe order type when take profit is triggered. Market(default), Limit. For tpslMode=Full, it only supports tpOrderType=Market
slOrderTypefalsestringThe order type when stop loss is triggered. Market(default), Limit. For tpslMode=Full, it only supports slOrderType=Market
positionIdxtrueintegerUsed to identify positions in different position modes.
  • 0: one-way mode
  • 1: hedge-mode Buy side
  • 2: hedge-mode Sell side

Response Parameters

None


Request Example

POST /v5/position/trading-stop HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXXX
X-BAPI-API-KEY: XXXXX
X-BAPI-TIMESTAMP: 1672283124270
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"category":"linear",
"symbol": "XRPUSDT",
"takeProfit": "0.6",
"stopLoss": "0.2",
"tpTriggerBy": "MarkPrice",
"slTriggerBy": "IndexPrice",
"tpslMode": "Partial",
"tpOrderType": "Limit",
"slOrderType": "Limit",
"tpSize": "50",
"slSize": "50",
"tpLimitPrice": "0.57",
"slLimitPrice": "0.21",
"positionIdx": 0
}

Response Example

{
"retCode": 0,
"retMsg": "OK",
"result": {},
"retExtInfo": {},
"time": 1672283125359
}