Skip to content

donoaccestag/polymarket-sports-trading-bot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Polymarket Cross-Line Arbitrage Bot

A polymarket trading bot that detects temporary pricing inefficiencies across connected Polymarket sports markets.

whoami

Who-am-i on Polymarket -> sold-my-car-to-bet

Live Performance

πŸŽ₯ Watch the trading bot execute live

live.mp4

Connect

πŸ“§ hacki13128@gmail.com

πŸ“ž https://t.me/hackonmon

Have an idea for prediction markets or AI trading? Feel free to reach out.


Risk Mangement by Kelly Criterion

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.


My Recommendation

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 ❀️


Features

  • ⚑ 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

Strategy

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

Quick Start

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:sim

CLI

npm start -- --mode sim
npm start -- --mode live --confirm-live
npm start -- --event nba-lal-bos-2026-01-15
npm start -- --tag 100381

CLI Options

Flag Description
--mode sim Simulation mode
--mode live Live trading
--event Watch specific event
--tag Filter Gamma tags
--confirm-live Required safety confirmation

Terminal Dashboard

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ 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.


Configuration

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

Architecture

                Gamma REST
                     β”‚
                     β–Ό
               Event Graph
                     β”‚
                     β–Ό
              Market Classifier
                     β”‚
                     β–Ό
           CLOB REST / WebSocket
                     β”‚
                     β–Ό
             OrderBook Store
                     β”‚
                     β–Ό
            Arbitrage Detector
                     β”‚
                     β–Ό
              Risk Management
                     β”‚
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β–Ό                         β–Ό
 Sim Executor              Live Executor
        β”‚                         β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                     β–Ό
            Portfolio + Dashboard

Live Trading

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.


Project Structure

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

Contributing

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.


Built with ❀️ for the Polymarket developer community.

If this repository helped you learn something new, consider giving it a ⭐.

About

polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot polymarket trading bot

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors