Trade
Open a new market position. The trade executes at the current market price.
Endpoint
Section titled “Endpoint”POST /v1/trade
Request Parameters
Section titled “Request Parameters”| Parameter | Type | Required | Description |
|---|---|---|---|
symbol | string | Yes | Trading symbol (e.g., EURUSD) |
side | string | Yes | Trade direction: buy or sell |
volume | number | Yes | Trade volume in lots. Must respect the symbol’s volume_min, volume_max, and volume_step |
price | number | No | Advisory price. The trade executes at market; this is for reference only |
sl | number | No | Stop loss price |
tp | number | No | Take profit price |
comment | string | No | Trade comment. Max 27 characters, ASCII only. Automatically prefixed with -API |
Example Request
Section titled “Example Request”curl -X POST https://interface.xbtfx.com/v1/trade \ -H "Authorization: Bearer your_api_key_here" \ -H "Content-Type: application/json" \ -d '{ "symbol": "EURUSD", "side": "buy", "volume": 0.1, "sl": 1.08000, "tp": 1.09500 }'Response
Section titled “Response”{ "status": "placed", "retcode": 10008, "volume": 0.10, "comment": ""}Retcodes: 10008 = order placed (market execution), 10009 = done. Both indicate success.
Response Fields
Section titled “Response Fields”| Field | Type | Description |
|---|---|---|
status | string | placed or filled or rejected |
retcode | integer | MT5 return code. 10008 (placed) and 10009 (done) indicate success |
volume | number | Executed volume in lots |
comment | string | Trade comment (includes -API prefix) |
deal | integer | Deal ticket number (present when status is filled) |
order | integer | Order ticket number (present when status is filled) |
price | number | Execution price (present when status is filled) |
- On netting accounts, opening a trade in the same direction as an existing position increases that position. Opening in the opposite direction reduces or closes it. See Hedging vs Netting for details.
- On hedging accounts, each trade creates an independent position.
- Use the Symbols endpoint to verify volume constraints before trading.
- Consider using an idempotency key to prevent duplicate trades on retries.