Close Position By IDs
Close Position By IDs
Close specific positions by specified position ID list, supporting spot, coin-margined contracts, and USDT-margined contracts
Request frequency limit: 1/1s
Request URL
POST /deepcoin/trade/close-position-by-ids
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 |
positionIds | true | []string | Position ID list, must contain at least one ID |
Request Example
// Close specified spot positions
{
"productGroup": "Spot",
"instId": "BTC-USDT",
"positionIds": ["pos123", "pos456"]
}
// Close specified coin-margined contract positions
{
"productGroup": "Swap",
"instId": "BTC-USD-SWAP",
"positionIds": ["pos789", "pos012", "pos345"]
}
// Close specified USDT-margined contract positions
{
"productGroup": "SwapU",
"instId": "BTC-USDT-SWAP",
"positionIds": ["pos678"]
}
// Close multiple positions
{
"productGroup": "SwapU",
"instId": "ETH-USDT-SWAP",
"positionIds": [
"1001063717138767",
"1001063717138768",
"1001063717138769",
"1001063717138770"
]
}
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 specified 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": 51404,
"errorMsg": "Position does not exist"
}
]
}
}
// All failures response
{
"code": "0",
"msg": "",
"data": {
"errorList": [
{
"memberId": "10001",
"accountId": "100001234",
"tradeUnitId": "TU001",
"instId": "BTC-USDT-SWAP",
"posiDirection": "long",
"errorCode": 51404,
"errorMsg": "Position does not exist"
},
{
"memberId": "10001",
"accountId": "100001234",
"tradeUnitId": "TU002",
"instId": "BTC-USDT-SWAP",
"posiDirection": "short",
"errorCode": 51404,
"errorMsg": "Position does not exist"
}
]
}
}
Description
Functionality
- Close specific positions by specified position ID list
- Supports spot (Spot), coin-margined contracts (Swap), and USDT-margined contracts (SwapU)
- Can close multiple specified positions at once
- Uses concurrent processing to improve efficiency
Processing Logic
- Internally calls the same
doClosePositionInternal
method as batch close position - Filters through
positionIds
parameter to only close positions with specified IDs - Processes multiple position closures concurrently
- Collects all position closure failure error information
Notes
positionIds
must contain at least one position ID- Only positions specified in the list will be closed, other positions will not be affected
- An empty error list indicates all specified positions were closed successfully
- Failed closures of some positions will not affect the closure operations of other positions
- If a position ID does not exist or has already been closed, corresponding error information will be returned in the error list