DEV Community

Cover image for Building a Polymarket Latency Arbitrage Bot: 200ms Edges, Data Feeds & Kelly Criterion
Adam Daniels
Adam Daniels

Posted on

Building a Polymarket Latency Arbitrage Bot: 200ms Edges, Data Feeds & Kelly Criterion

I showed a Polymarket latency bot to a quant friend. He quit his job the next week.

From $800 to $5,000. Pure latency arbitrage.

The bot doesn't try to predict outcomes better than the crowd. It simply gets the information ~200ms faster than Polymarket updates its odds and executes before the spread closes.

Core idea: In prediction markets, the edge often isn't in superior analysis — it's in superior information arrival time and execution speed.

The Latency Arbitrage Opportunity

Prediction markets like Polymarket aggregate information from many sources. For fast-moving events (sports matches, elections, breaking news), there is often a measurable delay between:

  • The moment real-world data becomes available (match result, vote count, etc.)
  • When that information is reflected in Polymarket odds

A well-built bot can:

  1. Subscribe directly to authoritative or high-speed data feeds
  2. Detect the delta before Polymarket reprices
  3. Enter the position in the narrow window before the market catches up

Every trade becomes a ~200 millisecond window of opportunity.

The Simple Profitability Formula

The original post shared this:

P = Σ(ΔOdds × Size) / Latency_gap
Enter fullscreen mode Exit fullscreen mode

Where:

  • ΔOdds = change in implied probability/price
  • Size = position size
  • Latency_gap = time advantage in milliseconds (or seconds)

Bigger gaps + faster execution = fatter edges. The bot scales in when the gap is wide and exits on convergence.

What's Running Under the Hood

A production latency bot typically includes these components:

1. High-Speed Data Ingestion Layer

  • Direct API/WebSocket connections to sports data providers (e.g., Odds API, Sportradar, official league feeds)
  • Political/news wires or real-time vote counting sources
  • Custom scrapers or official APIs for specific events
  • Goal: Receive the signal before it hits Polymarket's internal systems or market makers

2. Polymarket Integration (CLOB + Gamma)

  • Gamma API (https://gamma-api.polymarket.com): Market discovery, current odds, metadata
  • CLOB API (https://clob.polymarket.com): Real-time order book, price history, order placement
  • Official Python SDK: py-clob-client (or v2)

Use WebSockets where available for the lowest latency on order book and price updates.

3. Signal & Decision Engine

  • Compare incoming real-world data against current Polymarket mid-price
  • Calculate edge: edge = true_probability - market_price
  • Filter for sufficient latency gap and liquidity

4. Execution Engine (The 11ms part)

  • Pre-sign orders where possible
  • Use limit orders placed just inside the spread
  • Monitor for fills in real time via WebSocket
  • Automatic exit on convergence or time-based rules

5. Position Sizing: Kelly Criterion

Never size positions by gut feel. Use (fractional) Kelly:

def kelly_fraction(edge: float, odds: float, fraction: float = 0.25) -> float:
    """
    edge = your estimated probability - market implied probability
    odds = decimal odds (1 / market_price for binary)
    fraction: use 0.25 for quarter-Kelly (safer)
    """
    if edge <= 0:
        return 0.0
    b = odds - 1
    kelly = (b * edge) / b   # simplified for binary
    return min(kelly * fraction, 0.10)  # cap at 10% of bankroll
Enter fullscreen mode Exit fullscreen mode

Many serious bots use half-Kelly or quarter-Kelly to survive variance.

Example Performance Metrics (as shared)

  • Win rate: 73%
  • Sharpe ratio: 2.24
  • Trade frequency: 57 trades per hour
  • Average window: 200 milliseconds

These numbers are aggressive and depend heavily on the specific markets (sports/political events with fast information flow). Real results vary wildly based on capital, infrastructure, competition, and fees.

Technical Architecture Sketch (Python)

# High-level structure
import asyncio
from py_clob_client.client import ClobClient

# 1. Connect to fast data feeds (example: sports websocket)
# 2. Connect to Polymarket
client = ClobClient(host="https://clob.polymarket.com", ...)

async def main():
    # Subscribe to data feeds + Polymarket WebSocket
    while True:
        real_world_data = await fast_data_feed.get_latest()
        poly_price = await get_current_polymarket_price(market_id)

        edge = calculate_edge(real_world_data, poly_price)
        latency_gap = measure_latency_advantage()

        if edge > threshold and latency_gap > min_gap:
            size = kelly_sizing(edge, bankroll)
            place_order(client, market_id, side, size)  # limit order

        await asyncio.sleep(0.01)  # tight loop
Enter fullscreen mode Exit fullscreen mode

Key optimizations for speed:

  • Co-located / low-latency VPS near data centers
  • Async Python (asyncio + aiohttp/websockets)
  • Pre-computed signatures
  • Minimal logging in the hot path
  • Dedicated infrastructure (not shared hosting)

Important Realities & Caveats

This is extremely competitive. Once a latency edge becomes known and profitable, market makers and other bots close the gap quickly. What works today may disappear in weeks.

Fees, slippage, and partial fills matter. A 200ms theoretical edge can evaporate after costs.

Data source quality is everything. "Before Polymarket" usually means having faster or more direct feeds than what Polymarket's own oracles/market makers are using.

Regulatory & access issues. Prediction market access, especially from certain jurisdictions, adds complexity. Always comply with local laws.

Backtest thoroughly. Simulate latency, data delays, and execution realistically. Paper trade extensively before going live.

Sharpe 2.24 and 73% win rate are excellent — but survivorship bias and selective reporting are common in these threads.

How to Get Started as a Developer

  1. Explore the official docs: docs.polymarket.com
  2. Install the SDK: pip install py-clob-client (check for latest v2)
  3. Build a simple scanner that monitors a few markets + external data
  4. Add WebSocket listeners for real-time updates
  5. Implement basic edge detection and Kelly sizing
  6. Paper trade → small live trades → scale

Focus first on reliable infrastructure and risk management rather than chasing the absolute fastest 11ms execution.

Final Thoughts

"People analyze charts. The bot analyzes latency."

In modern prediction markets, speed + information asymmetry often beats pure predictive power for short-term edges. The best bots combine both: fast data + smart models.

Building one teaches you a lot about:

  • Real-time systems
  • API design & latency
  • Probabilistic thinking (Kelly)
  • Market microstructure

If you're serious about this space, start small, measure everything, and assume edges are temporary.

While you were reading this, a well-built bot probably already scanned several new opportunities.


Disclaimer: This is for educational and informational purposes only. Trading prediction markets involves substantial risk of loss. Past performance (or claimed performance) is not indicative of future results. Do your own research, backtest rigorously, and never risk more than you can afford to lose. The numbers and strategies discussed are illustrative.

Have you built or are you building anything in the prediction market bot space? Drop your experiences or questions in the comments!

Top comments (0)