Close Positions (TRADE)
- POST
/capi/v3/closePositions
Weight(IP): 40
Request parameters
| Parameter | Type | Required? | Description |
|---|---|---|---|
| symbol | String | No | Trading pair to close. |
| positionId | Long | No | Position ID. |
- When both
symbolandpositionIdare provided, the system closes the position specified bypositionId, and verifies that the position belongs to the trading pair specified bysymbol. If the verification fails, the request is rejected. - When both
symbolandpositionIdare empty, the system closes all open positions in the account. - When only
symbolis provided, the system closes all positions under the specified trading pair (symbol), including both long and short positions. - When only
positionIdis provided, the system closes the position corresponding to the specified position ID (positionId).
Request example
curl -X POST "https://api-contract.weex.com/capi/v3/closePositions" \
-H "ACCESS-KEY:*******" \
-H "ACCESS-SIGN:*******" \
-H "ACCESS-PASSPHRASE:*****" \
-H "ACCESS-TIMESTAMP:1659076670000" \
-H "Content-Type: application/json" \
-d '{
"symbol": "BTCUSDT"
}'
Response parameters
Returns an array of objects with the fields below:
| Field | Type | Description |
|---|---|---|
| positionId | Long | Position identifier. |
| success | Boolean | Whether the close action succeeded. |
| successOrderId | Long | Order ID created to close the position (when successful). |
| errorMessage | String | Failure reason when success = false. |
Response example
[
{
"positionId": 689987235755328154,
"success": true,
"successOrderId": 702345678901234580,
"errorMessage": ""
}
]