Skip to content

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.

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

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
EndpointHedgingNetting
/v1/tradeYesYes
/v1/closeYesYes
/v1/close-allYesYes
/v1/close-symbolYesYes
/v1/modifyYesYes
/v1/close-byYesNo
/v1/reverseYesYes

POST /v1/close-by

Close a position by netting it against an opposite position on the same symbol. Only available on hedging accounts.

ParameterTypeRequiredDescription
positionintegerYesTicket of the position to close
position_byintegerYesTicket of the opposite position to close against
commentstringNoClose comment. Max 27 characters, ASCII only
Terminal window
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"
}'
{
"status": "success",
"retcode": 10009
}

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.

ParameterTypeRequiredDescription
ticketintegerYesTicket of the position to reverse
commentstringNoComment. Max 27 characters, ASCII only
Terminal window
curl -X POST https://interface.xbtfx.com/v1/reverse \
-H "Authorization: Bearer your_api_key_here" \
-H "Content-Type: application/json" \
-d '{
"ticket": 12345678
}'

On full success:

{
"status": "success",
"retcode": 10009,
"close_deal": 87654322,
"open_deal": 87654323
}