Skip to main content

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

ParameterRequiredTypeComments
symboltruestringSymbol name
takeProfitfalsestringCannot be less than 0, 0 means cancel TP. Partial TP/SL cannot be cancelled by set it 0
stopLossfalsestringCannot be less than 0, 0 means cancel SL. Partial TP/SL cannot be cancelled by set it 0
tpslModefalsestringTP/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.
tpSizefalsestringTake profit size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal
slSizefalsestringStop loss size. Valid in TP/SL partial mode only. Note: the value of tpSize and slSize must equal
tpTriggerByfalsestringTake profit trigger price type. default: LastPrice
slTriggerByfalsestringStop loss trigger price type. default: LastPrice
trailingStopfalsestringCannot be less than 0, 0 means cancel TS
activePricefalsestringTrailing stop trigger price. Trailing stop will be triggered when this price is reached only
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
positionIdxfalsestringUsed to identify positions in different position modes. For hedge-mode, this param is required
  • 0: one-way mode
  • 1: hedge-mode Buy side
  • 2: hedge-mode Sell side

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
}