Hedging vs Netting
XBTFX MT5 accounts operate in one of two margin modes: hedging or netting. The mode determines how positions are managed and which API operations are available.
You can check your account’s margin mode via the margin_mode field returned by GET /v1/auth/status or GET /v1/account.
Hedging Mode
Section titled “Hedging Mode”In hedging mode, you can hold multiple independent positions on the same symbol, including positions in opposite directions.
Key behaviors:
- Each trade creates a new, independent position with its own ticket
- You can have simultaneous buy and sell positions on the same symbol
- Partial closes maintain the same ticket number
- Close-by operations are available (close one position against an opposite position)
- All API endpoints are available
Netting Mode
Section titled “Netting Mode”In netting mode, there is only one position per symbol at any time. New trades on the same symbol modify the existing position rather than creating a new one.
Key behaviors:
- Opening a trade in the same direction as an existing position increases its volume
- Opening a trade in the opposite direction reduces or closes the existing position
- Close-by operations are not available
- The position ticket may change when the position is modified by a new trade
Endpoint Availability by Mode
Section titled “Endpoint Availability by Mode”| Endpoint | Hedging | Netting |
|---|---|---|
/v1/trade | Yes | Yes |
/v1/close | Yes | Yes |
/v1/close-all | Yes | Yes |
/v1/close-symbol | Yes | Yes |
/v1/modify | Yes | Yes |
/v1/close-by | Yes | No |
/v1/reverse | Yes | Yes |
Close By
Section titled “Close By”POST /v1/close-by
Close a position by netting it against an opposite position on the same symbol. Only available on hedging accounts.
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
position | integer | Yes | Ticket of the position to close |
position_by | integer | Yes | Ticket of the opposite position to close against |
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-by \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "position": 12345678, "position_by": 12345679, "comment": "hedge close" }'Response
Section titled “Response”{ "status": "success", "retcode": 10009}Reverse
Section titled “Reverse”POST /v1/reverse
Atomically close an existing position and open a new position in the opposite direction. This is a convenience operation that performs a close and open in a single request.
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
ticket | integer | Yes | Ticket of the position to reverse |
comment | string | No | Comment. Max 27 characters, ASCII only |
Example Request
Section titled “Example Request”curl -X POST https://interface.xbtfx.com/v1/reverse \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "ticket": 12345678 }'Response
Section titled “Response”On full success:
{ "status": "success", "retcode": 10009, "close_deal": 87654322, "open_deal": 87654323}