smf-ulm's picture
Update README.md
b85406f verified
---
license: cc-by-4.0
language:
- en
pretty_name: Polymarket Quant Bench OHLCV bars for high-liquidity resolved markets
size_categories:
- 10M<n<100M
task_categories:
- other
tags:
- polymarket
- prediction-markets
- blockchain
- polygon
- market-microstructure
- ohlcv
- backtesting
- quantitative-finance
configs:
- config_name: markets
data_files:
- split: train
path: "polymarket/markets/markets_*.parquet"
- config_name: bars_hourly
data_files:
- split: train
path: "polymarket/bars_hourly/bars_*.parquet"
- config_name: bars_daily
data_files:
- split: train
path: "polymarket/bars_daily/bars_*.parquet"
---
# Polymarket Quant Bench — OHLCV bars for high-liquidity resolved markets
A teaching-grade derivative of the [Polymarket](https://polymarket.com)
on-chain trade history, designed for indicator-engineering and
walk-forward back-testing assignments. Polymarket is a decentralised
prediction market on the Polygon blockchain; binary contracts settle to
one USDC if the underlying event occurs and zero otherwise.
This release replaces the per-trade fill stream of the upstream dataset
with **per-token OHLCV bars** at hourly and daily resolution, restricted
to high-liquidity *resolved* markets so every market has a known outcome
for P&L scoring and enough depth for rolling indicators.
## Contents
| File group | Rows | Description |
|---|---:|---|
| `polymarket/markets/markets_*.parquet` | 36,831 | One row per resolved market with cumulative volume >= $100,000 and >= 200 on-chain trade fills. Full upstream schema plus a `category` column. |
| `polymarket/bars_hourly/bars_*.parquet` | 12,655,266 | One row per `(token_id, calendar hour)` with OHLCV plus trade and direction counts. |
| `polymarket/bars_daily/bars_*.parquet` | 1,462,282 | One row per `(token_id, calendar day)`, aggregated from the hourly bars. |
Each file group is chunked into 10,000-row parquet shards.
## Provenance and attribution
The raw market metadata and trade events were collected and released by
**Jon Becker** at
[https://github.com/jon-becker/prediction-market-analysis](https://github.com/jon-becker/prediction-market-analysis).
This dataset is a derivative: market metadata is restricted to the
filter described below and trades are aggregated into OHLCV bars. If you
use this dataset, please also cite Jon Becker's release.
## How prices are computed
Each on-chain `OrderFilled` event swaps **USDC** for an **outcome
token** (or vice versa). Both assets use 6 decimals, so the raw atomic
ratio of USDC to token quantity is already a dimensionless probability
in `[0, 1]` -- the price the Polymarket UI shows in cents-per-dollar.
For each trade `t`:
```
if t.maker_asset_id == '0': # maker delivered USDC, taker delivered tokens
usdc_amount = t.maker_amount
token_amount = t.taker_amount
taker_is_seller = True # taker handed over tokens -> sold
else: # maker delivered tokens, taker delivered USDC
usdc_amount = t.taker_amount
token_amount = t.maker_amount
taker_is_seller = False # taker handed over USDC -> bought
price = usdc_amount / token_amount # in [0, 1]
volume_usd = usdc_amount / 1e6 # in USD
signed_size = (-1 if taker_is_seller else +1) * token_amount / 1e6
```
`price` is the implied probability of the outcome the token represents.
## How bars are aggregated
For each `(token_id, bar_period)` group:
| Field | Formula |
|---|---|
| `open` | `price` of the first trade in the bar (ordered by `block_number, log_index`) |
| `high` | `MAX(price)` |
| `low` | `MIN(price)` |
| `close` | `price` of the last trade |
| `vwap` | `SUM(price * volume_usd) / SUM(volume_usd)` |
| `volume_usd` | `SUM(volume_usd)` |
| `n_trades` | total fills in the bar |
| `n_buys` / `n_sells` | fills where the taker bought / sold outcome tokens |
Bars are emitted **only when at least one trade occurred in the period**
(sparse representation). Use `tidyr::fill()` or
`data.table::nafill()` to forward-fill if a dense series is required by
your indicator.
The hour boundary is defined by `block_number // 1800` (Polygon ~2 s per
block; 1 800 blocks = 1 hour). Wall-clock `period_start` is attached
post-aggregation by looking up the first block of each hour in the
blocks-timestamp index and extrapolating forward at 2 seconds per
block.
Bars are emitted **per token** rather than per market. A Polymarket
market has two complementary tokens (YES and NO); the `markets` table
exposes both via `clob_token_ids`. If you want a single market-level
mid-price series, pair the two token series yourself.
## Filter applied to upstream markets
A market is included iff **all** of the following hold:
1. The market is **resolved** (one outcome price closed above 0.99 in
the upstream snapshot).
2. **Cumulative trading volume >= $100,000** -- removes the long
tail of dust markets.
3. **At least 200 on-chain trade fills** -- ensures enough
depth to compute rolling indicators meaningfully.
This intentionally trades coverage for per-market depth. About
36,831 markets remain out of the ~409 k in the upstream snapshot.
## Schemas
### `markets/markets_*.parquet`
Upstream columns from Jon Becker's release plus `category`. Notable
ones:
| column | type | description |
|---|---|---|
| `id` | string | Polymarket market id (primary key). |
| `condition_id` | string | Parent CTF condition id. |
| `question` | string | The question prompt. |
| `slug` | string | URL slug. |
| `outcomes` | string | JSON outcome labels, e.g. `["Yes","No"]`. |
| `outcome_prices` | string | JSON outcome prices at snapshot time. The winning outcome closes near 1. |
| `clob_token_ids` | string | JSON `[yes_token_id, no_token_id]`. Use to join bars to a market. |
| `volume` | double | Cumulative USDC traded. |
| `liquidity` | double | Snapshot depth. |
| `end_date` | timestamp | Useful as `resolution_date` for held-out cohorts. |
| `created_at` | timestamp | Market creation. |
| `category` | string | Best-effort topic label. Use cautiously. |
### `bars_hourly/bars_*.parquet` and `bars_daily/bars_*.parquet`
| column | type | description |
|---|---|---|
| `token_id` | string | CTF outcome-token id. |
| `period_start` | timestamp | Bar start, UTC. |
| `period_end` | timestamp | `period_start + 1 hour` (or `+ 1 day`). |
| `open` / `high` / `low` / `close` | double | Implied probability in `[0, 1]`. |
| `vwap` | double | Volume-weighted average price. |
| `volume_usd` | double | Total USDC traded in the bar. |
| `n_trades` | int64 | Number of `OrderFilled` events in the bar. |
| `n_buys` / `n_sells` | int64 | Taker-side direction counts. |
## Quick start in R
### Setup
```r
install.packages(c("arrow", "dplyr", "jsonlite", "lubridate", "slider",
"TTR", "PerformanceAnalytics", "glmnet"))
library(arrow)
library(dplyr)
library(slider)
```
### Build a per-token feature frame
```r
markets <- open_dataset("polymarket/markets/")
bars <- open_dataset("polymarket/bars_hourly/")
# Pick a large market and grab its YES token id.
m <- markets %>% filter(volume > 1e6) %>% head(1) %>% collect()
yes_token_id <- jsonlite::fromJSON(m$clob_token_ids)[1]
ts <- bars %>%
filter(token_id == yes_token_id) %>%
collect() %>%
arrange(period_start) %>%
mutate(
sma_24h = slide_dbl(close, mean, .before = 24, .complete = TRUE),
ema_24h = TTR::EMA(close, n = 24),
ret_1h = log(close / lag(close)),
rsi_14 = TTR::RSI(close, n = 14),
boll = TTR::BBands(close, n = 20, sd = 2)[, "pctB"],
days_to_resolution = as.numeric(difftime(m$end_date, period_start, units = "days"))
)
```
### Walk-forward elastic net + back-test
```r
library(glmnet)
library(PerformanceAnalytics)
fit <- cv.glmnet(X_train, y_train, alpha = 0.5)
signal <- predict(fit, newx = X_test, s = "lambda.min")
# 1% per-trade cost, threshold-based position.
pos <- sign(signal) * (abs(signal) > threshold)
ret <- pos * y_test - 0.01 * abs(diff(c(0, pos)))
charts.PerformanceSummary(ret)
```
## Streaming via the HuggingFace `datasets` library
```python
from datasets import load_dataset
markets = load_dataset("smf-ulm/polymarket-quant-bench", "markets", split="train")
bars_hourly = load_dataset("smf-ulm/polymarket-quant-bench", "bars_hourly", split="train", streaming=True)
bars_daily = load_dataset("smf-ulm/polymarket-quant-bench", "bars_daily", split="train")
```
## License
[CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/). Please cite
both this release and Jon Becker's upstream repository.
## Citation
```bibtex
@misc{polymarket_quant_bench_2026,
author = {Padmaperuma, Oliver},
title = {Polymarket Quant Bench: OHLCV bars for high-liquidity resolved markets},
year = {2026},
howpublished = {HuggingFace dataset, smf-ulm/polymarket-quant-bench},
note = {Derived from Jon Becker's polymarket-data release at
\url{https://github.com/jbecker19/polymarket-data}}
}
```