polymarket · prediction-markets · github · market-microstructure · backtesting
Four free GitHub repos, each covering one thing you should know before you put money on a Polymarket contract: where the data is, how a strategy would have filled, who has been winning, and what the order book really costs you.
For each one: what it does, what's inside, and the link. At the end: the order I'd use them in.
pmxt calls itself the ccxt for prediction markets. Polymarket, Kalshi, Limitless, Opinion, Smarkets and more sit behind one interface, so the same calls fetch markets, order books and trades across venues. There are Python and TypeScript SDKs, a command line tool, and an MCP server so an AI agent can query it too.
It's MIT licensed. You can use their hosted API with a key or run the open-source server yourself.
The team also keeps a free order book archive: hourly files of Polymarket's order book, every snapshot and every price change. That is the raw material the next repo replays.
Open it: pmxt · Archive: archive.pmxt.dev
A price-only backtest assumes you fill at the last traded price. This one replays the actual Polymarket order book from the pmxt archive, built on NautilusTrader, the open-source trading engine.
A market order walks the replayed book, so a big order fills across several price levels like it would live. A limit order waits in a queue behind the size already sitting at its price. Fees come from Polymarket's fee schedule, and latency is modeled too, 75 milliseconds in their setup. The docs are upfront that the queue model is an estimate, not the venue's true order of arrival.
It also charts a cumulative Brier advantage, a running score of your probabilities against the market's, next to the P&L.
Open it: prediction-market-backtesting
Jon Becker's repo ships the largest public dataset of Polymarket and Kalshi markets and trades, 36 GiB compressed, plus the indexers to keep collecting and scripts that turn it into figures. Its README lists ten 2026 research papers that use or cite it.
His own paper runs on the Kalshi half: 72.1 million trades, 18.26 billion dollars of volume. Takers, the people who cross the spread, lost 1.12% per trade on average before fees. Makers, the people whose resting orders they hit, earned the same 1.12%. And longshots are overpriced: contracts trading at 5 cents won only 4.18% of the time.
If you plan to buy cheap YES contracts with market orders, that is the trade the data says loses.
Open it: prediction-market-analysis
Philipp Dubach recorded 30 billion order book events over 52 days, joined them to the on-chain trade record, and studied a pre-registered panel of 600 markets. The repo is the full replication package, including the panel data.
I plotted the spreads straight from it:

Near 50 cents the median spread is 400 basis points, 4% of the price. Below 10 cents it's 1,818, so buying at the ask and selling back at the bid costs 18% of what you paid before the event even happens.
One more finding matters if you're building tools: trade direction inferred from Polymarket's public feed matches the on-chain truth only about 59% of the time, against roughly 80% for the standard method on stocks. If your signal depends on who bought and who sold, take direction from the chain.
Open it: polymarket-microstructure
Start with polymarket-microstructure and Becker's dataset, because they tell you what the market costs and who it pays before you've risked anything. Then pull data through pmxt and test your idea on the replayed book in the backtester, where spreads, queues and fees are already in the result.
None of this hands you an edge. It shows you what you're up against: wide spreads at the cheap end, takers paying makers on average, and a feed that misreads who traded.
Those three are the subject of QuantFrame's Market Microstructure module: the limit order book, queue position, market makers and the spread, and the true cost of a trade.
The repos are free. When you want to understand the book they're replaying, your roadmap is waiting at quantframe.io.
Found this useful?
Likes decide what gets written next.Sign in to like
QuantFrame teaches you the math, code, and projects to break into quant. Plus a personalized roadmap built for your background and goals.