Batch Close Position
Batch Close Position
Batch close all positions for a specified product, supporting spot, coin-margined contracts, and USDT-margined contracts
Request frequency limit: 1/1s
Request URL
POST /deepcoin/trade/batch-close-position
Request Parameters
Field Name | Required | Type | Description |
---|---|---|---|
productGroup | true | string | Product group Spot: Spot Coin-margined: Swap USDT-margined: SwapU |
instId | true | string | Product ID |
Request Example
// Batch close spot positions
{
"productGroup": "Spot",
"instId": "BTC-USDT"
}
// Batch close coin-margined contract positions
{
"productGroup": "Swap",
"instId": "BTC-USD-SWAP"
}
// Batch close USDT-margined contract positions
{
"productGroup": "SwapU",
"instId": "BTC-USDT-SWAP"
}
Response Parameters
Field Name | Type | Description |
---|---|---|
errorList | array | Error list containing detailed information of failed closures |
ClosePositionErrorItem Structure in errorList
Field Name | Type | Description |
---|---|---|
memberId | string | Member ID |
accountId | string | Account ID |
tradeUnitId | string | Trade unit ID |
instId | string | Product ID |
posiDirection | string | Position direction |
errorCode | int | Error code |
errorMsg | string | Error message |
Response Example
// Successful response (all positions closed successfully)
{
"code": "0",
"msg": "",
"data": {
"errorList": []
}
}
// Partial failure response
{
"code": "0",
"msg": "",
"data": {
"errorList": [
{
"memberId": "10001",
"accountId": "100001234",
"tradeUnitId": "TU001",
"instId": "BTC-USDT-SWAP",
"posiDirection": "long",
"errorCode": 51020,
"errorMsg": "Insufficient position"
},
{
"memberId": "10001",
"accountId": "100001234",
"tradeUnitId": "TU002",
"instId": "BTC-USDT-SWAP",
"posiDirection": "short",
"errorCode": 51008,
"errorMsg": "Order does not exist"
}
]
}
}
Description
Functionality
- Batch close all positions for a specified product
- Supports spot (Spot), coin-margined contracts (Swap), and USDT-margined contracts (SwapU)
- Uses concurrent processing to improve efficiency
- Returns an error list containing detailed information about all failed closures
Processing Logic
- Calls different services (spot/contracts) based on
productGroup
- Processes multiple position closures concurrently
- Collects all position closure failure error information
- Even if some positions fail to close, successful positions will still be closed
Notes
- This API will close all positions for the specified product, please use with caution
- An empty error list indicates all positions were closed successfully
- Failed closures of some positions will not affect the closure operations of other positions