AI Trading Agent
Multi-symbol AI trading agent β Claude AI + FastAPI + Next.js + MetaTrader 5
Ask AI about AI Trading Agent
Powered by Claude Β· Grounded in docs
I know everything about AI Trading Agent. Ask me about installation, configuration, usage, or troubleshooting.
0/500
Reviews
Documentation
AI Trading Agent
Multi-symbol autonomous trading platform powered by Claude AI agents
Trades GOLD Β· OILCash Β· BTCUSD Β· USDJPY through MetaTrader 5
Features Β· Screenshots Β· Architecture Β· Quick Start Β· Pages
β¨ Highlights
Eight specialist Claude agents collaborating on a virtual trading floor β Orchestrator, Technical, Fundamental, Risk, Reflector, Sentiment, Strategy Optimizer, and Single-Agent fallback. Hard guardrails prevent runaway trades. Real-time UI streams every decision, position, and P&L tick.
π Table of Contents
- Features
- Screenshots
- Architecture
- Tech Stack
- Pages Overview
- Quick Start
- Project Structure
- Environment Variables
π Features
| Domain | Capability |
|---|---|
| π§ Multi-Agent AI | 8 specialist Claude agents (Sonnet + Haiku) β Orchestrator + Technical + Fundamental + Risk + Reflector + Sentiment + Optimizer |
| π‘οΈ Guardrails | Non-bypassable limits at MCP tool layer (lot size, daily loss, trade frequency, cooldowns) |
| π― Strategy Engine | 5 strategies + ensemble (EMA, RSI, Breakout, Mean Reversion, ML Signal) with regime-adaptive switching |
| π€ ML Models | Per-symbol LightGBM with 40+ features, drift detection, auto-retrain, calibration analysis |
| π Real-time Dashboard | Live ticks, positions, P&L, equity chart, AI insights, multi-symbol tabs |
| πͺ Token Cost Tracking | Per-agent token + cost monitoring with daily breakdown and 90-day retention |
| π Secrets Vault | AES-256-GCM encrypted credential storage, OAuth token health monitor |
| π° News & Sentiment | RSS + macro feeds, Claude sentiment analyzer with bullish/bearish/neutral scoring |
| βοΈ Quantitative Analysis | VaR, Sharpe, Sortino, drawdown, Monte Carlo, walk-forward, cointegration |
| π¦ Gradual Rollout | Shadow β Paper β Micro-Live β Live deployment modes |
| π Self-Reflection | Reflector agent reviews past trades and writes lessons to session memory |
| π‘ Live WebSocket | Real-time price, position, sentiment, and bot event streaming |
| π Passkey Auth | WebAuthn-ready (currently JWT/password active on Railway) |
| π¨ Telegram Alerts | Trade open/close, signal, AI analysis, system health (Thai language) |
πΈ Screenshots
Drop PNGs into
docs/screenshots/with the filenames below.
π Dashboard β Live Trading View
π Backtest Studio
π Trade History & Performance
π§ AI Insights
β‘ AI Activity Timeline
π° AI Usage & Cost Monitor
π€ ML Model Monitoring
π Macro Data
π‘οΈ Quant Risk Dashboard
π’ AI Trading Floor β Agent Prompts
π Integration Status
π Notifications Center
βοΈ Settings
π Architecture
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Next.js 16, Vercel/Railway) β
β Dashboard Β· Backtest Β· History Β· AI Insights Β· AI Usage Β· ML β
ββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββββββββ
β HTTPS + WebSocket
βΌ
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Backend (FastAPI, Railway) β
β βββ Auth Layer (JWT cookie Β· Passkey WebAuthn ready) β
β βββ Secrets Vault (AES-256-GCM Β· HKDF key derivation) β
β βββ Runner Manager (process / Docker sandbox) β
β β βββ Job Queue (Redis + DB-persisted) β
β β βββ Heartbeat Monitor (auto-restart) β
β β βββ Agent Entrypoint (asyncio loop) β
β β βββ MCP Tool Server (14 modules Β· 40+ tools) β
β β βββ Guardrails (non-bypassable trading limits) β
β β βββ Multi-Agent Pipeline β
β β βββ Reflector (Haiku) β past trade review β
β β βββ Technical Analyst (Haiku) β indicators β
β β βββ Fundamental Analyst (Haiku) β sentiment β
β β βββ Risk Analyst (Haiku) β portfolio risk β
β β βββ Sentiment Analyzer (Haiku) β news scoring β
β β βββ Strategy Optimizer (Haiku) β param tuning β
β β βββ Orchestrator (Sonnet) β final decision β
β βββ Strategy Engine (5 strategies + ensemble + MTF + regime) β
β βββ ML Models (LightGBM per-symbol Β· drift detection) β
β βββ AI Usage Logger (token + cost per call Β· 90d retention) β
β βββ PostgreSQL 15 + Redis 7 (AOF persistence) β
β ββββ HTTP βββββΊ Windows VPS β
β βββ MT5 Bridge + MetaTrader 5 (XM Global) β
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π Tech Stack
| Layer | Technology |
|---|---|
| Backend | FastAPI 0.115 Β· SQLAlchemy 2.0 (async) Β· asyncpg Β· APScheduler |
| Frontend | Next.js 16 Β· React 19 Β· Tailwind 4 Β· Zustand Β· lightweight-charts Β· recharts |
| AI | Claude Code SDK (Max subscription) + Anthropic SDK fallback Β· Sonnet 4 + Haiku 4.5 |
| ML | LightGBM Β· scikit-learn Β· pandas Β· 40+ features per symbol |
| Auth | JWT Bearer (active) Β· WebAuthn Passkey (ready) |
| Trading | MetaTrader 5 via custom HTTP Bridge (Windows VPS) |
| CI/CD | GitHub Actions (ruff Β· pytest Β· tsc Β· build) Β· Railway auto-deploy |
| DB | PostgreSQL 15 (14 Alembic migrations) Β· Redis 7 (AOF) |
| Notifications | Telegram bot (trade signals Β· AI analysis Β· system alerts) |
| Testing | pytest (444 tests Β· 27 files) Β· SQLite in-memory Β· fakeredis Β· MT5 mock |
π Pages Overview
| Route | Page | Purpose |
|---|---|---|
/dashboard | Trading Dashboard | Live ticks, positions, P&L, equity chart, AI insights, multi-symbol tabs |
/backtest | Backtest Studio | Run backtests, optimizer, walk-forward, Monte Carlo, overfitting score |
/history | Trade History | Past trades + performance breakdown (P&L, equity curve, archive demo) |
/insights | AI Insights | News sentiment + Claude optimization reports |
/activity | AI Activity | Unified timeline of agent decisions, sentiment runs, errors |
/ai-usage | AI Usage | Per-agent token consumption + equivalent USD cost (90-day window) |
/ml | ML Model | LightGBM training, drift detection, calibration, predictions |
/macro | Macro Data | FRED indicators, economic calendar, correlations |
/quant | Quant Risk | VaR, regime, correlation matrix, volatility, portfolio, stress test |
/agent-prompts | Trading Floor | Customize per-agent system prompts (chibi character avatars) |
/integration | Integration | Service connectivity status (DB, Redis, MT5, Vault, OAuth) |
/notifications | Notifications | Event history with filters |
/settings | Settings | Per-symbol risk, AI filter toggle, paper trade switch |
/login | Login | Passkey or password authentication |
/setup | Setup | First-time passkey registration wizard |
β‘ Quick Start
Prerequisites
- Python 3.12+
- Node.js 22+
- Docker (for local PostgreSQL + Redis)
- Windows VPS with MetaTrader 5 (production trading only)
1. Start databases
docker-compose up -d
2. Backend
cd backend
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
alembic upgrade head
uvicorn app.main:app --reload --port 8000
3. MT5 Bridge (Windows VPS only)
cd mt5_bridge
pip install -r requirements.txt
cp .env.example .env # add MT5 credentials
uvicorn main:app --host 0.0.0.0 --port 8001
4. Frontend
cd frontend
npm install
cp .env.example .env.local
npm run dev
5. Run tests
cd backend
python -m pytest tests/ -v --no-cov # 444 tests
π Project Structure
gold-trading-bot/
βββ backend/
β βββ app/
β β βββ api/routes/ # 80+ REST endpoints
β β βββ ai/ # Claude client, pricing, usage logger
β β βββ bot/ # Trading engine, scheduler, health monitor
β β βββ strategy/ # 5 strategies + ensemble + regime
β β βββ risk/ # Risk manager, circuit breaker, correlation
β β βββ ml/ # LightGBM trainer, features, drift
β β βββ runner/ # Docker sandbox runner system
β β βββ db/ # SQLAlchemy models + 15 migrations
β β βββ ...
β βββ alembic/versions/ # DB migrations
β βββ mcp_server/
β β βββ server.py # FastMCP tool server
β β βββ guardrails.py # Non-bypassable trading limits
β β βββ agents/ # 6 specialist agents + orchestrator
β β βββ tools/ # 14 tool modules
β βββ tests/ # 444 tests (27 files)
βββ frontend/
β βββ app/ # Next.js App Router (15 pages, no runners)
β βββ components/ # UI primitives + layout
β βββ lib/ # API client + WebSocket
β βββ public/agent-characters/ # Chibi agent portraits
βββ mt5_bridge/ # MetaTrader 5 HTTP bridge (Windows VPS)
βββ agent-character/ # Source character art (PNG)
βββ docs/
β βββ logo/ # Logo assets
β βββ screenshots/ # README screenshots
βββ scripts/backup_db.sh # Daily pg_dump
βββ docker-compose.yml
π§ Environment Variables
See backend/.env.example and mt5_bridge/.env.example.
| Variable | Purpose |
|---|---|
DATABASE_URL / DATABASE_URL_SYNC | PostgreSQL connection (asyncpg + sync for Alembic) |
REDIS_URL | Redis connection |
SECRET_KEY | JWT signing key |
VAULT_MASTER_KEY | AES-256-GCM root key for Secrets Vault |
CLAUDE_CODE_OAUTH_TOKEN | Claude Max subscription token |
MT5_BRIDGE_URL / MT5_BRIDGE_API_KEY | Windows VPS bridge endpoint |
AGENT_MODE | single (Phase C) or multi (Phase D) |
ROLLOUT_MODE | shadow Β· paper Β· micro Β· live |
MAX_RISK_PER_TRADE / MAX_DAILY_LOSS / MAX_LOT | Hard risk limits |
TELEGRAM_BOT_TOKEN / TELEGRAM_CHAT_ID | Telegram alerts |
π License
Private β internal use only.
Built with Claude Code Β· Deployed on Railway Β· Trading on MT5
