--- license: mit task_categories: - other tags: - polymarket - prediction-market - crypto - bitcoin - ethereum - solana - trades - orderbook - time-series - on-chain - polygon size_categories: - 100M **v2 era (post 2026-04-28 11:05 UTC):** the v1 CTF Exchange > (`0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E`) was replaced by the > v2 CTF Exchange (`0xE111180000d2663C0091e4f400237545B87B996B`) with > a redesigned `OrderFilled` event. This repo covers the v1 era only. > A separate dataset covers the v2 era. ## TL;DR | | btc/5m | btc/15m | |---|---:|---:| | **Date range (UTC)** | 2026-03-01 00:00 → 2026-04-28 11:00 | 2026-03-01 00:00 → 2026-04-28 11:00 | | **Days covered** | 58.5 | 58.5 | | **Windows in range** | 16,838 | 5,613 | | **Windows in this dataset** | 16,837 (99.99%) | 5,613 (100%) | | **On-chain fills** | 201,539,008 | 49,996,949 | | **Total compressed size** | 119.6 GB (uncompressed ~7.5x) | 30.0 GB (uncompressed ~7.5x) | | **Gzipped per window (5m median)** | ~7.2 MB | ~5.5 MB | | **Windows with `priceToBeat`** | 26,612 / 27,068 (98.3%) | 8,879 / 9,025 (98.4%) | | **Windows with `finalPrice`** | 20,717 / 27,068 (76.5%) | 6,911 / 9,025 (76.6%) | | **Integrity (1000-window spot check)** | 1000/1000 OK | 1000/1000 OK | ETH and SOL series are also in this dataset (same schema, same shape, same v1 era). Only BTC numbers are shown above; see the *Coverage matrix* section below for the full picture. ## What is in this dataset Every `OrderFilled` event emitted on the v1 Polymarket CTF Exchange (`0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E`) and the v1 NegRisk adapter (`0xC5d563A36AE78145C45a50134d48A1215220f80a`) for the listed markets, sliced into 5-minute and 15-minute windows aligned to UTC boundaries. The markets are the **Crypto Up/Down** binary outcome markets on Polymarket that resolve based on the Chainlink BTC/USD (or ETH/USD, SOL/USD) data stream. Each window has two tokens (Up and Down) that pay $1 if the asset's price at the window close is >= its price at the window open, and $0 otherwise. For every window we ship: - Every `OrderFilled` event (raw, no projection, no normalization) for both the Up token and the Down token. - The full Gamma API market metadata (tokenIds, conditionId, volume, liquidity, fees, description, tags, series). - The `eventMetadata` block from Gamma (when present) including the `priceToBeat` (Chainlink price at window open) and `finalPrice` (Chainlink price at window close). ## Directory structure ``` data/ raw/ trades/ / # btc, eth, sol / # 5m, 15m _manifest.json # series-level manifest (one per asset/timeframe) _index/ # cross-series index (in repo) / # UTC day folder / # UTC time folder = window start fills.jsonl.gz # one gzipped JSONL file per window # (NO .sha256 sidecar; integrity is # re-checked by hf_hub_download etag) _index/ trades_by_window.jsonl # one row per window across all series metadata/ //... # same layout, but holds metadata.json coverage.json # series-level coverage summary ``` The `//` path encoding matches the UTC window start exactly. For example, the 5m window that started at `2026-03-05 00:00:00 UTC` lives at: `data/raw/trades/btc/5m/05-03-2026/00-00-00-UTC/fills.jsonl.gz` with the slug `btc-updown-5m-1772668800` and window `[1772668800, 1772669100)`. ## Per-row schema (v1 OrderFilled) Each line in `fills.jsonl.gz` is one raw `OrderFilled` event from the v1 Goldsky subgraph, with all 11 schema fields preserved (no projection, no normalization). See [Goldsky v1 schema docs](https://github.com/Polymarket/polymarket-subgraph) for the canonical field definitions. | Field | Type | Description | |---|---|---| | `id` | string | Composite `_` (unique per order match) | | `timestamp` | string | Unix seconds (when the match was mined) | | `transactionHash` | string | Polygon tx hash | | `orderHash` | string | EIP-712 order hash | | `maker` | string | Lowercase 0x address | | `taker` | string | Lowercase 0x address (often the CTF Exchange contract) | | `makerAssetId` | string | Decimal string; "0" = USDC, else CTF tokenId | | `takerAssetId` | string | Decimal string; "0" = USDC, else CTF tokenId | | `makerAmountFilled` | string | BigInt, 6-decimal units (USDC or shares) | | `takerAmountFilled` | string | BigInt, 6-decimal units (USDC or shares) | | `fee` | string | BigInt, 6-decimal USDC, paid by maker (v1 model) | All integers are encoded as **decimal strings** because Goldsky's GraphQL endpoint returns them as strings (some exceed JS 2^53). USDC amounts use **6 decimals**. CTF token amounts also use 6 decimals (1 share = 1_000_000 raw units). **Side interpretation:** a fill is a BUY for `maker` if `makerAssetId == "0"` (maker paid USDC). A fill is a SELL for `maker` if `takerAssetId == "0"` (maker paid shares, received USDC). The v1 event does not carry an explicit `side` field; it must be derived from the assetId pair. **Fee semantics (v1):** the `fee` is paid by the **maker**, denominated in USDC, max 1000 bps (10%). ## Slug convention `{asset}-updown-{timeframe}-{window_start_epoch}` where `window_start = (unix_ts // duration_seconds) * duration_seconds`. The window is `[T, T+duration)` and the slug encodes the start, not the close. | Timeframe | `duration_seconds` | Example slug | Window | |---|---|---|---| | `5m` | `300` | `btc-updown-5m-1772668800` | `[1772668800, 1772669100)` | | `15m` | `900` | `btc-updown-15m-1772668800` | `[1772668800, 1772669700)` | To look up a market that closed at UTC time `T`: `window_start = ((T - 1) // duration_seconds) * duration_seconds`. ## Coverage matrix Status codes: - **fetched** — `fills.jsonl.gz` exists and passed all sanity checks (timestamps in window, assetIds match expected tokens, JSONL parses, gzip decompresses, no duplicates by `id`). - **no_trades** — window is within range, metadata is on disk, but the v1 subgraph returned 0 fills for this window. The 5m/15m window is real but the order book had no activity on-chain during it. - **missing_metadata** — window is within range but the Gamma API returned no event (market was created and removed without a slug being recorded). Trades cannot be attributed to a conditionId. - **skipped** — window is outside the requested date range or was explicitly excluded. | Asset | TF | Fetched | No trades | Missing metadata | Skipped | Total | |---|---|---:|---:|---:|---:|---:| | btc | 5m | 16,579 | 28 | 4 | 226 | 16,837 | | btc | 15m | 5,585 | 7 | 0 | 21 | 5,613 | ETH and SOL series are also in this dataset (same schema, same shape, same v1 era). The exact counts for those series are in `data/raw/metadata/coverage.json` and the per-series `_manifest.json` files. The 4 `missing_metadata` 5m windows are: `1776254700`, `1776255000`, `1776380100`, `1776382500` (all on 2026-04-15 / 2026-04-16). These windows have no corresponding event in the Gamma API — they were either created and removed without a slug being recorded, or the slug/conditionId was rotated. ## Known data quirks **1. May 22, 2026 resolution outage (no impact on v1 trades).** On 2026-05-22, 452 markets (across all assets and timeframes) had their `eventMetadata` block empty in the Gamma API response. The `closed` flag is set to `true` for these markets, but neither `priceToBeat` nor `finalPrice` was ever recorded. This appears to be a server-side resolution outage. The actual on-chain resolution for these markets is recoverable from the trade data itself (the maker/taker/amounts encode it) and from re-fetching the CLOB `/markets/{condition_id}` endpoint (which still returns the resolved `outcome` and `winner` flag for the `tokens[]`). This is the source of the ~23% of metadata files without `eventMetadata`. **2. V1 era cutover (2026-04-28 ~11:05 UTC).** The v1 CTF Exchange emitted its last `OrderFilled` events on block 84,902,352. The v2 CTF Exchange at `0xE111180000d2663C0091e4f400237545B87B996B` started emitting `OrderFilled` events on block 84,902,353 (and the event signature changed — see v2 era dataset). This dataset ends at the v1 cutover. A small number of `fills.jsonl.gz` files in the last 1-2 hours of the v1 era may be empty (no v1 fills) because those windows were already on the v2 contract. **3. `finalPrice` populated ~7 min after window close (live-verified).** Polymarket does **not** populate `eventMetadata.priceToBeat` at window start. Both fields are written after the window closes, but `priceToBeat` is written first (≈ +2 min after close) and `finalPrice` follows ≈ 5 min later (≈ +7 min after close). The intermediate state `closed=true, em={priceToBeat only}, no finalPrice` is real and observable. If your downstream task needs `finalPrice`, wait at least 10 min after window close before reading. The `outcomePrices` field reaches the resolution value `[1, 0]` or `[0, 1]` at the +2 min mark, so the binary Up/Down label is available much earlier. **4. `fee` is sometimes 0.** A non-trivial fraction of v1 fills (especially in the early March 2026 data) have `fee = "0"`. This is real on-chain data — not a collector bug. The fee model in v1 was sometimes waived for certain order types or for market makers below a threshold. **5. No cancellation events.** This dataset captures only `OrderFilled` events, not `OrderCancelled` or `OrderCreated` events. The historical order book state is not recoverable from this dataset alone. For order book state, see the v2 live WS feed. ## Loading ```python import gzip, json, os from huggingface_hub import snapshot_download path = snapshot_download( repo_id="krish301/polymarket-crypto-trades-v1", repo_type="dataset", ) # Iterate all windows trades_root = os.path.join(path, "data", "raw", "trades") for root, _, files in os.walk(trades_root): for f in files: if f == "fills.jsonl.gz": fp = os.path.join(root, f) with gzip.open(fp, "rt") as gz: for line in gz: fill = json.loads(line) # fill["id"], fill["timestamp"], fill["maker"], ... # assetId: "0" = USDC, else CTF tokenId # amounts: BigInt as decimal string, 6 decimals # Or jump straight to a specific window slug = "btc-updown-5m-1772668800" # 5m slug -> "05-03-2026/00-00-00-UTC" date, time = "05-03-2026", "00-00-00-UTC" fp = os.path.join(trades_root, "btc", "5m", date, time, "fills.jsonl.gz") ``` ## Integrity guarantees Every `fills.jsonl.gz` file in this dataset has been verified to: 1. **Decompress** as a valid gzip stream. 2. **Parse** as JSONL with the 11 fields above. 3. **Contain fills only for that window's two tokenIds** (the Up and Down tokens from the window's `metadata.json`). 4. **Have all timestamps within `[window_start, window_start + duration)`**. 5. **Have unique `id` values** (no duplicate fills). 6. **Have non-empty maker/taker/amount fields** for every row. The 1000-window spot check on the latest release of this dataset (2026-06-05) returned **1000/1000 OK, 0 SHA mismatches, 0 corrupt, 0 token mismatches, 0 out-of-window timestamps, 0 missing metadata, 0 empty** for both btc/5m and btc/15m. Per-window SHA256 sidecars are computed on the local file system (see `data/raw/trades////fills.jsonl.gz.sha256`) but are **not** shipped to HF — integrity is re-verifiable from the file etags after re-download. ## Provenance Pulled from the public Goldsky v1 GraphQL endpoint: `https://api.goldsky.com/api/public/project_cl6mb8i9h0003e201j6li0diw/subgraphs/orderbook-subgraph/0.0.1/gn` For each window, two paginated queries (taker-side + maker-side) are merged and deduped by `id`. Skip-pagination only (sticky-cursor `id_gt` is broken on this endpoint — the `id` is a composite string that the cursor doesn't compare correctly). Market metadata was pulled from the Gamma API: `https://gamma-api.polymarket.com/events?slug={slug}` For the v2 era (post 2026-04-28 11:05 UTC), see the polymarket-crypto-trades-v2 dataset, which uses `eth_getLogs` against the V2 CTF Exchange contract on Polygon via Goldsky Edge RPC. ## Generation Generated by: - `polymarket_bot.data_collection.collect_metadata` (Gamma → metadata) - `polymarket_bot.data_collection.collect_trades_v1` (Goldsky → fills) - `polymarket_bot.data_collection.upload_trades_to_hf` (HF upload) - `polymarket_bot.data_collection.integrity_check` (sanity checks) Schema, endpoint, and pagination quirks are documented in `polymarket_bot.data_collection.goldsky_v1.py`.