http://<VM_IP>:6542Auth:
Authorization: Bearer <API_TOKEN>
System
| Method | Endpoint | Description |
|---|---|---|
GET | /ping | Heartbeat — returns {"status": "ok", "time": <epoch>} |
GET | /ping/broker | MT5→broker latency: {ping_ms, quality, connected} |
GET | /error | Last MT5 error code + message |
GET | /terminal | Full terminal info (connection state, flags) |
POST | /terminal/init | Initialize MT5 terminal connection |
POST | /terminal/restart | Force restart MT5 terminal |
Account
| Method | Endpoint | Description |
|---|---|---|
GET | /account | Balance, equity, margin, leverage, currency |
Symbols
| Method | Endpoint | Description |
|---|---|---|
GET | /symbols | List all available symbols |
GET | /symbols/{sym} | Symbol spec: digits, stops_level, contract_size |
GET | /symbols/{sym}/tick | Latest tick: bid, ask, last, time |
GET | /symbols/{sym}/rates?timeframe=M15&count=250 | OHLCV bars (includes spread in raw points) |
GET | /symbols/{sym}/ticks?count=100 | Raw historical ticks |
Positions
| Method | Endpoint | Description |
|---|---|---|
GET | /positions | All open positions |
GET | /positions/{ticket} | Single position by ticket |
PUT | /positions/{ticket} | Modify SL/TP — body: {"sl": 84200.0, "tp": 85000.0} |
DELETE | /positions/{ticket} | Close position (full or partial) |
Orders
| Method | Endpoint | Description |
|---|---|---|
GET | /orders | All active pending orders |
GET | /orders/{ticket} | Single pending order |
POST | /orders | Place order — see body below |
PUT | /orders/{ticket} | Modify pending order price/SL/TP |
DELETE | /orders/{ticket} | Cancel pending order |
Place order — request body
type accepts "BUY" or "SELL". sl and tp are optional.
History
| Method | Endpoint | Description |
|---|---|---|
GET | /history/orders?from=&to= | Historical closed/cancelled orders |
GET | /history/deals?from=&to= | Historical deals (executions + P/L) |
from and to are Unix timestamps.
Notes
Spread conversion
/rates returns spread in raw points. For BTCUSD, multiply by $0.01 to get dollar spread:
trading.py handles this automatically — you never need to convert manually.
Response objects
HTTP helpers intrading/bot.py parse all responses into SimpleNamespace objects for attribute access:
Error handling
Non-2xx responses or failed orders include aretcode field with the MT5 error code. The bot logs the error and sends a Telegram alert: