MCPcopy Index your code
hub / github.com/Jon-Becker/prediction-market-analysis

github.com/Jon-Becker/prediction-market-analysis @main sqlite

repository ↗ · DeepWiki ↗
321 symbols 1,165 edges 61 files 204 documented · 64%
README

Prediction Market Analysis

A framework for analyzing prediction market data, including the largest publicly available dataset of Polymarket and Kalshi market and trade data. Provides tools for data collection, storage, and running analysis scripts that generate figures and statistics.

Overview

This project enables research and analysis of prediction markets by providing: - Pre-collected datasets from Polymarket and Kalshi - Data collection indexers for gathering new data - Analysis framework for generating figures and statistics

Currently supported features: - Market metadata collection (Kalshi & Polymarket) - Trade history collection via API and blockchain - Parquet-based storage with automatic progress saving - Extensible analysis script framework

Installation & Usage

Requires Python 3.9+. Install dependencies with uv:

uv sync

Download and extract the pre-collected dataset (36GiB compressed):

make setup

This downloads data.tar.zst from Cloudflare R2 Storage and extracts it to data/.

Data Collection

Collect market and trade data from prediction market APIs:

make index

This opens an interactive menu to select which indexer to run. Data is saved to data/kalshi/ and data/polymarket/ directories. Progress is saved automatically, so you can interrupt and resume collection.

Running Analyses

make analyze

This opens an interactive menu to select which analysis to run. You can run all analyses or select a specific one. Output files (PNG, PDF, CSV, JSON) are saved to output/.

Packaging Data

To compress the data directory for storage/distribution:

make package

This creates a zstd-compressed tar archive (data.tar.zst) and removes the data/ directory.

Project Structure

├── src/
│   ├── analysis/           # Analysis scripts
│   │   ├── kalshi/         # Kalshi-specific analyses
│   │   └── polymarket/     # Polymarket-specific analyses
│   ├── indexers/           # Data collection indexers
│   │   ├── kalshi/         # Kalshi API client and indexers
│   │   └── polymarket/     # Polymarket API/blockchain indexers
│   └── common/             # Shared utilities and interfaces
├── data/                   # Data directory (extracted from data.tar.zst)
│   ├── kalshi/
│   │   ├── markets/
│   │   └── trades/
│   └── polymarket/
│       ├── blocks/
│       ├── markets/
│       └── trades/
├── docs/                   # Documentation
└── output/                 # Analysis outputs (figures, CSVs)

Documentation

Contributing

If you'd like to contribute to this project, please open a pull-request with your changes, as well as detailed information on what is changed, added, or improved.

For more information, see the contributing guide.

Issues

If you've found an issue or have a question, please open an issue here.

Research & Citations

  • Becker, J. (2026). The Microstructure of Wealth Transfer in Prediction Markets. Jbecker. https://jbecker.dev/research/prediction-market-microstructure
  • Le, N. A. (2026). Decomposing Crowd Wisdom: Domain-Specific Calibration Dynamics in Prediction Markets. arXiv. https://arxiv.org/abs/2602.19520
  • Akey P., Gregoire, V., Harvie, N., Martineau, C. (2026). Who Wins and Who Loses In Prediction Markets? Evidence from Polymarket. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6443103
  • Vedova, J. (2026). Who Profits from Prediction Markets? Execution, not Information. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6191618
  • Brown, A. (2026). Cassandra Or the Boy Who Cried Wolf? Are Prediction Markets Effective Early Warning Systems?. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6381538
  • Reichenbach, F., Walther, M. (2025). Exploring Decentralized Prediction Markets: Accuracy, Skill, and Bias on Polymarket. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=5910522
  • Bartlett, R., O'Hara, M. (2026). Adverse Selection in Prediction Markets: Evidence from Kalshi. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6615739
  • Luong, K. L., Heesen, G. (2026). The Wisdom of the Few: Skilled Traders and Prediction Market Accuracy. SSRN. https://papers.ssrn.com/sol3/papers.cfm?abstract_id=6758662

If you have used or plan to use this dataset in your research, please reach out via email or Twitter -- i'd love to hear about what you're using the data for! Additionally, feel free to open a PR and update this section with a link to your paper.

Core symbols most depended-on inside this repo

get
called by 64
src/common/client.py
save
called by 15
src/common/analysis.py
load
called by 9
src/common/indexer.py
progress
called by 7
src/common/analysis.py
from_dict
called by 6
src/indexers/kalshi/models.py
_format_number
called by 5
src/analysis/kalshi/meta_stats.py
close
called by 4
src/indexers/polymarket/client.py
get_block_number
called by 4
src/indexers/polymarket/blockchain.py

Shape

Method 218
Class 55
Function 48

Languages

Python100%

Modules by API surface

tests/test_analysis_save.py23 symbols
src/indexers/polymarket/blockchain.py15 symbols
src/common/interfaces/chart.py15 symbols
tests/conftest.py14 symbols
src/indexers/polymarket/fpmm_trades.py13 symbols
src/indexers/kalshi/client.py11 symbols
src/common/client.py11 symbols
src/indexers/kalshi/models.py10 symbols
src/analysis/kalshi/statistical_tests.py9 symbols
src/analysis/comparison/win_rate_by_price_animated.py9 symbols
src/indexers/polymarket/blocks.py8 symbols
tests/test_backfill_cursor.py7 symbols

Dependencies from manifests, versioned

brokenaxes0.6.2 · 1×
cryptography46.0.3 · 1×
duckdb1.4.2 · 1×
httpx0.28.1 · 1×
imageio2.36.0 · 1×
kalshi-python2.1.4 · 1×
matplotlib3.9.4 · 1×
pandas2.3.3 · 1×
polymarket-py0.1.0 · 1×
pyarrow18.0.0 · 1×
python-dotenv1.2.1 · 1×
requests2.32.5 · 1×

For agents

$ claude mcp add prediction-market-analysis \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact