Skip to content
Zihao Ye
All work

Polymarket bot

Async Trading on Prediction Markets

A high-throughput Python bot that monitors thousands of Polymarket prediction markets in real time and auto-executes risk-free arbitrage trades when YES + NO token prices drift below $1.

Role
Builder
When
Oct 2025 – Jan 2026

A live-trading bot for Polymarket binary-outcome markets. Every market has two complementary tokens — YES and NO — that together must pay out exactly $1. Whenever their combined price slips below $1, buying both locks in guaranteed profit regardless of how the event resolves. The bot watches for those gaps across the entire venue and trades them in milliseconds.

What it does

  • Streams real-time prices from Polymarket's CLOB over 6 parallel WebSocket connections, covering up to 1,500 markets concurrently.
  • Filters to markets with at least $10k liquidity and resolution within 7 days, where mispricings are tradeable.
  • Detects pure arbitrage opportunities (YES + NO < $1, net of fees and gas) and fires both legs through the CLOB with low-latency async execution.
  • Exposes a small web dashboard for live order visibility and Slack notifications for every fill.

What I built

  • A Python 3.12 service built on asyncio, aiohttp, and websockets, with parallel order signing via web3.py + eth-account for sub-second execution.
  • A CLOB client integration (py-clob-client) with order monitoring, 10-second timeouts, and auto-cancellation.
  • A FastAPI + Jinja2 dashboard served behind HTTPS with auto SSL, plus aiosqlite for trade history.
  • Geo-distributed architecture: bot in us-east-1 for WebSocket latency, SOCKS5 proxy in ca-central-1 for order placement (Polymarket blocks US IPs).
  • Infrastructure-as-code provisioning under infra/ (OpenTofu + Ansible) to spin the whole stack up reproducibly.