{"id":49357463,"url":"https://github.com/flukelaster/ai-trading-agent","last_synced_at":"2026-04-27T14:05:38.492Z","repository":{"id":351013842,"uuid":"1204003467","full_name":"flukelaster/ai-trading-agent","owner":"flukelaster","description":"Multi-symbol AI trading agent — Claude AI + FastAPI + Next.js + MetaTrader 5","archived":false,"fork":false,"pushed_at":"2026-04-13T09:02:57.000Z","size":890,"stargazers_count":10,"open_issues_count":0,"forks_count":5,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-13T09:43:52.452Z","etag":null,"topics":["ai-agent","algorithmic-trading-portfolio","claude-ai","fastapi","lightgbm","metatrader5","nextjs","python","trading-bot","typescript"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/flukelaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-07T15:43:09.000Z","updated_at":"2026-04-13T09:21:10.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/flukelaster/ai-trading-agent","commit_stats":null,"previous_names":["flukelaster/ai-trading-agent"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/flukelaster/ai-trading-agent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flukelaster%2Fai-trading-agent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flukelaster%2Fai-trading-agent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flukelaster%2Fai-trading-agent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flukelaster%2Fai-trading-agent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/flukelaster","download_url":"https://codeload.github.com/flukelaster/ai-trading-agent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/flukelaster%2Fai-trading-agent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32339353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T23:26:28.701Z","status":"online","status_checked_at":"2026-04-27T02:00:06.769Z","response_time":128,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai-agent","algorithmic-trading-portfolio","claude-ai","fastapi","lightgbm","metatrader5","nextjs","python","trading-bot","typescript"],"created_at":"2026-04-27T14:05:37.849Z","updated_at":"2026-04-27T14:05:38.483Z","avatar_url":"https://github.com/flukelaster.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"docs/logo/logo.png\" alt=\"AI Trading Agent\" width=\"160\" /\u003e\n\n# AI Trading Agent\n\n**Multi-symbol autonomous trading platform powered by Claude AI agents**\n\nTrades **GOLD** · **OILCash** · **BTCUSD** · **USDJPY** through MetaTrader 5\n\n[![Python](https://img.shields.io/badge/Python-3.12-3776AB?logo=python\u0026logoColor=white)](https://www.python.org/)\n[![FastAPI](https://img.shields.io/badge/FastAPI-0.115-009688?logo=fastapi\u0026logoColor=white)](https://fastapi.tiangolo.com/)\n[![Next.js](https://img.shields.io/badge/Next.js-16-000000?logo=nextdotjs\u0026logoColor=white)](https://nextjs.org/)\n[![PostgreSQL](https://img.shields.io/badge/PostgreSQL-15-4169E1?logo=postgresql\u0026logoColor=white)](https://www.postgresql.org/)\n[![Redis](https://img.shields.io/badge/Redis-7-DC382D?logo=redis\u0026logoColor=white)](https://redis.io/)\n[![Claude](https://img.shields.io/badge/Claude-Sonnet%204%20+%20Haiku%204.5-D97757?logo=anthropic\u0026logoColor=white)](https://www.anthropic.com/)\n[![Railway](https://img.shields.io/badge/Deploy-Railway-0B0D0E?logo=railway\u0026logoColor=white)](https://railway.app/)\n[![License](https://img.shields.io/badge/License-Private-red)]()\n\n[Features](#-features) · [Screenshots](#-screenshots) · [Architecture](#-architecture) · [Quick Start](#-quick-start) · [Pages](#-pages-overview)\n\n\u003c/div\u003e\n\n---\n\n## ✨ Highlights\n\n\u003e 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\u0026L tick.\n\n\u003cdiv align=\"center\"\u003e\n\n\u003cimg src=\"docs/screenshots/hero-dashboard.png\" alt=\"Trading Dashboard\" width=\"900\" /\u003e\n\n\u003c/div\u003e\n\n---\n\n## 📑 Table of Contents\n\n- [Features](#-features)\n- [Screenshots](#-screenshots)\n- [Architecture](#-architecture)\n- [Tech Stack](#-tech-stack)\n- [Pages Overview](#-pages-overview)\n- [Quick Start](#-quick-start)\n- [Project Structure](#-project-structure)\n- [Environment Variables](#-environment-variables)\n\n---\n\n## 🚀 Features\n\n| Domain | Capability |\n|--------|-----------|\n| 🧠 **Multi-Agent AI** | 8 specialist Claude agents (Sonnet + Haiku) — Orchestrator + Technical + Fundamental + Risk + Reflector + Sentiment + Optimizer |\n| 🛡️ **Guardrails** | Non-bypassable limits at MCP tool layer (lot size, daily loss, trade frequency, cooldowns) |\n| 🎯 **Strategy Engine** | 5 strategies + ensemble (EMA, RSI, Breakout, Mean Reversion, ML Signal) with regime-adaptive switching |\n| 🤖 **ML Models** | Per-symbol LightGBM with 40+ features, drift detection, auto-retrain, calibration analysis |\n| 📊 **Real-time Dashboard** | Live ticks, positions, P\u0026L, equity chart, AI insights, multi-symbol tabs |\n| 🪙 **Token Cost Tracking** | Per-agent token + cost monitoring with daily breakdown and 90-day retention |\n| 🔐 **Secrets Vault** | AES-256-GCM encrypted credential storage, OAuth token health monitor |\n| 📰 **News \u0026 Sentiment** | RSS + macro feeds, Claude sentiment analyzer with bullish/bearish/neutral scoring |\n| ⚖️ **Quantitative Analysis** | VaR, Sharpe, Sortino, drawdown, Monte Carlo, walk-forward, cointegration |\n| 🚦 **Gradual Rollout** | Shadow → Paper → Micro-Live → Live deployment modes |\n| 🔁 **Self-Reflection** | Reflector agent reviews past trades and writes lessons to session memory |\n| 📡 **Live WebSocket** | Real-time price, position, sentiment, and bot event streaming |\n| 🔑 **Passkey Auth** | WebAuthn-ready (currently JWT/password active on Railway) |\n| 📨 **Telegram Alerts** | Trade open/close, signal, AI analysis, system health (Thai language) |\n\n---\n\n## 📸 Screenshots\n\n\u003e Drop PNGs into `docs/screenshots/` with the filenames below.\n\n### 🏠 Dashboard — Live Trading View\n\u003cimg src=\"docs/screenshots/dashboard.png\" alt=\"Dashboard\" width=\"900\" /\u003e\n\n### 📈 Backtest Studio\n\u003cimg src=\"docs/screenshots/backtest.png\" alt=\"Backtest\" width=\"900\" /\u003e\n\n### 📜 Trade History \u0026 Performance\n\u003cimg src=\"docs/screenshots/history.png\" alt=\"History\" width=\"900\" /\u003e\n\n### 🧠 AI Insights\n\u003cimg src=\"docs/screenshots/ai-insights.png\" alt=\"AI Insights\" width=\"900\" /\u003e\n\n### ⚡ AI Activity Timeline\n\u003cimg src=\"docs/screenshots/ai-activity.png\" alt=\"AI Activity\" width=\"900\" /\u003e\n\n### 💰 AI Usage \u0026 Cost Monitor\n\u003cimg src=\"docs/screenshots/ai-usage.png\" alt=\"AI Usage\" width=\"900\" /\u003e\n\n### 🤖 ML Model Monitoring\n\u003cimg src=\"docs/screenshots/ml-model.png\" alt=\"ML Model\" width=\"900\" /\u003e\n\n### 🌐 Macro Data\n\u003cimg src=\"docs/screenshots/macro.png\" alt=\"Macro Data\" width=\"900\" /\u003e\n\n### 🛡️ Quant Risk Dashboard\n\u003cimg src=\"docs/screenshots/quant.png\" alt=\"Quant\" width=\"900\" /\u003e\n\n### 🏢 AI Trading Floor — Agent Prompts\n\u003cimg src=\"docs/screenshots/agent-prompts.png\" alt=\"Agent Prompts\" width=\"900\" /\u003e\n\n### 🔌 Integration Status\n\u003cimg src=\"docs/screenshots/integration.png\" alt=\"Integration\" width=\"900\" /\u003e\n\n### 🔔 Notifications Center\n\u003cimg src=\"docs/screenshots/notifications.png\" alt=\"Notifications\" width=\"900\" /\u003e\n\n### ⚙️ Settings\n\u003cimg src=\"docs/screenshots/settings.png\" alt=\"Settings\" width=\"900\" /\u003e\n\n---\n\n## 🏗 Architecture\n\n```\n┌──────────────────────────────────────────────────────────────────────┐\n│  Frontend (Next.js 16, Vercel/Railway)                               │\n│  Dashboard · Backtest · History · AI Insights · AI Usage · ML        │\n└──────────────────────┬───────────────────────────────────────────────┘\n                       │  HTTPS + WebSocket\n                       ▼\n┌──────────────────────────────────────────────────────────────────────┐\n│  Backend (FastAPI, Railway)                                          │\n│  ├── Auth Layer (JWT cookie · Passkey WebAuthn ready)                │\n│  ├── Secrets Vault (AES-256-GCM · HKDF key derivation)               │\n│  ├── Runner Manager (process / Docker sandbox)                       │\n│  │   ├── Job Queue (Redis + DB-persisted)                            │\n│  │   ├── Heartbeat Monitor (auto-restart)                            │\n│  │   └── Agent Entrypoint (asyncio loop)                             │\n│  │       ├── MCP Tool Server (14 modules · 40+ tools)                │\n│  │       ├── Guardrails (non-bypassable trading limits)              │\n│  │       └── Multi-Agent Pipeline                                    │\n│  │           ├── Reflector (Haiku)        — past trade review        │\n│  │           ├── Technical Analyst (Haiku) — indicators              │\n│  │           ├── Fundamental Analyst (Haiku) — sentiment             │\n│  │           ├── Risk Analyst (Haiku)     — portfolio risk           │\n│  │           ├── Sentiment Analyzer (Haiku) — news scoring           │\n│  │           ├── Strategy Optimizer (Haiku) — param tuning           │\n│  │           └── Orchestrator (Sonnet)    — final decision           │\n│  ├── Strategy Engine (5 strategies + ensemble + MTF + regime)        │\n│  ├── ML Models (LightGBM per-symbol · drift detection)               │\n│  ├── AI Usage Logger (token + cost per call · 90d retention)         │\n│  ├── PostgreSQL 15 + Redis 7 (AOF persistence)                       │\n│  └─── HTTP ────► Windows VPS                                         │\n│                  └── MT5 Bridge + MetaTrader 5 (XM Global)           │\n└──────────────────────────────────────────────────────────────────────┘\n```\n\n---\n\n## 🛠 Tech Stack\n\n| Layer | Technology |\n|-------|-----------|\n| **Backend** | FastAPI 0.115 · SQLAlchemy 2.0 (async) · asyncpg · APScheduler |\n| **Frontend** | Next.js 16 · React 19 · Tailwind 4 · Zustand · lightweight-charts · recharts |\n| **AI** | Claude Code SDK (Max subscription) + Anthropic SDK fallback · Sonnet 4 + Haiku 4.5 |\n| **ML** | LightGBM · scikit-learn · pandas · 40+ features per symbol |\n| **Auth** | JWT Bearer (active) · WebAuthn Passkey (ready) |\n| **Trading** | MetaTrader 5 via custom HTTP Bridge (Windows VPS) |\n| **CI/CD** | GitHub Actions (ruff · pytest · tsc · build) · Railway auto-deploy |\n| **DB** | PostgreSQL 15 (14 Alembic migrations) · Redis 7 (AOF) |\n| **Notifications** | Telegram bot (trade signals · AI analysis · system alerts) |\n| **Testing** | pytest (444 tests · 27 files) · SQLite in-memory · fakeredis · MT5 mock |\n\n---\n\n## 📄 Pages Overview\n\n| Route | Page | Purpose |\n|-------|------|---------|\n| `/dashboard` | Trading Dashboard | Live ticks, positions, P\u0026L, equity chart, AI insights, multi-symbol tabs |\n| `/backtest` | Backtest Studio | Run backtests, optimizer, walk-forward, Monte Carlo, overfitting score |\n| `/history` | Trade History | Past trades + performance breakdown (P\u0026L, equity curve, archive demo) |\n| `/insights` | AI Insights | News sentiment + Claude optimization reports |\n| `/activity` | AI Activity | Unified timeline of agent decisions, sentiment runs, errors |\n| `/ai-usage` | AI Usage | Per-agent token consumption + equivalent USD cost (90-day window) |\n| `/ml` | ML Model | LightGBM training, drift detection, calibration, predictions |\n| `/macro` | Macro Data | FRED indicators, economic calendar, correlations |\n| `/quant` | Quant Risk | VaR, regime, correlation matrix, volatility, portfolio, stress test |\n| `/agent-prompts` | Trading Floor | Customize per-agent system prompts (chibi character avatars) |\n| `/integration` | Integration | Service connectivity status (DB, Redis, MT5, Vault, OAuth) |\n| `/notifications` | Notifications | Event history with filters |\n| `/settings` | Settings | Per-symbol risk, AI filter toggle, paper trade switch |\n| `/login` | Login | Passkey or password authentication |\n| `/setup` | Setup | First-time passkey registration wizard |\n\n---\n\n## ⚡ Quick Start\n\n### Prerequisites\n\n- Python 3.12+\n- Node.js 22+\n- Docker (for local PostgreSQL + Redis)\n- Windows VPS with MetaTrader 5 (production trading only)\n\n### 1. Start databases\n\n```bash\ndocker-compose up -d\n```\n\n### 2. Backend\n\n```bash\ncd backend\npython -m venv .venv\nsource .venv/bin/activate          # Windows: .venv\\Scripts\\activate\npip install -r requirements.txt\ncp .env.example .env\nalembic upgrade head\nuvicorn app.main:app --reload --port 8000\n```\n\n### 3. MT5 Bridge (Windows VPS only)\n\n```bash\ncd mt5_bridge\npip install -r requirements.txt\ncp .env.example .env                # add MT5 credentials\nuvicorn main:app --host 0.0.0.0 --port 8001\n```\n\n### 4. Frontend\n\n```bash\ncd frontend\nnpm install\ncp .env.example .env.local\nnpm run dev\n```\n\n### 5. Run tests\n\n```bash\ncd backend\npython -m pytest tests/ -v --no-cov   # 444 tests\n```\n\n---\n\n## 📁 Project Structure\n\n```\ngold-trading-bot/\n├── backend/\n│   ├── app/\n│   │   ├── api/routes/         # 80+ REST endpoints\n│   │   ├── ai/                 # Claude client, pricing, usage logger\n│   │   ├── bot/                # Trading engine, scheduler, health monitor\n│   │   ├── strategy/           # 5 strategies + ensemble + regime\n│   │   ├── risk/               # Risk manager, circuit breaker, correlation\n│   │   ├── ml/                 # LightGBM trainer, features, drift\n│   │   ├── runner/             # Docker sandbox runner system\n│   │   ├── db/                 # SQLAlchemy models + 15 migrations\n│   │   └── ...\n│   ├── alembic/versions/       # DB migrations\n│   ├── mcp_server/\n│   │   ├── server.py           # FastMCP tool server\n│   │   ├── guardrails.py       # Non-bypassable trading limits\n│   │   ├── agents/             # 6 specialist agents + orchestrator\n│   │   └── tools/              # 14 tool modules\n│   └── tests/                  # 444 tests (27 files)\n├── frontend/\n│   ├── app/                    # Next.js App Router (15 pages, no runners)\n│   ├── components/             # UI primitives + layout\n│   ├── lib/                    # API client + WebSocket\n│   └── public/agent-characters/ # Chibi agent portraits\n├── mt5_bridge/                 # MetaTrader 5 HTTP bridge (Windows VPS)\n├── agent-character/            # Source character art (PNG)\n├── docs/\n│   ├── logo/                   # Logo assets\n│   └── screenshots/            # README screenshots\n├── scripts/backup_db.sh        # Daily pg_dump\n└── docker-compose.yml\n```\n\n---\n\n## 🔧 Environment Variables\n\nSee [`backend/.env.example`](backend/.env.example) and [`mt5_bridge/.env.example`](mt5_bridge/.env.example).\n\n| Variable | Purpose |\n|----------|---------|\n| `DATABASE_URL` / `DATABASE_URL_SYNC` | PostgreSQL connection (asyncpg + sync for Alembic) |\n| `REDIS_URL` | Redis connection |\n| `SECRET_KEY` | JWT signing key |\n| `VAULT_MASTER_KEY` | AES-256-GCM root key for Secrets Vault |\n| `CLAUDE_CODE_OAUTH_TOKEN` | Claude Max subscription token |\n| `MT5_BRIDGE_URL` / `MT5_BRIDGE_API_KEY` | Windows VPS bridge endpoint |\n| `AGENT_MODE` | `single` (Phase C) or `multi` (Phase D) |\n| `ROLLOUT_MODE` | `shadow` · `paper` · `micro` · `live` |\n| `MAX_RISK_PER_TRADE` / `MAX_DAILY_LOSS` / `MAX_LOT` | Hard risk limits |\n| `TELEGRAM_BOT_TOKEN` / `TELEGRAM_CHAT_ID` | Telegram alerts |\n\n---\n\n## 📜 License\n\nPrivate — internal use only.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\nBuilt with **Claude Code** · Deployed on **Railway** · Trading on **MT5**\n\n\u003c/div\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflukelaster%2Fai-trading-agent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fflukelaster%2Fai-trading-agent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fflukelaster%2Fai-trading-agent/lists"}