Quantitative trading system for Polymarket prediction markets, built on 40+ years of prediction market research.
π Live Dashboard: polymarket-trading-dashboard.vercel.app
by b1rdmania
An AI-powered trading system for Polymarket that:
- Applies mean reversion strategies from academic research (Berg & Rietz 2018, Munger cognitive biases)
- Runs three parallel models (Conservative, Moderate, Aggressive) to test different risk profiles
- Operates in paper trading mode for safe testing without real capital
- Uses OpenAI GPT-4o-mini for market analysis and quality scoring
- Provides a live dashboard to monitor model performance and trading signals
Development Stage: Paper Trading & Research
Live Dashboard: polymarket-trading-dashboard.vercel.app
Backend: polymarket-trading-system.onrender.com
Deployment: β
Production (Vercel + Render, $7/month)
- β Live market data streaming from Polymarket CLOB API
- β AI-powered market analysis (GPT-4o-mini + embeddings)
- β Market quality scoring (liquidity, spread, activity, clarity)
- β Multi-model architecture (3 trading strategies running in parallel)
- β Real-time signal detection and tracking
- β Resolution tracking and win rate calculation
- β Semantic market search using vector embeddings
- β Docker containerization for 24/7 operation
- β Web dashboard with live backend connection
- π§ Backtesting framework (partially implemented)
- π§ Historical trade data collection
- π§ Model performance optimization
- π§ Trade execution logic refinement
- β Real capital deployment (staying in paper mode)
- β Wallet integration (no private keys, no real trades)
- β Advanced risk management beyond basic Kelly Criterion
- β Multi-market portfolio optimization
βββββββββββββββββββββββββββββββββββββββββββ
β Frontend (Vercel) β
β - Market data ticker β
β - Model performance comparison β
β - Trading signal monitoring β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β HTTP/REST
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β FastAPI Backend (Port 8000) β
β - /api/models - Model stats β
β - /api/signals/live - Trading signals β
β - /api/quality/* - Market scoring β
β - /api/ai/* - GPT-4o analysis β
β - /api/resolution/* - Accuracy tracker β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β SQLite
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Docker Containers (4 services) β
β βββββββββββββββββββββββββββββββββββββ β
β β Conservative Model (Low Risk) β β
β β Moderate Model (Balanced) β β
β β Aggressive Model (High Risk) β β
β β Dashboard API β β
β βββββββββββββββββββββββββββββββββββββ β
βββββββββββββββββββ¬ββββββββββββββββββββββββ
β WebSocket/API
βΌ
βββββββββββββββββββββββββββββββββββββββββββ
β Polymarket CLOB API β
β - Live market data β
β - Order book feeds β
β - Market resolution data β
βββββββββββββββββββββββββββββββββββββββββββ
Each model uses the same core strategy (mean reversion) but with different risk parameters:
- Risk Level: Low
- Position Size: Small (Kelly Criterion Γ 0.25)
- Entry Threshold: High confidence only (>70% signal strength)
- Max Drawdown: 10%
- Target Win Rate: 60%+
- Risk Level: Balanced
- Position Size: Medium (Kelly Criterion Γ 0.50)
- Entry Threshold: Moderate confidence (>55%)
- Max Drawdown: 20%
- Target Win Rate: 55%+
- Risk Level: High
- Position Size: Large (Kelly Criterion Γ 1.0)
- Entry Threshold: Lower confidence (>45%)
- Max Drawdown: 35%
- Target Win Rate: 50%+
All models run in paper mode - no real capital deployed.
- Docker Desktop (for local development) OR
- Render account (for production deployment - sign up free)
- OpenAI API key (for AI features - get one here)
- Clone the repository
git clone https://github.com/b1rdmania/polymarket-ai-trading.git
cd polymarket-ai-trading- Set up environment variables
# Create .env file
cp .env.example .env
# Edit .env and add your OpenAI API key:
OPENAI_API_KEY=sk-....env file. It's in .gitignore by default.
- Start Docker containers
# Build and start all services (canonical wrapper)
bash scripts/docker.sh start
# Check status
bash scripts/docker.sh status
# View logs
bash scripts/docker.sh logs
# Run smoke checks
bash scripts/docker.sh smoke- Access the dashboard
Open http://localhost:8000 in your browser.
Cost: $7/month for 24/7 uptime (or free with 15-min spin-down)
-
Quick Deploy:
- Go to dashboard.render.com
- Click "New +" β "Blueprint"
- Connect GitHub:
b1rdmania/polymarket-ai-trading - Add environment variable:
OPENAI_API_KEY=sk-... - Click "Apply"
-
Full Guide: See RENDER_QUICKSTART.md or RENDER_DEPLOY.md
Your system will be live at: https://polymarket-trading-system.onrender.com
π View Full Documentation β
| Guide | Purpose |
|---|---|
| Getting Started | Complete setup walkthrough for beginners |
| Deploy to Render | 5-step production deployment ($7/month) |
| Paper Trading Guide | How paper trading mode works |
| Backtesting Guide | Run historical backtests |
| Docker Setup | Local development with Docker |
- Deployment: Render β’ Docker β’ Vercel
- Usage: Getting Started β’ Paper Trading β’ Backtesting
- Advanced: Raspberry Pi β’ Wallet Setup β’ Go Live
β οΈ
This system is built on academic research in prediction markets:
-
Berg & Rietz (2018) - "Longshots and Overconfidence"
- Favorite-longshot bias: Market overprices unlikely outcomes
- Mean reversion opportunities in mispriced probabilities
-
Munger's 25 Cognitive Biases
- Recency bias: Overweighting recent events
- Availability bias: Overestimating memorable events
- Confirmation bias: Seeking supporting evidence
-
Quantitative Mean Reversion
- Statistical arbitrage in probability spreads
- Kelly Criterion for position sizing
- Market quality filtering (liquidity, spread, activity)
-
@the_smart_ape Trading Insights
- Real-world Polymarket trading strategies
- Market timing and entry/exit optimization
See research/ for detailed papers and analysis.
The system includes specialized modules for different trading functions:
| Module | Purpose | Status |
|---|---|---|
| polymarket-data | Market data fetching and normalization | β Working |
| mean-reversion | Statistical arbitrage detection | β Working |
| execution-engine | Order execution and trade management | π§ Paper mode only |
| volatility-alerts | Price movement detection and alerts | β Working |
| whale-tracker | Large position monitoring | π§ Partial |
Each toolkit module is designed to be modular and reusable.
The web dashboard provides real-time monitoring:
Core Views:
- Model Comparison: Side-by-side performance of Conservative/Moderate/Aggressive models
- Live Signals: Real-time trading signals with strength indicators
- Market Quality: AI-powered scoring of tradeable markets (liquidity, spread, clarity)
- AI Insights: GPT-4o analysis of market questions with risk factors
- Resolution Tracker: Accuracy tracking on resolved markets
- Vector Search: Semantic similarity search across markets
Tech Stack:
- Frontend: Vanilla JavaScript, modern CSS (dark theme)
- Backend: FastAPI (Python)
- Database: SQLite for trade history
- AI: OpenAI GPT-4o-mini + embeddings (text-embedding-3-small)
- Deployment: Vercel (frontend) + Docker (backend)
Dashboard is mobile-responsive and updates in real-time.
The system runs as 4 containerized services:
services:
conservative: # Conservative trading model
moderate: # Moderate trading model
aggressive: # Aggressive trading model
dashboard: # FastAPI backend (port 8000)Shared Volumes:
./data- SQLite databases for trade history./logs- Application logs./config- Model configuration files
Health Checks:
- Models: Process health check every 60s
- Dashboard: HTTP health check at
/api/healthevery 30s
All containers restart automatically on failure.
β Safe:
- No real capital at risk
- No wallet private keys required
- No blockchain transactions
- API keys stored in
.env(gitignored) - Cloudflare Tunnel for secure public access
- Secure wallet with private key management
- HSM or hardware wallet integration
- Risk limits and kill switches
- Position size caps
- Drawdown monitoring
- Multi-signature for large trades
Don't rush to production. Paper trade first, validate strategy, then scale slowly.
Never commit these to Git:
OPENAI_API_KEY- OpenAI API keyPOLYGON_PRIVATE_KEY- Wallet private key (if going live)
All sensitive vars are in .env which is gitignored.
Model Performance:
- Total trades executed
- Win rate (target: >50%)
- Total P&L (paper)
- Average P&L per trade
- Open positions
- Today's activity
Market Quality:
- Liquidity score (volume-based)
- Spread score (bid-ask tightness)
- Activity score (recent volume)
- Clarity score (question readability)
System Health:
- Backend connection status
- Docker container health
- API response times
- Database size
Local: http://localhost:8000
Live: View Dashboard
The dashboard updates in real-time. Green dot = backend connected.
This is a personal research project, but I'm open to:
- Bug reports and fixes
- Documentation improvements
- Research paper contributions
- Strategy suggestions
Not accepting:
- PRs that enable live trading without proper safety checks
- Features that compromise security
Feel free to fork and experiment! Just keep it in paper mode until you really know what you're doing.
Built on research and insights from:
- Berg & Rietz (2018) - "Longshots, Overconfidence, and Efficiency in the NCAA Tournament Betting Market"
- Charlie Munger - 25 cognitive biases framework
- @the_smart_ape - Real-world Polymarket trading strategies and insights
- Polymarket community - Market data and ecosystem knowledge
- GitHub: github.com/b1rdmania/polymarket-ai-trading
- Live Dashboard: polymarket-trading-dashboard.vercel.app
- Polymarket: polymarket.com
- My GitHub: @b1rdmania
- Canton Prediction Markets - Decentralized prediction markets on Canton Network (in development)
- Aztec Auction Analysis - Privacy-preserving auction research on Aztec
This system is for educational and research purposes only.
- Not financial advice
- No guarantees of profit
- Paper trading is not the same as live trading
- Prediction markets involve risk
- Always trade responsibly with capital you can afford to lose
Use at your own risk. No warranty provided.