Close
Close an open position by its ticket number. Supports partial closes by specifying a volume less than the full position size.
Endpoint
Section titled “Endpoint”POST /v1/close
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
ticket | integer | Yes | Position ticket number to close |
volume | number | No | Volume to close in lots. Omit to close the full position. Specify a smaller value for a partial close |
comment | string | No | Close comment. Max 27 characters, ASCII only |
Example Request
Section titled “Example Request”Close a full position:
curl -X POST https://interface.xbtfx.com/v1/close \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "ticket": 12345678 }'Partial close (close 0.05 lots of a 0.1 lot position):
curl -X POST https://interface.xbtfx.com/v1/close \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "ticket": 12345678, "volume": 0.05 }'Response
Section titled “Response”{ "status": "success", "retcode": 10009, "deal": 87654322, "price": 1.08890}Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
status | string | Result status |
retcode | integer | MT5 return code. 10008 or 10009 indicate success |
deal | integer | Closing deal ticket number |
price | number | Close execution price |