Modify Position Take Profit and Stop Loss
Modify Position Take Profit and Stop Loss
Modify existing position take profit and stop loss orders, supporting both spot and contract trading.
Request frequency limit: 1/s
Rate limit rule: UserID
Request URL
POST /deepcoin/trade/modify-position-sltp
Request Parameters
| Field Name | Required | Type | Description |
|---|---|---|---|
| instType | true | string | Product type Spot: SPOTContract: SWAP |
| instId | true | string | Product ID e.g., BTC-USDT for spot, BTC-USDT-SWAP for contract |
| ordId | true | string | SLTP Order ID (obtained from set-position-sltp response) |
| posSide | false | string | Position side (required for contract) Long: longShort: short |
| mrgPosition | false | string | Margin position mode (for contract) Merged: mergeSplit: split |
| tdMode | false | string | Trade mode (for contract) Cross margin: crossIsolated margin: isolated |
| posId | false | string | Position ID (required when mrgPosition is split) |
| tpTriggerPx | false | string | Take profit trigger price At least one of TP or SL must be set |
| tpTriggerPxType | false | string | Take profit trigger price type Last price: lastIndex price: indexMark price: markDefault: last |
| tpOrdPx | false | string | Take profit order price-1 means market priceDefault: -1 |
| slTriggerPx | false | string | Stop loss trigger price At least one of TP or SL must be set |
| slTriggerPxType | false | string | Stop loss trigger price type Last price: lastIndex price: indexMark price: markDefault: last |
| slOrdPx | false | string | Stop loss order price-1 means market priceDefault: -1 |
| sz | false | string | Position size for partial TP/SL Empty means full position |
Notes:
ordIdis required and must be a valid pending SLTP order ID- At least one of
tpTriggerPxorslTriggerPxmust be provided - For contract trading with split position mode (
mrgPosition=split),posIdis required - For spot trading,
posSide,mrgPosition,tdMode, andposIdare not applicable - The order ID is obtained from the
set-position-sltpAPI response
Request Example
Spot - Modify both take profit and stop loss:
{
"instType": "SPOT",
"instId": "BTC-USDT",
"ordId": "1000762096073860",
"tpTriggerPx": "110000",
"slTriggerPx": "103000"
}
Contract - Modify TP/SL for long position (merged mode):
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "1000596069447069",
"posSide": "long",
"mrgPosition": "merge",
"tdMode": "cross",
"tpTriggerPx": "110000",
"tpTriggerPxType": "mark",
"tpOrdPx": "-1",
"slTriggerPx": "103000",
"slTriggerPxType": "mark",
"slOrdPx": "-1"
}
Contract - Modify TP/SL for specific position (split mode):
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "1000596069492933",
"posSide": "long",
"mrgPosition": "split",
"tdMode": "isolated",
"posId": "1000596069432784",
"tpTriggerPx": "111000",
"tpTriggerPxType": "mark",
"tpOrdPx": "-1",
"slTriggerPx": "104000",
"slTriggerPxType": "mark",
"slOrdPx": "-1",
"sz": "200"
}
Modify only take profit:
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "1000596069447069",
"posSide": "long",
"mrgPosition": "merge",
"tdMode": "cross",
"tpTriggerPx": "112000",
"tpTriggerPxType": "mark",
"tpOrdPx": "-1"
}
Modify only stop loss:
{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "1000596069447069",
"posSide": "long",
"mrgPosition": "merge",
"tdMode": "cross",
"slTriggerPx": "101000",
"slTriggerPxType": "mark",
"slOrdPx": "-1"
}
Response Parameters
| Field Name | Type | Description |
|---|---|---|
| ordId | string | SLTP Order ID |
| sCode | string | Event execution result status code0: Success |
| sMsg | string | Rejection message if the request is unsuccessful |
Response Example
Successful response:
{
"code": "0",
"msg": "",
"data": {
"ordId": "1000596069447069",
"sCode": "0",
"sMsg": ""
}
}
Failed response:
{
"code": "51400",
"msg": "Order not found",
"data": {
"ordId": "",
"sCode": "51400",
"sMsg": "Order does not exist or has been executed"
}
}
Description
Functionality
- Modify existing position take profit and/or stop loss orders
- Supports both spot (SPOT) and contract (SWAP) trading
- Allows partial position TP/SL modification by specifying
szparameter - Supports different trigger price types (last, index, mark)
- Can modify market or limit order price for TP/SL execution
- Can modify only take profit or only stop loss independently
Use Cases
- Strategy Adjustment: Adjust TP/SL levels based on market conditions
- Risk Management: Tighten or loosen stop loss based on position performance
- Profit Optimization: Adjust take profit targets as price moves favorably
- Partial Position Management: Modify TP/SL for only part of the position
Important Notes
- Order ID Required: Must provide valid
ordIdfrom the set-position-sltp response - Order Status: Can only modify pending TP/SL orders (not yet triggered or executed)
- Price Precision: Trigger prices must comply with the product's price precision requirements
- Parameter Consistency: Parameters like
instId,posSide,mrgPositionshould match the original order - At Least One: Must modify at least one of take profit or stop loss
- Split Mode: For split position mode,
posIdis required - Query Orders: Use trigger-orders-pending API to query existing TP/SL orders and get their IDs
Related APIs
- Set Position TP/SL:
/deepcoin/trade/set-position-sltp- Create new TP/SL orders - Cancel Position TP/SL:
/deepcoin/trade/cancel-position-sltp- Cancel TP/SL orders - Query Pending Trigger Orders:
/deepcoin/trade/trigger-orders-pending- Query existing TP/SL orders
Common Errors
| Error Code | Error Message | Solution |
|---|---|---|
| 51400 | Order not found | Check if ordId is correct and order has not been canceled or executed |
| 51000 | Parameter error | Verify all required parameters are provided and formatted correctly |
| 51001 | At least one of TP or SL must be set | Provide at least tpTriggerPx or slTriggerPx |