Skip to main content

Set Trading Stop

tip

Pass the following parameters, then the system will create conditional orders. If the position is closed, the system will cancel these orders, and adjust the position size.

HTTP Request

POST /unified/v3/private/position/trading-stop

Request Parameters

ParameterRequiredTypeComments
categorytruestringProduct type. linear
symboltruestringSymbol name
takeProfitfalsestringCannot be less than 0, 0 means cancel TP
stopLossfalsestringCannot be less than 0, 0 means cancel SL
trailingStopfalsestringCannot be less than 0, 0 means cancel TS. note: valid for USDT Perpetual only
tpTriggerByfalsestringTake profit trigger price type. default: LastPrice
slTriggerByfalsestringStop loss trigger price type. default: LastPrice
activePricefalsestringTrailing stop trigger price. Trailing stop will be triggered when this price is reached only
tpSizefalsestringTake profit size. Valid in TP/SL partial mode
slSizefalsestringStop loss size. Valid in TP/SL partial mode
positionIdxtrueintegerUsed to identify positions in different position modes. 0: one-way mode for unified margin only

Response Parameters

None

Request Example

POST /unified/v3/private/position/trading-stop HTTP/1.1
Host: api-testnet.bybit.com
X-BAPI-SIGN: XXXX
X-BAPI-API-KEY: XXXX
X-BAPI-TIMESTAMP: 1672017116301
X-BAPI-RECV-WINDOW: 5000
Content-Type: application/json

{
"category": "linear",
"symbol":"BTCUSDT",
"takeProfit":"18000",
"stopLoss":"15500",
"tpTriggerBy":"MarkPrice",
"slTriggerBy":"MarkPrice",
"trailingStop": null,
"activePrice": null,
"slSize": "0.05",
"tpSize": "0.1",
"positionIdx": 0
}

Response Example

{
"retCode": 0,
"retMsg": "",
"result": {},
"retExtInfo": {},
"time": 1672017116958
}