The MetaTrader 5 integration connects an MT5 Expert Advisor (EA) to the QUIMERIA Sovereign Market Kernel via a ZeroMQ publish/subscribe bridge. Incoming ticks arrive on port 5555 and are fed directly into the kernel order book. Outbound order signals leave on port 5556, tagged with aDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/deskiziarecords/QUIMERIA-HYPERION/llms.txt
Use this file to discover all available pages before exploring further.
QUIMERIA-{signal_id} identifier so the EA can correlate responses. The bridge is implemented in integrations/mt5/service.py and connects to backend/data/zmq_data_bus.py.
How the ZeroMQ bridge works
TickData object. The gateway deserializes the tick and calls kernel.order_book.update(TickData) to update the high-performance limit order book.
Port 5556 — SMK publishes as a ZMQ PUB socket. When the lambda fusion engine approves a signal and the Mandra Gate passes (ΔE ≥ 0.02), an ORDER_SEND JSON message is published tagged QUIMERIA-{signal_id}. The MT5 EA subscribes on this port, parses the message, and executes the order.
MT5Gateway class
MT5Gateway in integrations/mt5/service.py wraps the MetaTrader5 Python library and handles connection lifecycle, symbol resolution, and order placement with broker-supported fill mode fallback.
Supported timeframes
Terminal path
The default terminal path isC:\Program Files\MetaTrader 5\terminal64.exe. Override it by passing path= to MT5Service() or by setting the environment variable in your .env file.
MT5 credential environment variables
The.env file supports separate credential sets for TradingView webhook targets and MetaTrader EA scripts. The MT_* variables are consumed by the MT5 integration.
The live_eurusd.py entry point
apps/live_eurusd.py is the primary entry point for running QUIMERIA-HYPERION in a live MT5 deployment. It initializes the ZeroMQ bridge, connects to the MT5 terminal, and starts the SMK pipeline in live mode.
SMK_DIR automatically:
apps/live_eurusd.py and backend/main.py both exist before starting. If either file is missing it exits with a clear error message.
ZMQ data bus
backend/data/zmq_data_bus.py is the internal message router between the MT5 bridge and the SMK pipeline. It exposes:
- A ZMQ SUB socket on port 5555 that receives tick messages from the MT5 EA
- A ZMQ PUB socket on port 5556 that dispatches
ORDER_SENDJSON to the EA - An async event loop compatible with the FastAPI uvicorn server
apps/live_eurusd.py runs. It does not require manual configuration beyond the port numbers.
Integration files reference
| File | Purpose |
|---|---|
integrations/mt5/service.py | MT5Service class — connection, order placement, symbol resolution |
integrations/mt5/bridge_client.py | ZeroMQ bridge client connecting to the data bus |
integrations/mt5/market_broadcast.py | Broadcasts candle data from MT5 to SMK pipeline |
integrations/mt5/mt5_compat.py | Compatibility shim for environments without MetaTrader5 installed |
integrations/mt5/mt5_service_standalone.py | Standalone version of MT5Service without Django REST dependencies |
integrations/mt5/app.py | Django REST API views for the MT5 service |
integrations/mt5/mt5cfg.ini | MT5 terminal configuration |
apps/live_eurusd.py | Main entry point for live EUR/USD MT5 deployment |
mt5_compat.py provides a stub MetaTrader5 module so the integration can be imported on Linux machines where the MT5 library is not available. The stub raises a descriptive error if you attempt to call a live MT5 function.Order tagging
Every order dispatched through the ZeroMQ bridge carries the tagQUIMERIA-{signal_id} in the MT5 comment field (mapped to the comment parameter of place_market_order). This allows the EA to:
- Match order responses back to specific SMK signals
- Filter QUIMERIA-managed positions from manually placed trades
- Route partial fills back to the correct
TradePositioninstance
LambdaFusionEngine when r['veto']['trade_allowed'] is True and is available in the r['action_center'] key of the step result dict.