A polymarket trading bot that detects temporary pricing inefficiencies across connected Polymarket sports markets.
Who-am-i on Polymarket -> sold-my-car-to-bet
π₯ Watch the trading bot execute live
live.mp4
π§ hacki13128@gmail.com
Have an idea for prediction markets or AI trading? Feel free to reach out.
While building this project I also created:
STAKE-MATH
A Node.js library implementing Kelly-based stake sizing and probability mathematics.
Trading is not gambling.
Trading is probability management.
Without mathematics, risk management becomes guessing.
Many of the position sizing models used here are based on the Kelly Criterion, fractional Kelly, expected value, and bankroll optimization.
Those mathematical foundations have been responsible for far more of my long-term success than any individual trading strategy.
If you decide to experiment with this project:
- start with simulation mode
- understand every trade the bot makes
- test your own ideas
- use small position sizes
- never risk money you cannot afford to lose
Happy Trading β€οΈ
- β‘ Real-time Polymarket CLOB streaming
- π§ Cross-line arbitrage detection
- π Kelly Criterion stake sizing
- π° Paper trading & Live trading
- π‘ Risk management engine
- π Beautiful terminal dashboard
- π§© Modular architecture
- π Structured logging
- π Production-oriented TypeScript codebase
Sports markets inside a single event should satisfy several no-arbitrage relationships.
Whenever one market reprices faster than another after new information arrives, temporary inefficiencies can appear.
The bot continuously:
Gamma API
β
βΌ
Discover connected markets
β
βΌ
Stream live CLOB orderbooks
β
βΌ
Detect pricing violations
β
βΌ
Risk evaluation
β
βΌ
Kelly stake sizing
β
βΌ
Submit limit orders
β
βΌ
Track positions & PnL
Current arbitrage checks include:
- Complementary YES/NO pairs
- Totals ladder relationships
- Spread ladder relationships
- Moneyline vs Spread
- Three-way market sums
- BTTS relationships
git clone https://github.com/Poly-Sports/polymarket-sports-arbitrage-bot.git
cd polymarket-sports-arbitrage-bot
cp .env.example .env
npm install
npm run start:simnpm start -- --mode simnpm start -- --mode live --confirm-livenpm start -- --event nba-lal-bos-2026-01-15npm start -- --tag 100381| Flag | Description |
|---|---|
--mode sim |
Simulation mode |
--mode live |
Live trading |
--event |
Watch specific event |
--tag |
Filter Gamma tags |
--confirm-live |
Required safety confirmation |
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β Header β
β Mode β’ WS Status β’ Balance β’ PnL β’ Uptime β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Tracked Markets β Opportunities β
ββββββββββββββββββββββββββββββ΄βββββββββββββββββββββββββββββββββββ€
β PnL Chart Exposure β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Orders / Fills β Alerts β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
[p] Pause
[f] Flatten
[q] Quit
Logs are written separately using Pino so they never corrupt the dashboard.
See .env.example.
Important variables:
| Variable | Default | Description |
|---|---|---|
| MODE | sim | sim or live |
| MIN_NET_EDGE_BPS | 50 | Minimum edge |
| MAX_POSITION_USD | 500 | Max Kelly stake |
| KELLY_FRACTION | 0.5 | Half Kelly |
| MIN_STAKE_USD | 5 | Minimum trade |
| MAX_EVENT_EXPOSURE_USD | 200 | Event exposure cap |
| DAILY_LOSS_LIMIT_USD | 100 | Kill switch |
| SIM_INITIAL_BALANCE | 10000 | Paper balance |
Gamma REST
β
βΌ
Event Graph
β
βΌ
Market Classifier
β
βΌ
CLOB REST / WebSocket
β
βΌ
OrderBook Store
β
βΌ
Arbitrage Detector
β
βΌ
Risk Management
β
ββββββββββββββ΄βββββββββββββ
βΌ βΌ
Sim Executor Live Executor
β β
ββββββββββββββ¬βββββββββββββ
βΌ
Portfolio + Dashboard
Live mode requires:
PRIVATE_KEY
CLOB_API_KEY
CLOB_API_SECRET
CLOB_API_PASSPHRASE
and either
--confirm-live
or
CONFIRM_LIVE=true
Execution uses
@polymarket/clob-client-v2
against production endpoints.
src/
βββ arb/
β βββ Arbitrage detection
βββ config/
β βββ Zod configuration
βββ core/
β βββ Engine
βββ data/
β βββ Gamma
β βββ CLOB REST
β βββ WebSocket
βββ exec/
β βββ Simulation
β βββ Live
β βββ Order Manager
βββ model/
β βββ Event Graph
β βββ Classifier
βββ portfolio/
β βββ PnL
βββ risk/
β βββ Exposure controls
βββ ui/
β βββ blessed-contrib dashboard
βββ util/
βββ Logging
βββ Math
βββ Rate limiting
Contributions are welcome.
Whether you're interested in:
- quantitative trading
- prediction markets
- TypeScript
- market microstructure
- performance optimization
feel free to open an Issue or Pull Request.
If this repository helped you learn something new, consider giving it a β.
