Hybrid AI-trading bot for MetaTrader 5, designed to run on Linux/Ubuntu and control a real MetaTrader 5 terminal on Windows through a lightweight REST bridge.
┌─────────────────────┐ REST/HTTP ┌──────────────────────┐
│ Ubuntu Bot │ ───────────────────────▶ │ Windows MT5 Bridge │
│ (core/bot_engine) │ BROKER_ADAPTER=wine-bridge│ (bridge/server.py) │
│ strategies/risk/ │ ◀─────────────────────── │ talks to local MT5 │
└─────────────────────┘ └──────────────────────┘
The bot never imports the Windows-only MetaTrader5 package directly. It talks
to a BrokerAdapter:
MockBrokerAdapter— deterministic offline dev/test modeMT5TerminalBridge— calls the Windows bridge over HTTP
cd operation-mt5-avatrade
python3 -m venv venv && source venv/bin/activate
pip install -r requirements.txt
# Offline mock mode (no MT5 needed):
BROKER_ADAPTER=mock python -m core.bot_engine
# Live bridge mode (needs the Windows bridge running):
export BROKER_ADAPTER=wine-bridge
export MT5_BRIDGE_HOST=<WINDOWS_IP>
export MT5_BRIDGE_PORT=8080
export MT5_BRIDGE_PASSWORD=<same secret as bridge>
export MT5_LOGIN=<your login>
export MT5_PASSWORD=<your password>
export MT5_SERVER=GULFBROKERS1-Live
export TRADING_ENVIRONMENT=live
python -m core.bot_engineSee bridge/ — copy that folder to your Windows machine, run
setup.bat (as Administrator), edit .env, then run.bat.
Full guide: bridge/WINDOWS_SETUP.md
.envandvenv/are git-ignored. Real credentials are never committed.- Always set a strong
BRIDGE_PASSWORDand restrict the bridge's firewall to the bot's IP. Do not expose the bridge to the public internet.
Trading involves substantial risk. This code is provided for educational and operational testing purposes. Use at your own risk.