Close All
Close all open positions on the account, or close all positions for a specific symbol. Close commands are sent in parallel for fast execution.
Close All Positions
Section titled “Close All Positions”POST /v1/close-all
Closes every open position on the account. Up to 20 positions are closed concurrently.
Weight: 10
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
comment | string | No | Close comment. Max 27 characters, ASCII only |
Example Request
Section titled “Example Request”curl -X POST https://interface.xbtfx.com/v1/close-all \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "comment": "close all" }'Close by Symbol
Section titled “Close by Symbol”POST /v1/close-symbol
Closes all open positions for a specific symbol. Up to 20 positions are closed concurrently.
Weight: 10
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Symbol to close all positions for (e.g., EURUSD) |
comment | string | No | Close comment. Max 27 characters, ASCII only |
Example Request
Section titled “Example Request”curl -X POST https://interface.xbtfx.com/v1/close-symbol \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "symbol": "EURUSD" }'Response
Section titled “Response”Both endpoints return the same response format:
{ "closed": 3, "failed": 0, "total_profit": 45.60, "details": [ { "ticket": 12345678, "status": "success", "retcode": 10009, "deal": 87654322, "price": 1.08890, "profit": 19.30 }, { "ticket": 12345679, "status": "success", "retcode": 10009, "deal": 87654323, "price": 1.52110, "profit": 12.50 }, { "ticket": 12345680, "status": "success", "retcode": 10009, "deal": 87654324, "price": 0.65430, "profit": 13.80 } ]}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
closed | integer | Number of positions successfully closed |
failed | integer | Number of positions that failed to close |
total_profit | number | Combined realized profit/loss from all closed positions |
details | array | Per-position results |
details[].ticket | integer | Position ticket number |
details[].status | string | Result status for this position |
details[].retcode | integer | MT5 return code |
details[].deal | integer | Closing deal ticket |
details[].price | number | Close execution price |
details[].profit | number | Realized profit/loss for this position |