AI-powered trading bot for Polymarket prediction markets with strategy backtesting, live deployment, risk management, and automated profit extraction.
- Multi-Strategy Portfolio: Run multiple strategies simultaneously
- Paper & Live Trading: Test strategies before deploying real capital
- AI-Powered Analysis: Claude integration for market analysis
- Risk Management: Position sizing, drawdown limits, circuit breakers
- Automated Profit Extraction: Weekly profit calculation and withdrawal
- Real-time Monitoring: Dashboard and Telegram/Discord alerts
- Python 3.11+
- Docker & Docker Compose
- Poetry (Python package manager)
- Clone the repository:
git clone https://github.com/yourusername/polymarket-bot.git
cd polymarket-bot- Copy environment file and configure:
cp .env.example .env
# Edit .env with your configuration- Start services:
make init # Installs dependencies, starts Docker, runs migrations- Start the development server:
make devThe API will be available at http://localhost:8000
Required environment variables:
# Wallet (REQUIRED for trading)
WALLET_PRIVATE_KEY=0x...
WALLET_ADDRESS=0x...
# Database
DATABASE_URL=postgresql+asyncpg://postgres:postgres@localhost:5432/polymarket_bot
REDIS_URL=redis://localhost:6379/0
# AI (optional, for market analysis)
ANTHROPIC_API_KEY=sk-ant-...polymarket-bot/
├── src/
│ ├── api/ # FastAPI routes
│ ├── core/ # Orchestrator, scheduler
│ ├── strategies/ # Trading strategies
│ ├── trading/ # Execution engine
│ ├── risk/ # Risk management
│ ├── ai/ # LLM integration
│ ├── integrations/ # Polymarket client
│ ├── profit/ # P&L tracking
│ └── db/ # Database models
├── tasks/ # Celery background tasks
├── tests/ # Test suite
└── alembic/ # Database migrations
curl -X POST http://localhost:8000/api/v1/bots \
-H "Content-Type: application/json" \
-d '{
"name": "My Trading Bot",
"initial_capital": 10,
"wallet_address": "0x...",
"mode": "paper"
}'curl -X POST http://localhost:8000/api/v1/strategies \
-H "Content-Type: application/json" \
-d '{
"bot_id": "your-bot-id",
"name": "Momentum Strategy",
"type": "momentum",
"allocation_pct": 50,
"parameters": {
"fast_ma_period": 6,
"slow_ma_period": 24
}
}'curl -X POST http://localhost:8000/api/v1/bots/{bot_id}/start| Strategy | Type | Description |
|---|---|---|
| Momentum | momentum |
Trend-following using moving average crossovers |
| Mean Reversion | mean_reversion |
Counter-trend using Bollinger Bands and RSI |
| Sentiment | sentiment |
News-based trading signals |
| Endpoint | Method | Description |
|---|---|---|
/api/v1/bots |
GET | List all bots |
/api/v1/bots |
POST | Create a new bot |
/api/v1/bots/{id}/start |
POST | Start a bot |
/api/v1/bots/{id}/stop |
POST | Stop a bot |
/api/v1/strategies |
GET | List strategies |
/api/v1/strategies |
POST | Create strategy |
/api/v1/markets |
GET | List markets |
/api/v1/positions |
GET | List positions |
/api/v1/analytics/bots/{id}/performance |
GET | Get performance |
make testmake lint
make format# Create a new migration
make migrate-create
# Apply migrations
make migrate# Start worker
make worker
# Start beat scheduler
make beat- This is experimental software. Use at your own risk.
- Start with small amounts ($10) to test.
- Polymarket has US restrictions. Ensure compliance.
- Smart contract risk exists for all funds.
- Never share your private keys.
MIT License - see LICENSE file for details.
Contributions are welcome! Please read CONTRIBUTING.md for guidelines.