Skip to main content
Version: V3(BETA)

Close Positions (TRADE)

  • POST /capi/v3/closePositions

Weight(IP): 40

Request parameters

ParameterTypeRequired?Description
symbolStringNoTrading pair to close.
positionIdLongNoPosition ID.
  • When both symbol and positionId are provided, the system closes the position specified by positionId, and verifies that the position belongs to the trading pair specified by symbol. If the verification fails, the request is rejected.
  • When both symbol and positionId are empty, the system closes all open positions in the account.
  • When only symbol is provided, the system closes all positions under the specified trading pair (symbol), including both long and short positions.
  • When only positionId is 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:

FieldTypeDescription
positionIdLongPosition identifier.
successBooleanWhether the close action succeeded.
successOrderIdLongOrder ID created to close the position (when successful).
errorMessageStringFailure reason when success = false.

Response example

[
{
"positionId": 689987235755328154,
"success": true,
"successOrderId": 702345678901234580,
"errorMessage": ""
}
]