Open-source Polymarket trading infrastructure and strategy reverse-engineering toolkit.
Polybot provides a complete trading infrastructure for Polymarket prediction markets, along with powerful tools to analyze and reverse-engineer successful trading strategies from any user.
- Executor Service: Low-latency order execution with paper trading simulation
- Strategy Service: Pluggable strategy framework for automated trading
- Real-time Market Data: WebSocket integration for order book and trade feeds
- Position Management: Automatic tracking, settlement, and token redemption
- Risk Management: Configurable limits, kill switches, and exposure caps
- User Trade Analysis: Ingest and analyze any Polymarket user's trading history
- Pattern Recognition: Identify entry/exit signals, sizing rules, and timing patterns
- Replication Scoring: Compare your bot's decisions against target strategies
- Backtesting Framework: Test strategies against historical data
- ClickHouse Integration: High-performance time-series analytics
- Event Streaming: Kafka-based event pipeline for real-time analysis
- Monitoring: Grafana dashboards and Prometheus metrics
┌─────────────────────────────────────────────────────────────────┐
│ Polybot Architecture │
├─────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │
│ │ Strategy │ │ Executor │ │ Ingestor │ │
│ │ Service │──│ Service │ │ Service │ │
│ │ │ │ │ │ │ │
│ │ • Strategies │ │ • Order Mgmt │ │ • User Trades │ │
│ │ • Signals │ │ • Simulator │ │ • Market Data │ │
│ │ • Positions │ │ • Settlement │ │ • On-chain Events │ │
│ └──────────────┘ └──────────────┘ └──────────────────────┘ │
│ │ │ │ │
│ └─────────────────┼────────────────────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ Kafka │ │
│ │ Events │ │
│ └──────┬──────┘ │
│ │ │
│ ┌──────▼──────┐ │
│ │ ClickHouse │ │
│ │ Analytics │ │
│ └─────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────┘
- Java 21+
- Maven 3.8+
- Docker & Docker Compose
- Python 3.11+ (for research tools)
git clone https://github.com/yourusername/polybot.git
cd polybot
# Copy environment template
cp .env.example .env
# Edit .env with your configuration
# At minimum, set POLYMARKET_TARGET_USER to analyze# Start ClickHouse and Kafka
docker-compose -f docker-compose.analytics.yaml up -d
# Optional: Start monitoring stack
docker-compose -f docker-compose.monitoring.yaml up -d# Build all services
mvn clean package -DskipTests
# Start executor (paper trading mode by default)
cd executor-service && mvn spring-boot:run -Dspring-boot.run.profiles=develop
# Start strategy service (in another terminal)
cd strategy-service && mvn spring-boot:run -Dspring-boot.run.profiles=develop
# Start ingestor (in another terminal) - ingests target user's trades
cd ingestor-service && mvn spring-boot:run -Dspring-boot.run.profiles=developcd research
# Create Python virtual environment
python3 -m venv .venv
source .venv/bin/activate
pip install -r requirements.txt
# Take a snapshot of target user's data
python snapshot_report.py
# Run deep analysis
python deep_analysis.py
# Compare your bot's execution vs target
python sim_trade_match_report.py| Variable | Description | Required |
|---|---|---|
POLYMARKET_TARGET_USER |
Username to analyze/replicate | Yes (for research) |
POLYMARKET_PRIVATE_KEY |
Wallet private key | For live trading |
POLYMARKET_API_KEY |
API credentials | For live trading |
ANALYTICS_DB_URL |
ClickHouse connection | For analytics |
See .env.example for complete configuration reference.
| Mode | Description |
|---|---|
PAPER |
Simulated trading (default) |
LIVE |
Real money trading |
Handles order execution, position management, and settlement.
# API Examples
curl http://localhost:8080/api/polymarket/health
curl http://localhost:8080/api/polymarket/positions
curl http://localhost:8080/api/polymarket/settlement/planRuns trading strategies and generates signals.
curl http://localhost:8081/api/strategy/statusIngests market data and user trades into ClickHouse.
Provides analytics APIs over ClickHouse data.
The repository includes a fully-implemented complete-set arbitrage strategy for Polymarket Up/Down binary markets:
- Edge Detection: Identifies when UP + DOWN prices sum to less than $1
- Inventory Skewing: Adjusts quotes to balance positions
- Fast Top-Up: Quickly completes pairs after partial fills
- Taker Mode: Crosses spread when edge is favorable
See docs/EXAMPLE_STRATEGY_SPEC.md for detailed documentation.
The research/ directory contains Python tools for strategy analysis:
| Script | Purpose |
|---|---|
snapshot_report.py |
Take data snapshots for analysis |
deep_analysis.py |
Comprehensive strategy analysis |
replication_score.py |
Score how well you're replicating |
sim_trade_match_report.py |
Compare sim vs target execution |
paper_trading_dashboard.py |
Jupyter dashboard for monitoring |
polybot/
├── executor-service/ # Order execution & settlement
├── strategy-service/ # Trading strategies
├── ingestor-service/ # Data ingestion
├── analytics-service/ # Analytics APIs
├── polybot-core/ # Shared libraries
├── research/ # Python analysis tools
├── docs/ # Documentation
└── monitoring/ # Grafana/Prometheus configs
We welcome contributions! See CONTRIBUTING.md for guidelines.
- New trading strategies
- Additional market types support
- Improved analytics and visualizations
- Better backtesting framework
- More reverse-engineering tools
This software is for educational and research purposes only.
- Trading prediction markets involves significant financial risk
- Past performance does not guarantee future results
- You are solely responsible for your trading decisions
- Always start with paper trading before using real funds
MIT License - see LICENSE for details.
Built with curiosity about how successful traders operate on Polymarket.
