latestOpenAPI 3.0.32026-08-224982,0272.8 MB

e445c15e5bee

Margin

Close all margin positions

Initiates an asynchronous process to close margin positions by executing market trades to net positions to zero. Unlike 'cover' which transfers assets, 'close' creates trade orders to sell or buy assets. Returns immediately with a request ID that can be used to track progress via the close position requests endpoints.

post/api/prime/trading/v1/accounts/{accountId}/margin/positions/close

Path parameters

accountIdstring required

The ID of the account

Request body

OR

Example request

{
  "currencies": [
    "BTC"
  ]
}

Response

Returns an acknowledgement that the action was received. Async process will kick off to perform trades to close out open positions.

closePositionsRequestIdstring uuid required

Unique identifier for the close position request

accountIdstring required

The ID of the account

enterpriseIdstring required

Enterprise ID associated with the request

status'pending' | 'in_progress' | 'completed' | 'failed' required

Status of a close position request or order

bitgoUserIdstring required

BitGo user ID who initiated the request

creationDatestring date-time required

Timestamp when the request was created

Example response

{
  "closePositionsRequestId": "b2c3d4e5-f6g7-8901-bcde-f23456789012",
  "accountId": "f230fdebfa084ffebc7e00515f54603f",
  "enterpriseId": "a130kjebfa084ffebc7e00515f54603f",
  "status": "pending",
  "bitgoUserId": "user123",
  "creationDate": "2024-01-15T11:00:00.000Z"
}