Skip to main content

REST API Trading - Bulk close positions

Bulk close positions

Written by Albert
Updated today

Bulk close positions

POST /frontoffice/api/v4/positions/bulk-close

Summary

Use this method to close multiple positions simultaneously based on different criteria such as all positions, positive PnL only, or negative PnL only.

Request

Header parameters

accountId required

The trading account identifier.

Body

mode string required

The bulk close mode.

Possible values:

  • AllPositions β€” close all positions.

  • PositivePnl β€” close only positions with positive PnL.

  • NegativePnl β€” close only positions with negative PnL.

Request example

POST /frontoffice/api/v4/positions/bulk-close HTTP/1.1
Host: {host}
Authorization: Bearer JWT
accountId: {accountId}
Content-Type: application/json; x-api-version=4.0
Accept: */*

{
"mode": "AllPositions"
}

Response

In case of success, an object will be returned containing identifiers of closed positions.

Response example β€” 200: OK

{
"status": "accepted",
"positionIds": [
"01K228VNC2Q7E7K9W8GABWBZ5Z",
"01K22BZ2DCETJZKW6MK81N1T8Y",
"01K2CXF06A3A5SK2YFJT67CMZ5",
"01K2CXF2ZJ6MJYMEK663TBBY8K",
"01K2PFXDP1FWCJSGTX4GJ6JHM0"
]
}

Did this answer your question?