Polymarket data and backtesting guides

Practical walkthroughs for working with Polymarket order book data, from reading your first book to stress testing a backtest. Each one is self contained and links into the docs and the data catalog where you need detail.

What is a prediction market order book?

Start here if order books are new to you. Binary shares priced 0 to 1, bids and asks as probability quotes, spread, depth, YES/NO complementarity, and a worked example of reading a real L2 book.

Polymarket API guide

Which official API does what (Gamma, CLOB, Data API, WebSocket), what needs a key, reading markets and books in Python, and where historical order books and trades come from.

Get the Polymarket order book in Python

The live book with Polymarket's official py-clob-client, then historical books with the Marketlens SDK, including spread and midpoint analysis.

Get Polymarket odds history in Python

Historical odds three ways: find any market, download its price history as candles, inspect the book behind the price at any past moment, and score odds against resolved outcomes.

Polymarket price history in Python

The official prices-history endpoint with its exact parameters and limits, then candles, trades, and the order book behind every price from the archive on the same window.

Execution backtesting: order level replay

The execution engine workflow: pick a series, write a Strategy subclass, run it against real order books, read the metrics, then add latency, slippage, queue position, and platform fees.

Alpha research: signal backtesting

Test whether a signal is profitable across thousands of markets and long windows: AlphaStrategy, on_bar, target weights, and the resolution, price, and fill options.

Reading backtest results

What both engines return: the summary metrics from win rate to fee drag, the DataFrames underneath, the dashboard, racing strategies, and saving runs.

Try it

Put a guide into practice

The free tier includes 1M rows per day with full API and full archive access, no card required.

bash
$ pip install marketlens