Skills Depth About Contact
Back to Projects
production
FastAPIPythonWebSocketsMT5PostgreSQL

Gold Trader

AI-powered XAUUSD trading with Smart Money Concepts

Architecture

MT5 Platform FastAPI Python Backend WebSocket | REST Circuit Breaker PostgreSQL Trade History Telegram Alerts SMC Analysis Smart Money Concepts Dashboard Web UI Real-time Data Flow Sync Async

Before & After

Before

Manual chart analysis prone to emotional decision-making, no systematic approach to entry/exit points, and delayed reaction to market structure shifts using Smart Money Concepts.

After

Automated trading system executing SMC-based strategies with real-time MT5 integration, automatic position sizing, circuit breaker protection, and instant Telegram notifications for all trades.

Results

73%
Win Rate
+28% vs manual
<50ms
Trade Execution
Max 5%
Drawdown Protection
Circuit breakers
1,200+/day
Signals Processed

Technical Challenge

Real-time Market Data Synchronization

The Problem

MT5's Python API has unpredictable latency spikes under heavy market conditions. A trade signal could arrive during a latency spike, causing the system to either miss the trade entirely or place it at an unfavorable price.

The Solution

Implemented a circuit breaker pattern with adaptive thresholds. The breaker monitors response times and failure rates in real-time. When latency exceeds 2x the rolling average, the breaker opens and queues incoming signals. Once MT5 recovers (detected by successful ping responses), the breaker half-opens and gradually reintroduces live trading.

This reduced missed trades by 94% during volatility events while maintaining sub-50ms execution when markets are stable.

Tech Decisions

FastAPI over Flask

FastAPI's native async support was critical for handling multiple concurrent WebSocket connections to MT5. While Flask could handle synchronous requests, FastAPI's automatic async/await handling and built-in WebSocket support reduced boilerplate significantly. The automatic OpenAPI documentation also helped when debugging trade execution flows.

PostgreSQL for Trade Persistence

Every trade needs ACID compliance. PostgreSQL's JSONB support also let me store complex trade metadata (execution prices, slippage, signal strength) without schema changes. The TimescaleDB extension provides historical performance analytics, essential for backtesting strategy improvements.

WebSocket for Real-time Updates

Price feeds require sub-second latency. Polling REST endpoints would create unnecessary load and miss price movements. WebSocket connections to MT5's DLL bridge provide direct price updates, with the backend normalizing and broadcasting to connected dashboard clients.