SII-WANGZJ commited on
Commit
a3564f3
·
1 Parent(s): a28eee3

Delete README.md

Browse files
Files changed (1) hide show
  1. README.md +0 -483
README.md DELETED
@@ -1,483 +0,0 @@
1
- <div align="center">
2
-
3
- <h1>Polymarket Data</h1>
4
-
5
- <h3>Complete Data Infrastructure for Polymarket — Fetch, Process, Analyze</h3>
6
-
7
- <p style="max-width: 750px; margin: 0 auto;">
8
- A comprehensive dataset of 1.1 billion trading records from Polymarket, processed into multiple analysis-ready formats. Features cleaned data, unified token perspectives, and user-level transformations — ready for market research, behavioral studies, and quantitative analysis.
9
- </p>
10
-
11
- <p>
12
- <b>Zhengjie Wang</b><sup>1,2</sup>, <b>Leiyu Chao</b><sup>1,3</sup>, <b>Yu Bao</b><sup>1,4</sup>, <b>Lian Cheng</b><sup>1,3</sup>, <b>Jianhan Liao</b><sup>1,5</sup>, <b>Yikang Li</b><sup>1,†</sup>
13
- </p>
14
-
15
- <p>
16
- <sup>1</sup>Shanghai Innovation Institute &nbsp;&nbsp; <sup>2</sup>Westlake University &nbsp;&nbsp; <sup>3</sup>Shanghai Jiao Tong University
17
- <br>
18
- <sup>4</sup>Harbin Institute of Technology &nbsp;&nbsp; <sup>5</sup>Fudan University
19
- </p>
20
-
21
- <p>
22
- <sup>†</sup>Corresponding author
23
- </p>
24
-
25
- </div>
26
-
27
- <p align="center">
28
- <a href="https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data">
29
- <img src="https://img.shields.io/badge/Hugging%20Face-Dataset-yellow.svg" alt="HuggingFace Dataset"/>
30
- </a>
31
- <a href="https://github.com/SII-WANGZJ/Polymarket_data">
32
- <img src="https://img.shields.io/badge/GitHub-Code-black.svg?logo=github" alt="GitHub Repository"/>
33
- </a>
34
- <a href="https://github.com/SII-WANGZJ/Polymarket_data/blob/main/LICENSE">
35
- <img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License"/>
36
- </a>
37
- <a href="#data-quality">
38
- <img src="https://img.shields.io/badge/Data-Verified-green.svg" alt="Data Quality"/>
39
- </a>
40
- </p>
41
-
42
- ---
43
-
44
- ## TL;DR
45
-
46
- We provide **163GB of historical on-chain trading data** from Polymarket, containing **1.9 billion records** across 538K+ markets. The dataset is directly fetched from Polygon blockchain, fully verified, and ready for analysis. Perfect for market research, behavioral studies, data science projects, and academic research.
47
-
48
- ## Highlights
49
-
50
- - **Complete Blockchain History**: All OrderFilled events from Polymarket's two exchange contracts, with no missing blocks or gaps. Every single trade from the platform's inception is included.
51
-
52
- - **Multiple Analysis Perspectives**: 5 structured datasets at different abstraction levels — raw blockchain events, processed trades with market linkage, market metadata, and derived quantitative views — serving diverse research needs.
53
-
54
- - **Production Ready**: Clean, validated data with proper schema documentation. All trades are verified against blockchain RPC, with market metadata linked and ready to use.
55
-
56
- - **Open Source Pipeline**: Fully reproducible data collection process. Our open-source tools allow you to verify, update, or extend the dataset independently.
57
-
58
- ## Dataset Overview
59
-
60
- | File | Size | Records | Description |
61
- |------|------|---------|-------------|
62
- | `trades.parquet` | 28GB | 418.3M | **Recommended.** Processed trades with market metadata linkage |
63
- | `orderfilled.parquet` | 84GB | 689.0M | Raw blockchain events from OrderFilled logs |
64
- | `markets.parquet` | 85MB | 538,587 | Market information and metadata |
65
- | `quant.parquet` | 28GB | 418.2M | Derived: unified YES perspective (for quant research) |
66
- | `users.parquet` | 23GB | 340.6M | Derived: user-level split by maker/taker (for quant research) |
67
-
68
- **Total**: 163GB, 1.9 billion records
69
-
70
- ## Use Cases
71
-
72
- ### Market Research & Analysis
73
- - Study prediction market dynamics and price discovery mechanisms
74
- - Analyze market efficiency and information aggregation
75
- - Research crowd wisdom and forecasting accuracy
76
-
77
- ### Behavioral Studies
78
- - Track individual user trading patterns and decision-making
79
- - Study market participant behavior under different conditions
80
- - Analyze risk preferences and trading strategies
81
-
82
- ### Data Science & Machine Learning
83
- - Train models for price prediction and market forecasting
84
- - Feature engineering for time-series analysis
85
- - Develop algorithms for market analysis
86
-
87
- ### Academic Research
88
- - Economics and finance research on prediction markets
89
- - Social science studies on collective intelligence
90
- - Computer science research on blockchain data analysis
91
-
92
- ## Quick Start
93
-
94
- ### Installation
95
-
96
- ```bash
97
- # Using pip
98
- pip install pandas pyarrow
99
-
100
- # Optional: for faster parquet reading
101
- pip install fastparquet
102
- ```
103
-
104
- ### Load Data with Pandas
105
-
106
- ```python
107
- import pandas as pd
108
-
109
- # Load trades (recommended for most users)
110
- df = pd.read_parquet('trades.parquet')
111
- print(f"Total trades: {len(df):,}")
112
-
113
- # Load market metadata
114
- markets = pd.read_parquet('markets.parquet')
115
- print(f"Total markets: {len(markets):,}")
116
- ```
117
-
118
- ### Load from HuggingFace Datasets
119
-
120
- ```python
121
- from datasets import load_dataset
122
-
123
- # Load trades
124
- dataset = load_dataset(
125
- "SII-WANGZJ/Polymarket_data",
126
- data_files="trades.parquet"
127
- )
128
-
129
- # Load multiple files
130
- dataset = load_dataset(
131
- "SII-WANGZJ/Polymarket_data",
132
- data_files=["trades.parquet", "markets.parquet"]
133
- )
134
- ```
135
-
136
- ### Download Specific Files
137
-
138
- ```bash
139
- # Download using HuggingFace CLI
140
- pip install huggingface_hub
141
-
142
- # Download a specific file
143
- hf download SII-WANGZJ/Polymarket_data quant.parquet --repo-type dataset
144
-
145
- # Download all files
146
- hf download SII-WANGZJ/Polymarket_data --repo-type dataset
147
- ```
148
-
149
- ## File Selection Guide
150
-
151
- > **We recommend `trades.parquet` as the primary dataset for most use cases.** It preserves all original trade semantics with market metadata linked, requiring no assumptions about token normalization.
152
-
153
- `quant.parquet` and `users.parquet` are derived datasets designed for our internal quantitative research. They apply specific transformations — normalizing all trades to the YES (token1) perspective — which may not be suitable for every analysis scenario. Detailed transformation logic is documented below.
154
-
155
- ## Data Structure
156
-
157
- ### trades.parquet - Processed Trades (Recommended)
158
-
159
- Complete trade records with market metadata linkage. Preserves all original blockchain semantics — no normalization or filtering applied.
160
-
161
- **Best for:** General-purpose analysis, custom research, building your own pipelines.
162
-
163
- **Schema:**
164
- | Column | Type | Description |
165
- |--------|------|-------------|
166
- | `timestamp` | uint64 | Unix timestamp (seconds) |
167
- | `block_number` | uint64 | Polygon block number |
168
- | `transaction_hash` | string | Blockchain transaction hash |
169
- | `log_index` | uint32 | Log index within the transaction |
170
- | `contract` | string | Exchange contract address |
171
- | `market_id` | string | Polymarket market identifier |
172
- | `condition_id` | string | CTF condition ID |
173
- | `event_id` | string | Event group identifier |
174
- | `maker` | string | Maker wallet address |
175
- | `taker` | string | Taker wallet address |
176
- | `price` | float64 | Trade price (0–1) |
177
- | `usd_amount` | float64 | USD (USDC) value of the trade |
178
- | `token_amount` | float64 | Number of outcome tokens traded |
179
- | `maker_direction` | string | Maker's direction: `BUY` or `SELL` |
180
- | `taker_direction` | string | Taker's direction: `BUY` or `SELL` |
181
- | `nonusdc_side` | string | Which outcome token was traded: `token1` (YES) or `token2` (NO) |
182
- | `asset_id` | string | The non-USDC token's asset ID |
183
-
184
- ### orderfilled.parquet - Raw Blockchain Events
185
-
186
- Unprocessed `OrderFilled` events directly from Polygon blockchain logs. No decoding, no market linkage — pure on-chain data.
187
-
188
- **Best for:** Blockchain research, data verification, building custom processing pipelines from scratch.
189
-
190
- **Schema:**
191
- | Column | Type | Description |
192
- |--------|------|-------------|
193
- | `timestamp` | uint64 | Unix timestamp (seconds) |
194
- | `block_number` | uint64 | Polygon block number |
195
- | `transaction_hash` | string | Blockchain transaction hash |
196
- | `log_index` | uint32 | Log index within the transaction |
197
- | `contract` | string | Exchange contract address |
198
- | `order_hash` | string | Unique order hash |
199
- | `maker` | string | Maker wallet address |
200
- | `taker` | string | Taker wallet address |
201
- | `maker_asset_id` | string | Asset ID of maker's token |
202
- | `taker_asset_id` | string | Asset ID of taker's token |
203
- | `maker_amount_filled` | string | Amount filled for maker (wei, uint256 as string) |
204
- | `taker_amount_filled` | string | Amount filled for taker (wei, uint256 as string) |
205
- | `maker_fee` | string | Maker fee (wei, uint256 as string) |
206
- | `taker_fee` | string | Taker fee (wei, uint256 as string) |
207
- | `protocol_fee` | string | Protocol fee (wei, uint256 as string) |
208
-
209
- > Note: Amount and fee fields are stored as strings because they are uint256 values from the blockchain that exceed standard integer range.
210
-
211
- ### markets.parquet - Market Metadata
212
-
213
- Market information, outcome token details, and event grouping.
214
-
215
- **Best for:** Linking trades to market context, filtering by market attributes, understanding market outcomes.
216
-
217
- **Schema:**
218
- | Column | Type | Description |
219
- |--------|------|-------------|
220
- | `id` | string | Market identifier (join key with `market_id` in other tables) |
221
- | `question` | string | Market question text |
222
- | `slug` | string | URL slug |
223
- | `condition_id` | string | CTF condition ID |
224
- | `token1` | string | Asset ID of outcome token 1 (YES) |
225
- | `token2` | string | Asset ID of outcome token 2 (NO) |
226
- | `answer1` | string | Label for token1 outcome (e.g., "Yes") |
227
- | `answer2` | string | Label for token2 outcome (e.g., "No") |
228
- | `closed` | uint8 | 0 = active, 1 = settled |
229
- | `active` | uint8 | Whether the market is currently active |
230
- | `archived` | uint8 | Whether the market is archived |
231
- | `outcome_prices` | string | JSON array of final prices, e.g. `["0.99", "0.01"]` means answer1 won |
232
- | `volume` | float64 | Total traded volume (USD) |
233
- | `event_id` | string | Parent event identifier |
234
- | `event_slug` | string | Parent event URL slug |
235
- | `event_title` | string | Parent event title |
236
- | `created_at` | datetime | Market creation time |
237
- | `end_date` | datetime | Market end / resolution time |
238
- | `updated_at` | datetime | Last metadata update time |
239
-
240
- ### quant.parquet - Unified YES Perspective (For Quantitative Research)
241
-
242
- > **Note:** This is a derived dataset built for our own quantitative research. It normalizes all trades to the YES (token1) perspective: for trades originally on token2 (NO), the price is converted to `1 - price`, and the buy/sell direction is flipped. Contract-address trades are filtered out, keeping only real user trades. **If you need the original trade semantics, use `trades.parquet` instead.**
243
-
244
- **Schema:**
245
- | Column | Type | Description |
246
- |--------|------|-------------|
247
- | `timestamp` | uint64 | Unix timestamp (seconds) |
248
- | `block_number` | uint64 | Polygon block number |
249
- | `transaction_hash` | string | Blockchain transaction hash |
250
- | `log_index` | uint32 | Log index within the transaction |
251
- | `market_id` | string | Market identifier |
252
- | `condition_id` | string | CTF condition ID |
253
- | `event_id` | string | Event group identifier |
254
- | `price` | float64 | YES token price (0–1). For original token2 trades: `1 - original_price` |
255
- | `usd_amount` | float64 | USD value |
256
- | `token_amount` | float64 | Token amount |
257
- | `side` | string | `BUY` or `SELL` (from YES token perspective). For original token2 trades: direction is flipped |
258
- | `maker` | string | Maker wallet address |
259
- | `taker` | string | Taker wallet address |
260
-
261
- ### users.parquet - User-Level Behavior Data (For Quantitative Research)
262
-
263
- > **Note:** This is a derived dataset built for our own research. Each trade is split into two records (one for maker, one for taker), with the same token1 normalization as `quant.parquet`. All records are converted to a unified BUY direction — negative `token_amount` indicates selling. **If you need the original trade semantics, use `trades.parquet` instead.**
264
-
265
- **Schema:**
266
- | Column | Type | Description |
267
- |--------|------|-------------|
268
- | `timestamp` | uint64 | Unix timestamp (seconds) |
269
- | `block_number` | uint64 | Polygon block number |
270
- | `transaction_hash` | string | Blockchain transaction hash |
271
- | `log_index` | uint32 | Log index within the transaction |
272
- | `market_id` | string | Market identifier |
273
- | `condition_id` | string | CTF condition ID |
274
- | `event_id` | string | Event group identifier |
275
- | `user` | string | User wallet address |
276
- | `role` | string | `maker` or `taker` |
277
- | `price` | float64 | YES token price (normalized, same as quant) |
278
- | `usd_amount` | float64 | USD value |
279
- | `token_amount` | float64 | Signed amount: positive = buy, negative = sell |
280
-
281
- ## Example Analysis
282
-
283
- ### 1. Calculate Market Statistics
284
-
285
- ```python
286
- import pandas as pd
287
-
288
- df = pd.read_parquet('trades.parquet')
289
-
290
- # Market-level statistics
291
- market_stats = df.groupby('market_id').agg({
292
- 'usd_amount': ['sum', 'mean'], # Total volume and average trade size
293
- 'price': ['mean', 'std', 'min', 'max'], # Price statistics
294
- 'transaction_hash': 'count' # Number of trades
295
- }).round(4)
296
-
297
- print(market_stats.head())
298
- ```
299
-
300
- ### 2. Track Price Evolution
301
-
302
- ```python
303
- import pandas as pd
304
- import matplotlib.pyplot as plt
305
-
306
- df = pd.read_parquet('trades.parquet')
307
- df['datetime'] = pd.to_datetime(df['timestamp'], unit='s')
308
-
309
- # Select a specific market
310
- market_id = 'your-market-id'
311
- market_data = df[df['market_id'] == market_id].sort_values('timestamp')
312
-
313
- # Plot price over time
314
- plt.figure(figsize=(12, 6))
315
- plt.plot(market_data['datetime'], market_data['price'])
316
- plt.title(f'Price Evolution - Market {market_id}')
317
- plt.xlabel('Date')
318
- plt.ylabel('Price')
319
- plt.show()
320
- ```
321
-
322
- ### 3. Market Volume Analysis
323
-
324
- ```python
325
- import pandas as pd
326
-
327
- df = pd.read_parquet('trades.parquet')
328
- markets = pd.read_parquet('markets.parquet')
329
-
330
- # Join with market metadata (markets uses 'id', trades uses 'market_id')
331
- df = df.merge(markets[['id', 'question']], left_on='market_id', right_on='id', how='left')
332
-
333
- # Top markets by volume
334
- top_markets = df.groupby(['market_id', 'question']).agg({
335
- 'usd_amount': 'sum'
336
- }).sort_values('usd_amount', ascending=False).head(20)
337
-
338
- print(top_markets)
339
- ```
340
-
341
- ### 4. Analyze by Token Side
342
-
343
- ```python
344
- import pandas as pd
345
-
346
- df = pd.read_parquet('trades.parquet')
347
-
348
- # Compare YES vs NO token trading activity
349
- side_stats = df.groupby('nonusdc_side').agg({
350
- 'usd_amount': ['sum', 'mean'],
351
- 'transaction_hash': 'count'
352
- })
353
- print(side_stats)
354
-
355
- # Filter for only YES token trades on a specific market
356
- market_id = 'your-market-id'
357
- yes_trades = df[(df['market_id'] == market_id) & (df['nonusdc_side'] == 'token1')]
358
- print(f"YES trades: {len(yes_trades):,}")
359
- ```
360
-
361
- ## Data Processing Pipeline
362
-
363
- ```
364
- Polygon Blockchain (RPC)
365
- ↓
366
- orderfilled.parquet (Raw events)
367
- ↓
368
- trades.parquet (+ Market linkage)
369
- ↓
370
- ├─→ quant.parquet (Trade-level, unified YES perspective)
371
- │ └─→ Filter contracts + Normalize tokens
372
- │
373
- └─→ users.parquet (User-level, split maker/taker)
374
- └─→ Split records + Unified BUY direction
375
- ```
376
-
377
- **Key Transformations:**
378
-
379
- 1. **quant.parquet**:
380
- - Filter out contract trades (keep only user trades)
381
- - Normalize all trades to YES token perspective
382
- - Preserve maker/taker information
383
- - Result: 418.2M records (from 418.3M trades)
384
-
385
- 2. **users.parquet**:
386
- - Split each trade into 2 records (maker + taker)
387
- - Convert all to BUY direction (signed amounts)
388
- - Sort by user for easy querying
389
- - Result: 340.6M records
390
-
391
- ## Documentation
392
-
393
- - **[DATA_DESCRIPTION.md](DATA_DESCRIPTION.md)** - Comprehensive documentation
394
- - Detailed schema for all 5 files
395
- - Data cleaning and transformation process
396
- - Usage examples and best practices
397
- - Comparison between different files
398
-
399
- ## Data Quality
400
-
401
- - **Complete History**: No missing blocks or gaps in blockchain data
402
- - **Verified Sources**: All OrderFilled events from 2 official exchange contracts
403
- - **Blockchain Verified**: Cross-checked against Polygon RPC nodes
404
- - **Regular Updates**: Automated daily pipeline for fresh data
405
- - **Open Source**: Fully reproducible collection process
406
-
407
- **Contracts Tracked:**
408
- - Exchange Contract 1: `0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E`
409
- - Exchange Contract 2: `0xC5d563A36AE78145C45a50134d48A1215220f80a`
410
-
411
- ## Collection Tools
412
-
413
- Data collected using our open-source toolkit: [polymarket-data](https://github.com/SII-WANGZJ/Polymarket_data)
414
-
415
- **Features:**
416
- - Direct blockchain RPC integration
417
- - Efficient batch processing
418
- - Automatic retry and error handling
419
- - Data validation and verification
420
-
421
- ## Dataset Statistics
422
-
423
- **Last Updated**: 2026-03-05
424
-
425
- **Coverage**:
426
- - Time Range: Polymarket inception to 2026-03-04
427
- - Total Markets: 538,587
428
- - Total Trades: 418.3 million (processed), 689.0 million (raw OrderFilled)
429
- - Unique Users: [To be calculated]
430
-
431
- **Data Freshness**: Updated periodically via automated pipeline
432
-
433
- ## Contributing
434
-
435
- We welcome contributions to improve the dataset and tools:
436
-
437
- 1. **Report Issues**: Found data quality issues? [Open an issue](https://github.com/SII-WANGZJ/Polymarket_data/issues)
438
- 2. **Suggest Features**: Ideas for new data transformations? Let us know!
439
- 3. **Contribute Code**: Improve our collection pipeline via pull requests
440
-
441
- ## License
442
-
443
- MIT License - Free for commercial and research use.
444
-
445
- See [LICENSE](LICENSE) file for details.
446
-
447
- ## Contact & Support
448
-
449
- - **Email**: [wangzhengjie@sii.edu.cn](mailto:wangzhengjie@sii.edu.cn)
450
- - **Issues**: [GitHub Issues](https://github.com/SII-WANGZJ/Polymarket_data/issues)
451
- - **Dataset**: [HuggingFace](https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data)
452
- - **Code**: [GitHub Repository](https://github.com/SII-WANGZJ/Polymarket_data)
453
-
454
- ## Citation
455
-
456
- If you use this dataset in your research, please cite:
457
-
458
- ```bibtex
459
- @misc{polymarket_data_2026,
460
- title={Polymarket Data: Complete Data Infrastructure for Polymarket},
461
- author={Wang, Zhengjie and Chao, Leiyu and Bao, Yu and Cheng, Lian and Liao, Jianhan and Li, Yikang},
462
- year={2026},
463
- howpublished={\url{https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data}},
464
- note={A comprehensive dataset and toolkit for Polymarket prediction markets}
465
- }
466
- ```
467
-
468
- ## Acknowledgments
469
-
470
- - **Polymarket** for building the leading prediction market platform
471
- - **Polygon** for providing reliable blockchain infrastructure
472
- - **HuggingFace** for hosting and distributing large datasets
473
- - The open-source community for tools and libraries
474
-
475
- ---
476
-
477
- <div align="center">
478
-
479
- **Built for the research and data science community**
480
-
481
- [HuggingFace](https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data) • [GitHub](https://github.com/SII-WANGZJ/Polymarket_data) • [Documentation](DATA_DESCRIPTION.md)
482
-
483
- </div>