Skip to content

The Data Scientist

Core ECE under administrative vs. winner-crossing clocks for changing vs. fixed market universes

How to Analyze Polymarket Data & Order Books Without Look-Ahead Bias (766M-Trade Pipeline)

THE DATA SCIENTIST // ZERO-LEAKAGE DATA ENGINEERING LAB PIPELINE: SII_POLYMARKET_766M → 1,401,619 ASOF SNAPSHOTS

How to Analyze Polymarket Data & Order Books Without Look-Ahead Bias (766M-Trade Pipeline)

A reproducible data-engineering specification for ingesting Polymarket API and on-chain Polygon trade tapes, executing backward ASOF joins, re-anchoring information clocks, and training leakage-safe Polymarket AI models.

AUTHORS: Dr Stylianos Kampakis (The Data Scientist & Tesseract Academy), Jiaqi Sun (UCL CS), Nikan Firoozye (UCL CS)
RAW POLYGON TAPE
766,412,707 TXS
1,019,069 metadata rows (2022-11-21..2026-05-04)
CLEAN FROZEN PANEL
N = 491,202
1,401,619 ASOF snapshots (2022-11-21..2026-04-30)
48H FRESHNESS CONTROL
86% SURVIVAL
Q1-Q4 ECE spread: 2.33 pp → 2.01 pp
2026 TEMPORAL HOLDOUT
N = 228,809
Market 0.9563 AUC vs LightGBM 0.9554 AUC

With Polymarket API queries and open on-chain Polygon datasets growing rapidly, thousands of data scientists and ML engineers are building Polymarket AI forecasting models. In our primary research study, Testing Market Efficiency on 766 Million Polymarket Trades: Backward-Join Data Engineering, LightGBM Benchmarks & L2/L3 Order-Book Tear Sheets, we audited 766,412,707 on-chain transactions (Hugging Face SII Polymarket Dataset) and 1,233 historical Level-2/Level-3 order books (Telonex Export, exported 26 June 2026). Here is the five-step engineering protocol to eliminate look-ahead leakage.

01 // Step 1: Freezing the Clean Market Universe (766.4M Trades → 491,202 Markets)

When querying the Polymarket API or loading the Hugging Face SII Polymarket Dataset (1,019,069 market metadata records and 766,412,707 on-chain OrderFilled trades from 21 November 2022 to 4 May 2026), freeze your universe before running any statistical or ML tests. A market enters the frozen research universe (N = 491,202, created 21 Nov 2022 – 30 Apr 2026) if and only if it: (1) is a standard event market (excluding automated Up/Down tick series), (2) resolves cleanly (terminal settlement price ≥ 0.95 for one outcome), (3) records positive traded volume, and (4) has consistent creation/close/resolution timestamps.

Daily live-market counts on Polymarket from metadata records on a logarithmic scale
[FIG_01] Daily live-market counts on Polymarket (log scale, ~27/day in 2020 to >41,000/day in 2026; ~96% of all markets in our sample were created in 2025–2026).

02 // Step 2: Backward ASOF Joins & The 48-Hour Quote Freshness Filter

Never filter historical snapshots by terminal lifetime volume (volume_total) or forward-interpolated prices. For cutoff t_{m,h} = t_{c,m} - h across seven horizons (T-30d, T-14d, T-7d, T-72h, T-24h, T-6h, T-1h), execute a strict backward ASOF JOIN:

pipeline/asof_snapshot_builder.sql DuckDB SQL // 1,401,619 Point-in-Time Snapshots
SELECT
    g.market_id, g.horizon_label, g.y,
    last_tx.price AS p_mh,
    EXTRACT(EPOCH FROM (g.cutoff_ts - last_tx.trade_ts)) / 3600.0 AS staleness_hours,
    (EXTRACT(EPOCH FROM (g.cutoff_ts - last_tx.trade_ts)) <= 48 * 3600) AS is_fresh_48h,
    SUM(pit_tx.usd_notional) AS V_mh -- Strictly known-at-time volume (tau <= cutoff_ts)
FROM horizon_grid g
ASOF JOIN sii_order_filled_trades last_tx
  ON g.market_id = last_tx.market_id AND last_tx.trade_ts <= g.cutoff_ts
LEFT JOIN sii_order_filled_trades pit_tx
  ON g.market_id = pit_tx.market_id  AND pit_tx.trade_ts  <= g.cutoff_ts
GROUP BY ALL;

At T-7d, Expected Calibration Error (ECE) in the lowest pre-cutoff volume quartile exceeds >3.0 pp, compared to <1.0 pp in the highest-volume quartile. Filtering strictly for fresh quotes (s_{m,h} ≤ 48h) narrows the bottom-minus-top quartile spread only from 2.33 pp to 2.01 pp (86% survival).

Expected Calibration Error by pre-cutoff volume quartile across observation horizons
[FIG_02] Expected Calibration Error (ECE) by pre-cutoff volume quartile across observation horizons.

03 // Step 3: Murphy (1973) Brier Decomposition & Re-Anchoring Information Clocks

Across all horizons, Polymarket achieves an aggregate Brier Skill Score (BSS = 1 - BS / BS_base) between 0.54 and 0.73. At T-24h, BSS rises from 0.28 (≤2d, N=129,582) and 0.50 (2–7d, N=142,819) to 0.69 (7–30d, N=110,424) and 0.91 (>30d, N=46,359).

Brier score decomposition into reliability and resolution components at T-24h grouped by market duration
[FIG_03] Murphy (1973) Brier score decomposition into reliability and resolution at T-24h by market duration.

