AI Trading Assistant
Control MetaTrader 5 accounts through WhatsApp or Telegram in plain language.
- Category
- AI
- Year
- 2026
- Role
- Solo · Architecture & build
01The problem
Chat is the most natural interface for a trader, and the most dangerous. A language model that misreads "close half" as "close all" costs real money. The challenge was to get the convenience of natural language without handing the model any authority.
02The approach
- Strict Clean Architecture: the domain knows nothing about Express, OpenAI, Telegram or Redis. Every adapter plugs into a port.
- The LLM interprets messages via function calling into a zod-validated TradingIntent, with retries and a safe fallback when output doesn't validate.
- A pure, synchronous Risk Engine (no I/O, no clock, no globals) checks 11 ordered rules, including session, symbol, lot size, risk %, daily loss, exposure and free margin, and short-circuits on the first violation.
- Approved trades go through BullMQ to an execution-command store that a custom MQL5 Expert Advisor polls, executes and reports back on.
03The impact
- Language is flexible; execution is deterministic and fully unit-tested.
- Channels (WhatsApp, Telegram) and providers are swappable without touching any consumer.
- Security by default: JWT + EA API keys, AES-256-GCM secrets at rest, fail-open distributed rate limiting, verified webhooks.