Skip to content

A crypto multi-agent trading desk 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.

License

Notifications You must be signed in to change notification settings

vasiliskou/Autonomous_Crypto_Traders

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Autonomous Crypto Traders (OpenAI Agents SDK + MCP)

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.

Features

  • 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

Demo

Here’s a quick look at the app in action:

CryptoFloor demo

Project layout

  • src/app.py — Gradio UI (crypto trader desk)
  • src/trading_floor.py — scheduler for periodic autonomous runs
  • src/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, logging
  • src/accounts_server.py — Accounts FastMCP tools (balance/holdings/buy/sell/strategy)
  • src/accounts_client.py — MCP client wrapper for the accounts server
  • src/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

Requirements

  • Python 3.12+
  • uv package manager (or use pip to install dependencies from pyproject.toml)
  • Node/npm available for MCP memory and Brave search servers when enabled
  • Polygon.io API key

Platforms

  • Windows (WSL2 recommended)
  • Linux
  • macOS (Apple silicon or Intel)

Setup

  1. Install dependencies
uv sync
  1. Create a .env in 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
  1. First run will create local SQLite files (accounts.db, memory/*.db).

Running

  • 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.

Resetting local state

If you want to reinitialize the four crypto personas (Vassilis, Vitalik, Arthur, Satoshi) with their strategies run:

uv run src/reset.py

Using the app

  • 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 SPREAD in src/accounts.py
  • Cannot buy more than available balance; cannot sell more than currently held

License

MIT

About

A crypto multi-agent trading desk 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.

Topics

Resources

License

Stars

Watchers

Forks

Languages