Because official close timestamps (endDate) often lag real-world event resolution, re-anchoring a fixed panel of N = 20,725 markets to outcome-independent clocks eliminates the illusion of smooth deadline learning:

[TABLE_01] Core ECE (pp) on Fixed Sub-Universe (N = 20,725) Under Alternative Clocks
Measurement Clock (N = 20,725 Fixed Panel) T-30d Core ECE T-7d Core ECE T-1h Core ECE Empirical Trajectory
Administrative End Date (t_{c,m}) 1.11 pp 0.88 pp 0.39 pp Apparent monotonic improvement (settlement lag)
Winner-Crossing Clock (p ≥ 0.80) 2.40 pp 2.55 pp 2.87 pp Flat / slight reversal
Band-Exit Clock (exits [0.30, 0.70]) 2.45 pp 2.51 pp 2.82 pp Outcome-independent; flat trajectory
Last-Material-Move Clock (>15 pp jump) 3.02 pp 3.84 pp 5.20 pp Outcome-independent; substantial reversal
Core ECE under administrative vs. winner-crossing clocks for changing vs. fixed market universes
[FIG_04] Core ECE under administrative countdowns vs. event-anchored clocks (N = 20,725).

04 // Step 4: Count Weighting vs. Pre-Cutoff Volume Weighting

Δb,vol = [ Σm ∈ b Vm,h (ym − pm,h) ] / [ Σm ∈ b Vm,h ]

At T-7d, count-weighted calibration in [0.90, 0.95] favourites is -12.3 pp (95% CI: [-14.6, -10.2] pp), driven by thin sports markets ($37 median pre-cutoff volume, -6.90 pp gap). Under volume weighting Δ_{b,vol}, [0.90, 0.95] flips to +6.3 pp (while [0.80, 0.90] flips from -6.6 pp to +9.0 pp, [0.70, 0.80] from -3.4 pp to +2.8 pp, [0.05, 0.10] narrows from +3.4 pp to +1.1 pp, and ≥0.95 moves from -1.3 pp to +0.2 pp).

05 // Step 5: Benchmarking “Polymarket AI” Models on Temporal Holdouts (N = 228,809)

Enforcing a strict temporal split (training LightGBM on pre-1 January 2026 observations with fixed seed 42 and testing on N = 228,809 holdout observations in 2026), the raw market price (0.9563 AUC, 0.07710 Brier Score, 0.72 pp ECE) outperforms LightGBM (0.9554 AUC, 0.07784 Brier Score, 0.59 pp ECE).

Out-of-sample predictive benchmark on 228,809 temporal holdout observations in 2026
[FIG_05] Out-of-sample predictive benchmark on 228,809 temporal holdout observations (2026).

When backtesting execution on the 2025–2026 holdout, equal-stake proxy returns (+25.0% fade-favourite, +20.6% back-longshot) collapse to -50.7% and -25.5% under liquidity weighting. Across 1,233 historical Level-2/Level-3 order books (Telonex Export, 26 June 2026) net of half-spreads and Polymarket’s 2% fee assumption, all tested taker strategies lost -14.6% to -53.4% out-of-sample (Thin-Book Favourite lost -50.2% at 25-level depth, N=30, and -53.4% at full depth, N=32, after +100% in-sample; Order-Book Imbalance lost -19.3%, N=209, and -14.6%, N=203; Wide-Spread Reversal lost -19.7%, N=146, and -16.1%, N=140), while our hypothetical passive market-making sensitivity model turns negative above a $15/market cap (+11.93% at $10, +1.27% at $15, -4.94% at $20, -24.43% at $100).

06 // Technical FAQ: Analyzing Polymarket API & On-Chain Data

1. What is the best dataset for historical Polymarket data and order-book research?

For venue-wide calibration and machine learning, our study uses the Hugging Face SII Polymarket Dataset (766,412,707 reconstructed on-chain OrderFilled transactions and 1,019,069 market metadata records from 21 November 2022 to 4 May 2026, filtered to N = 491,202 cleanly resolved standard markets created 21 Nov 2022 – 30 Apr 2026). For realistic execution backtesting, we pair this with the Telonex Export (1,233 markets with historical Level-2/Level-3 order-book snapshots, exported 26 June 2026).

2. How do you avoid look-ahead bias in Polymarket API time series?

Never use terminal market volume (volume_total) or forward-interpolated prices when constructing historical features. Use a strict backward as-of join (τ ≤ t_{c,m} - h) for both snapshot prices p_{m,h} and cumulative pre-cutoff volume V_{m,h}, and enforce a temporal train/test split (pre-2026 training vs. 2026 out-of-sample holdout).

3. Why do administrative close timestamps distort Polymarket price discovery studies?

Official market close timestamps (endDate) frequently occur hours or days after the real-world event has already been decided. On a fixed panel of 20,725 markets, core Expected Calibration Error drops from 1.11 pp at T-30d to 0.39 pp at T-1h under the administrative clock, but remains flat (2.45 pp to 2.82 pp) under the outcome-independent Band-Exit Clock ([0.30, 0.70]) and reverses (3.02 pp to 5.20 pp) under the Last-Material-Move Clock (>15 pp).

4. Can a LightGBM model trained on Polymarket data beat the market price?

On our 228,809-observation temporal holdout in 2026, a leakage-safe LightGBM model achieved 0.9554 ROC-AUC and 0.07784 Brier Score, trailing the raw contemporaneous market price (0.9563 ROC-AUC, 0.07710 Brier Score).

Free Starter Kit • Beyond Machine

The AI-Augmented Data Analyst Starter Kit (2026 Edition)

Master modern AI workflows, automated EDA, SQL querying, and executive decision briefs.