Skip to main content

Cancel Position Take Profit and Stop Loss

Cancel Position Take Profit and Stop Loss​

Cancel existing position take profit and stop loss orders, supporting both spot and contract trading.

Rate limit rule: UserID

Request URL​

POST /deepcoin/trade/cancel-position-sltp

Request Parameters​

Field NameRequiredTypeDescription
instTypetruestringProduct type
Spot: SPOT
Contract: SWAP
instIdtruestringProduct ID
e.g., BTC-USDT for spot, BTC-USDT-SWAP for contract
ordIdtruestringSLTP Order ID
Obtained from set-position-sltp API response or trigger order query

Notes:

  • The ordId is returned when setting position TP/SL via the set-position-sltp API
  • You can also query pending trigger orders to get the ordId

Request Example​

Cancel spot position TP/SL:

{
"instType": "SPOT",
"instId": "BTC-USDT",
"ordId": "1000762096073860"
}

Cancel contract position TP/SL:

{
"instType": "SWAP",
"instId": "BTC-USDT-SWAP",
"ordId": "1000596068909100"
}

Response Parameters​

Field NameTypeDescription
ordIdstringOrder ID
sCodestringEvent execution result status code
0: Success
sMsgstringRejection message if the request is unsuccessful

Response Example​

Successful response:

{
"code": "0",
"msg": "",
"data": {
"ordId": "1000762096073860",
"sCode": "0",
"sMsg": ""
}
}

Failed response (order not found):

{
"code": "51400",
"msg": "Order does not exist",
"data": {
"ordId": "1000762096073860",
"sCode": "51400",
"sMsg": "Order does not exist"
}
}

Failed response (order already executed):

{
"code": "51401",
"msg": "Order already executed",
"data": {
"ordId": "1000762096073860",
"sCode": "51401",
"sMsg": "Order already executed or canceled"
}
}

Description​

Functionality​

  • Cancel existing position take profit and stop loss orders
  • Supports both spot (SPOT) and contract (SWAP) trading
  • Can only cancel pending TP/SL orders (not yet triggered)

Use Cases​

  1. Strategy Adjustment: Cancel existing TP/SL to set new levels
  2. Market Change Response: Remove TP/SL when market conditions change
  3. Manual Control: Take manual control of position closing instead of automatic TP/SL
  4. Error Correction: Cancel incorrectly set TP/SL orders

Important Notes​

  1. Order ID Required: You must have the ordId from the set-position-sltp response
  2. Order Status: Can only cancel pending orders; already triggered or executed orders cannot be canceled
  3. Query Orders: Use the trigger-orders-pending API to query existing TP/SL orders and get their IDs
  4. Timing: Once a TP/SL order is triggered, it cannot be canceled
  5. Verification: Ensure the order belongs to your account before attempting to cancel
  • Set Position TP/SL: /deepcoin/trade/set-position-sltp - Set new TP/SL orders
  • Modify Position TP/SL: /deepcoin/trade/modify-position-sltp - Modify existing TP/SL orders
  • Query Pending Trigger Orders: /deepcoin/trade/trigger-orders-pending - Query existing TP/SL orders
  • Query Trigger Order History: /deepcoin/trade/trigger-orders-history - Query historical TP/SL orders