Automated arbitrage detection bot for prediction markets (Polymarket & Kalshi) made by Jasper Buffet, Mark Burry and Duco Munger.
- Real-time market data from Polymarket and Kalshi
- Fuzzy text matching to find equivalent markets across platforms
- Automatic arbitrage opportunity detection (2%+ profit threshold)
- Discord webhook notifications
- Price validation and liquidity filtering
- Install dependencies:
cd arbitrage_bot
pip install -r requirements.txt- Configure credentials in
.env:
KALSHI_API_KEY_ID=your_api_key_id
KALSHI_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n...\n-----END RSA PRIVATE KEY-----"
DISCORD_WEBHOOK=https://discord.com/api/webhooks/...- Adjust settings in
config.yaml:
arbitrage:
min_profit_pct: 2.0 # Minimum 2% profit to report
min_liquidity: 500 # Minimum $500 liquidity
check_interval: 30 # Check every 30 seconds
matching:
min_confidence: 0.65 # 65% similarity thresholdSee a guaranteed 27% arbitrage opportunity:
python test_bot.py --mockFetch live markets and check for opportunities:
python test_bot.pyCheck for opportunities every 30 seconds:
python -m src.main --continuousOr run once:
python -m src.main --once- Fetch Markets: Retrieves active markets from Polymarket and Kalshi
- Match Markets: Uses fuzzy text matching to find equivalent markets
- Calculate Arbitrage: Checks if buying YES on one platform + NO on another guarantees profit
- Notify: Sends Discord notification when opportunities are found
If the same event has different prices on each platform:
- Polymarket: YES = $0.35, NO = $0.65
- Kalshi: YES = $0.62, NO = $0.38
Strategy: Buy YES on Polymarket ($0.35) + Buy NO on Kalshi ($0.38)
- Cost: $0.73
- Payout: $1.00 (guaranteed)
- Profit: $0.27 (27%)
No matter the outcome, one position pays $1.00!
arbitrage_bot/
├── config.yaml # Configuration settings
├── .env # API credentials (not in git)
├── test_bot.py # Testing script
├── src/
│ ├── main.py # Entry point
│ ├── api/
│ │ ├── polymarket.py # Polymarket API client
│ │ └── kalshi.py # Kalshi API client (JWT auth)
│ ├── matching/
│ │ ├── semantic_matcher.py # Market matching logic
│ │ └── normalizer.py # Text normalization
│ ├── arbitrage/
│ │ ├── detector.py # Orchestrates detection
│ │ └── calculator.py # Arbitrage math
│ └── utils/
│ ├── config.py # Config loader
│ ├── logger.py # Logging
│ └── notifier.py # Discord notifications
The bot is fully functional but currently finds 0 opportunities because:
- Polymarket focuses on politics, economics, crypto
- Kalshi currently only has sports betting markets
- No overlap = no arbitrage opportunities
The bot will automatically detect opportunities when the platforms offer the same events.
.envfile is in.gitignore(never commit credentials!)- API keys stored as environment variables
- RSA private key authentication for Kalshi