Python package for MetaTrader 5 REST API.
Connect to any MT5 terminal via its REST API server and trade programmatically.
pip install mt5bridgefrom mt5bridge import MT5Bridge
mt5 = MT5Bridge(host="192.168.1.234", port=332)
# Check connection
print(mt5.health())
# Account info
print(mt5.account())
# Open a position
mt5.open(symbol="US500", tipo="buy", volume=0.1, sl=0, tp=0)
# Get candles
print(mt5.candles(symbol="US500", tf="H1", count=100))| Method | Description |
|---|---|
health() |
Server status and MT5 connection state |
account() |
Account balance, equity, margin |
positions() |
Open positions |
orders() |
Pending orders |
symbol(symbol) |
Symbol specs (spread, digits, etc.) |
candles(symbol, tf, count) |
OHLCV candles |
open(symbol, tipo, volume, sl, tp) |
Market order |
close(ticket) |
Close position by ticket |
MIT