System Overview

The Polymarket Trading Platform is a hybrid automated trading system built with Node.js and Go. It specializes in identifying market inefficiencies (EV+) across Football, Tennis, Baseball, and Crypto markets.

Current Version: Quantitative V2.0 - Supporting dynamic EV calculation, Kelly Criterion sizing, and atomic file locking.

Main Components

Node.js

Football/Tennis Scanner

Fetches odds from api-football & HKJC, removes vig, and identifies EV+ opportunities.

live/football/odds_scanner.mjs

Node.js

Trading Bot

Executes orders, manages trailing stops (+25%), and monitors open positions.

live/football/bot.js

Go

Polymarket Hub

Web dashboard (Port 8421) for portfolio monitoring and manual order management.

polymarket-hub/

Node.js

Sports Redeemer

Automated service (PM2 cron) that redeems winnings and converts to pUSD.

src/redeemer-sports.js

Running the System

Core Commands

# Start the Football Bot
bash start-football.sh

# Build & Run Polymarket Hub
cd polymarket-hub
go build -o polymarket-hub ./cmd/hub/
./polymarket-hub -config config.yaml

# View Logs
pm2 logs football
pm2 logs polymarket-hub

Configuration

Key Recommended Description
DRY_RUN true Global safety switch
bet_size $2 - $5 Default stake per trade
MAX_AUTOBOOK_PRICE 0.65 Max share price for auto-buys

Hub UI Controls

The web dashboard provides controls for each active football trade:

Button Action Description
Exit force_tp Immediately sells the position at the best available bid price. This is a manual override to exit a trade.
TP Lock block_tp Prevents the automated bot from exiting a position. This is used to hold the position until the market resolves, ignoring trailing stop-loss or take-profit signals.
Unlock unblock_tp Re-enables the bot's automated exit logic, allowing it to manage the trade based on its pre-defined strategy.

Quantitative Model

The system uses professional betting mathematics to maintain a statistical edge.

1. Vig Removal (True Probability)

The scanner calculates the "Fair Price" by normalizing bookmaker odds across all outcomes (Home, Draw, Away).

2. Expected Value (EV)

We only trade when the Expected Value is positive:

EV = (True_Probability / Polymarket_Price) - 1

3. Kelly Criterion

Position sizing is determined by Quarter-Kelly (0.25) to maximize growth while minimizing the risk of ruin.

Safety Rules

Rule #1: Never kill the football bot manually. Always use stop-football.sh or pm2 stop to avoid corrupting the trades.json file.

Architecture

The platform follows a "Scanner-to-Approved" pipeline:

  1. Scanner identifies EV+ opportunities.
  2. Successful picks are written to approved_bets.json under an atomic lock.
  3. Trading Bot reads the JSON and executes Limit Orders.
  4. Redeemer cleans up winning positions every 30 minutes.