Poly Research & Robotics
TUTORIAL · 6 steps · 90 minutes

Mastering the Orderbook

Reconstruct live books via WebSocket, compute executable edge, and paper-trade with realistic fills on Polymarket's BTC 5-Minute market.

By Poly Research & Robotics Research6 steps~90 minutes
Mastering the Orderbook
Welcome

Polymarket prices are outcome-token prices, not clean probabilities. This tutorial shows you how to reconstruct a live book, compute real executable edge, and build a paper-trading loop that survives contact with actual spreads and latency.

Estimated time: 90 minutes Format: Step-by-step
What you'll learn
  • Why edge = fair_prob minus effective fill price, never midpoint
  • How to map UP and DOWN token IDs without guessing
  • How to reconstruct a live level-2 book from WebSocket deltas
  • How to compute spread, depth, microprice, and diffusion fair value
  • How to gate signals with regime filters and churn guards
  • How to paper-trade with latency-aware depth-walked fills and markout logging
What you'll need
  • Python 3.10+ with websockets, httpx, scipy, and numpy installed
  • Familiarity with REST and WebSocket APIs (exchange experience is fine)
  • A Polymarket account for reading market metadata (no funds required for paper trading)
  • Basic understanding of binary options or prediction markets is helpful but not required
Join Discord