-->
1) Local MT5 terminal + Python integration
MetaTrader 5 exposes a Python integration that can run scripts via MetaEditor, and the official MetaTrader5 Python package is installed via pip. This path assumes a running terminal and local access to the platform data/IPC layer.
2) Cloud API (MetaApi)
MetaApi provides REST and WebSocket access to MT4/MT5 account state, positions, orders, trading history, and streaming quotes/candles/ticks. This is suitable for a hosted integration when you cannot run MT5 locally.
3) Broker/Manager API (future)
Some cloud providers offer MT5 Manager API access for broker-level account management. This is a future option if TIB-Trader becomes a broker platform.
Connectors
- mt5_terminal connector (local MT5 + Python package).
- cloud_api connector (MetaApi or equivalent).
- A common adapter interface (fetch candles, fetch positions, place orders, stream ticks).
Data pipeline
- Ingest candles (H1) and store in MarketCandle.
- Produce forecast signals into ForecastSignal.
- Simulate trades into SimulatedTrade.
- Store each run in SimulationRun.
Mt5IntegrationConfig
Stores provider type, account id, server, enable flag, and sync timestamps. Secrets remain in env files.
TradingSymbol
Tracks symbol metadata (EURUSD, pip size, digits).
MarketCandle
H1 candles for EUR/USD (source = simulation initially, later MT5).
ForecastSignal
Signal (BUY/SELL/HOLD), confidence, target time, model version, inputs.
SimulationRun
Parameters + metrics for each simulation run (H1, horizon=60m).
SimulatedTrade
Entry/exit, side, size, pnl, and reasons.
Model: Simple moving-average crossover (fast=5, slow=20) on 1-hour closes.
Signal:
- fast > slow → BUY
- fast < slow → SELL
- else HOLD
Confidence: scaled by distance between SMAs relative to pip size.
This provides a deterministic baseline to validate the pipeline before testing more advanced models.
Command: python manage.py simulate_trades
Default: 72 hours, EURUSD, H1.
Outputs:
- candles, forecasts, trades, metrics
- logs under pmcore.trading (captured by fluent-bit)
Metrics recorded: - trades_total, trades_won, win_rate - pnl_total, pnl_avg - max_drawdown
Route: /management/trading/
Sections:
- Latest forecast (signal, confidence, target)
- Recent simulation runs (metrics)
- Recent simulated trades
- React-based EUR/USD chart (Lightweight Charts)
Route: /management/connection/
Sections:
- MT5 configuration (provider, account, server, enabled)
- Connection status summary
python manage.py trading_validate logs MT5 config + connector health + latest run/forecast snapshot.pmcore.trading and captured by fluent-bit.Dashboard: - Connection status (Terminal/Cloud) - EUR/USD price strip (H1 close) - Signal panel (BUY/SELL/HOLD + confidence)
Simulation - Run list (parameters + metrics) - Trade journal (entry/exit, pnl, reason)
Forecast - Latest signal summary - 1-hour horizon countdown
Observability - Log stream panel for connector state, sync, and simulation events.
1) Implement connector interface and stub MT5/MetaApi adapters. 2) Add charting overlays (forecast bands, trade markers). 3) Integrate historical EUR/USD candles for backtesting. 4) Add validation tests for forecast accuracy and latency.