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": 42.50, "details": [ { "ticket": 12345, "status": "filled", "deal": 99001, "profit": 15.00 }, { "ticket": 12346, "status": "filled", "deal": 99002, "profit": 20.00 }, { "ticket": 12347, "status": "filled", "deal": 99003, "profit": 7.50 } ]}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 |