A crypto multi-agent trading simulation built with the OpenAI Agents SDK and the Model Context Protocol (MCP). LLM “traders” invoke MCP tools for internet research, price lookup, and account operations, then track P&L and present everything in a Gradio dashboard. The app auto-discovers USD crypto pairs via Polygon.io, stores daily UTC close prices in SQLite (using the prior UTC day for consistency), and provides audit logs, holdings, recent transactions, and one-click CSV exports.
- Crypto pricing via Polygon.io
- Accounts service for buy/sell/strategy (Accounts FastMCP tools)
- Research (MCPs: Brave Search, Fetch)
- Memory (MCP: LibSQL Memory)
- Push notifications (FastMCP Push)
- Gradio UI: portfolio value chart, holdings, transactions, logs
Here’s a quick look at the app in action:
src/app.py— Gradio UI (crypto trader desk)src/trading_floor.py— scheduler for periodic autonomous runssrc/traders.py— agent orchestration (models, MCP wiring)src/market.py— crypto price access (Polygon grouped-daily cache; optional live snapshots)src/market_server.py— MCP market tool (price lookup)src/accounts.py— account model, buy/sell logic, P&L, loggingsrc/accounts_server.py— Accounts FastMCP tools (balance/holdings/buy/sell/strategy)src/accounts_client.py— MCP client wrapper for the accounts serversrc/templates.py— agent prompts/instructions (researcher and trader messages)src/mcp_params.py— MCP server spawn parameters (accounts/market; optional research/push)src/database.py— SQLite helpers (accounts, logs, market cache)src/push_server.py— FastMCP push notifications (optional)src/reset.py— defines the four crypto personas and resets their accounts with those strategies
- Python 3.12+
uvpackage manager (or usepipto install dependencies frompyproject.toml)- Node/npm available for MCP memory and Brave search servers when enabled
- Polygon.io API key
- Windows (WSL2 recommended)
- Linux
- macOS (Apple silicon or Intel)
- Install dependencies
uv sync- Create a
.envin the project root (set these):
# Required for pricing
POLYGON_API_KEY=your_polygon_key
# One of: realtime | paid | (leave unset for free EOD behavior)
POLYGON_PLAN=realtime
# Choose at least one model provider (set one or more)
# OpenAI
OPENAI_API_KEY=sk-...
# (Optional) OpenRouter (router to many models; use model names like openai/gpt-4o-mini)
OPENROUTER_API_KEY=...
# (Optional) DeepSeek
DEEPSEEK_API_KEY=...
# (Optional) xAI Grok
GROK_API_KEY=...
# (Optional) Google Gemini (OpenAI-compatible endpoint used here)
GOOGLE_API_KEY=...
# researcher tools
BRAVE_API_KEY=...
# Optional push notifications (Pushover)
PUSHOVER_USER=...
PUSHOVER_TOKEN=...
# Scheduler/model toggles (optional)
RUN_EVERY_N_MINUTES=60
USE_MANY_MODELS=false- First run will create local SQLite files (
accounts.db,memory/*.db).
- Dashboard/UI (opens in browser):
uv run src/app.py- Autonomous traders (periodic runs):
uv run src/trading_floor.py- By default, names and styles are defined in
src/trading_floor.py.
If you want to reinitialize the four crypto personas (Vassilis, Vitalik, Arthur, Satoshi) with their strategies run:
uv run src/reset.py- The UI shows a live portfolio value chart, holdings, recent transactions, and logs per trader.
- Agents research and place crypto trades using MCP tools.
- Quantities are fractional
- Simple fee/spread model via
SPREADinsrc/accounts.py - Cannot buy more than available balance; cannot sell more than currently held
MIT
