Commit
·
fbd2f78
0
Parent(s):
Duplicate from SII-WANGZJ/Polymarket_data
Browse filesCo-authored-by: SII-WANGZJ <SII-WANGZJ@users.noreply.huggingface.co>
- .gitattributes +59 -0
- DATA_DESCRIPTION.md +449 -0
- README.md +429 -0
- markets.parquet +3 -0
- orderfilled.parquet +3 -0
- quant.parquet +3 -0
- trades.parquet +3 -0
- users.parquet +3 -0
.gitattributes
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*.7z filter=lfs diff=lfs merge=lfs -text
|
| 2 |
+
*.arrow filter=lfs diff=lfs merge=lfs -text
|
| 3 |
+
*.bin filter=lfs diff=lfs merge=lfs -text
|
| 4 |
+
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
| 5 |
+
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
| 6 |
+
*.ftz filter=lfs diff=lfs merge=lfs -text
|
| 7 |
+
*.gz filter=lfs diff=lfs merge=lfs -text
|
| 8 |
+
*.h5 filter=lfs diff=lfs merge=lfs -text
|
| 9 |
+
*.joblib filter=lfs diff=lfs merge=lfs -text
|
| 10 |
+
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
| 11 |
+
*.lz4 filter=lfs diff=lfs merge=lfs -text
|
| 12 |
+
*.mds filter=lfs diff=lfs merge=lfs -text
|
| 13 |
+
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
| 14 |
+
*.model filter=lfs diff=lfs merge=lfs -text
|
| 15 |
+
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
| 16 |
+
*.npy filter=lfs diff=lfs merge=lfs -text
|
| 17 |
+
*.npz filter=lfs diff=lfs merge=lfs -text
|
| 18 |
+
*.onnx filter=lfs diff=lfs merge=lfs -text
|
| 19 |
+
*.ot filter=lfs diff=lfs merge=lfs -text
|
| 20 |
+
*.parquet filter=lfs diff=lfs merge=lfs -text
|
| 21 |
+
*.pb filter=lfs diff=lfs merge=lfs -text
|
| 22 |
+
*.pickle filter=lfs diff=lfs merge=lfs -text
|
| 23 |
+
*.pkl filter=lfs diff=lfs merge=lfs -text
|
| 24 |
+
*.pt filter=lfs diff=lfs merge=lfs -text
|
| 25 |
+
*.pth filter=lfs diff=lfs merge=lfs -text
|
| 26 |
+
*.rar filter=lfs diff=lfs merge=lfs -text
|
| 27 |
+
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
| 28 |
+
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
| 29 |
+
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
| 30 |
+
*.tar filter=lfs diff=lfs merge=lfs -text
|
| 31 |
+
*.tflite filter=lfs diff=lfs merge=lfs -text
|
| 32 |
+
*.tgz filter=lfs diff=lfs merge=lfs -text
|
| 33 |
+
*.wasm filter=lfs diff=lfs merge=lfs -text
|
| 34 |
+
*.xz filter=lfs diff=lfs merge=lfs -text
|
| 35 |
+
*.zip filter=lfs diff=lfs merge=lfs -text
|
| 36 |
+
*.zst filter=lfs diff=lfs merge=lfs -text
|
| 37 |
+
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
| 38 |
+
# Audio files - uncompressed
|
| 39 |
+
*.pcm filter=lfs diff=lfs merge=lfs -text
|
| 40 |
+
*.sam filter=lfs diff=lfs merge=lfs -text
|
| 41 |
+
*.raw filter=lfs diff=lfs merge=lfs -text
|
| 42 |
+
# Audio files - compressed
|
| 43 |
+
*.aac filter=lfs diff=lfs merge=lfs -text
|
| 44 |
+
*.flac filter=lfs diff=lfs merge=lfs -text
|
| 45 |
+
*.mp3 filter=lfs diff=lfs merge=lfs -text
|
| 46 |
+
*.ogg filter=lfs diff=lfs merge=lfs -text
|
| 47 |
+
*.wav filter=lfs diff=lfs merge=lfs -text
|
| 48 |
+
# Image files - uncompressed
|
| 49 |
+
*.bmp filter=lfs diff=lfs merge=lfs -text
|
| 50 |
+
*.gif filter=lfs diff=lfs merge=lfs -text
|
| 51 |
+
*.png filter=lfs diff=lfs merge=lfs -text
|
| 52 |
+
*.tiff filter=lfs diff=lfs merge=lfs -text
|
| 53 |
+
# Image files - compressed
|
| 54 |
+
*.jpg filter=lfs diff=lfs merge=lfs -text
|
| 55 |
+
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
| 56 |
+
*.webp filter=lfs diff=lfs merge=lfs -text
|
| 57 |
+
# Video files - compressed
|
| 58 |
+
*.mp4 filter=lfs diff=lfs merge=lfs -text
|
| 59 |
+
*.webm filter=lfs diff=lfs merge=lfs -text
|
DATA_DESCRIPTION.md
ADDED
|
@@ -0,0 +1,449 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Polymarket Dataset Description
|
| 2 |
+
|
| 3 |
+
Complete guide to the 5 parquet files in this dataset.
|
| 4 |
+
|
| 5 |
+
---
|
| 6 |
+
|
| 7 |
+
## 📁 File Overview
|
| 8 |
+
|
| 9 |
+
| File | Size | Description | Use Case |
|
| 10 |
+
|------|------|-------------|----------|
|
| 11 |
+
| `orderfilled.parquet` | 31GB | Raw blockchain events | Complete historical record |
|
| 12 |
+
| `trades.parquet` | 32GB | Processed trading data | Market analysis, price tracking |
|
| 13 |
+
| `markets.parquet` | 68MB | Market metadata | Market info, token mapping |
|
| 14 |
+
| `quant.parquet` | 21GB | Quantitative trading data | Trading algorithms, backtesting |
|
| 15 |
+
| `users.parquet` | 23GB | User behavior data | User analysis, wallet tracking |
|
| 16 |
+
|
| 17 |
+
---
|
| 18 |
+
|
| 19 |
+
## 1️⃣ orderfilled.parquet (31GB)
|
| 20 |
+
|
| 21 |
+
**Raw OrderFilled events from Polygon blockchain**
|
| 22 |
+
|
| 23 |
+
### Description
|
| 24 |
+
Original blockchain events decoded from two Polymarket exchange contracts:
|
| 25 |
+
- CTF Exchange: `0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e`
|
| 26 |
+
- NegRisk CTF Exchange: `0xc5d563a36ae78145c45a50134d48a1215220f80a`
|
| 27 |
+
|
| 28 |
+
### Schema
|
| 29 |
+
```
|
| 30 |
+
timestamp int64 # Unix timestamp
|
| 31 |
+
datetime string # Human-readable datetime
|
| 32 |
+
block_number int64 # Blockchain block number
|
| 33 |
+
transaction_hash string # Transaction hash
|
| 34 |
+
log_index int64 # Log index within transaction
|
| 35 |
+
contract string # Contract name
|
| 36 |
+
maker string # Maker address
|
| 37 |
+
taker string # Taker address
|
| 38 |
+
maker_asset_id string # Maker's asset ID (uint256 as string)
|
| 39 |
+
taker_asset_id string # Taker's asset ID (uint256 as string)
|
| 40 |
+
maker_amount_filled int64 # Maker's filled amount (wei)
|
| 41 |
+
taker_amount_filled int64 # Taker's filled amount (wei)
|
| 42 |
+
maker_fee int64 # Maker fee (wei)
|
| 43 |
+
taker_fee int64 # Taker fee (wei)
|
| 44 |
+
protocol_fee int64 # Protocol fee (wei)
|
| 45 |
+
order_hash string # Order hash
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
### Key Features
|
| 49 |
+
- ✅ Complete blockchain data with no missing fields
|
| 50 |
+
- ✅ Includes block_number for time-series analysis
|
| 51 |
+
- ✅ Includes all fees (maker, taker, protocol)
|
| 52 |
+
- ✅ Contains order_hash for order tracking
|
| 53 |
+
|
| 54 |
+
### Use Cases
|
| 55 |
+
- Full historical blockchain analysis
|
| 56 |
+
- Fee analysis
|
| 57 |
+
- Order matching studies
|
| 58 |
+
- Raw event processing
|
| 59 |
+
|
| 60 |
+
---
|
| 61 |
+
|
| 62 |
+
## 2️⃣ trades.parquet (32GB)
|
| 63 |
+
|
| 64 |
+
**Processed trading data with market linkage**
|
| 65 |
+
|
| 66 |
+
### Description
|
| 67 |
+
Enhanced version of orderfilled events with:
|
| 68 |
+
- Market ID linkage (from token to market)
|
| 69 |
+
- Trade direction analysis (BUY/SELL)
|
| 70 |
+
- Price calculation
|
| 71 |
+
- USD amount extraction
|
| 72 |
+
|
| 73 |
+
### Schema
|
| 74 |
+
All fields from `orderfilled.parquet`, plus:
|
| 75 |
+
```
|
| 76 |
+
market_id string # Linked market ID
|
| 77 |
+
condition_id string # Condition ID
|
| 78 |
+
token_id string # Non-USDC token ID
|
| 79 |
+
answer string # Market outcome (YES/NO/etc.)
|
| 80 |
+
nonusdc_side string # Which side has token (token1/token2)
|
| 81 |
+
maker_direction string # Maker's direction (BUY/SELL)
|
| 82 |
+
taker_direction string # Taker's direction (BUY/SELL)
|
| 83 |
+
price float64 # Trade price (0-1)
|
| 84 |
+
token_amount int64 # Token amount (in wei)
|
| 85 |
+
usd_amount int64 # USDC amount (in wei)
|
| 86 |
+
```
|
| 87 |
+
|
| 88 |
+
### Key Features
|
| 89 |
+
- ✅ Auto-linked to market metadata
|
| 90 |
+
- ✅ Trade direction calculated for both sides
|
| 91 |
+
- ✅ Price normalized to 0-1 range
|
| 92 |
+
- ✅ Preserves all original blockchain fields
|
| 93 |
+
|
| 94 |
+
### Use Cases
|
| 95 |
+
- Market price analysis
|
| 96 |
+
- Trading volume by market
|
| 97 |
+
- Direction-based analysis
|
| 98 |
+
- General trading analytics
|
| 99 |
+
|
| 100 |
+
---
|
| 101 |
+
|
| 102 |
+
## 3️⃣ markets.parquet (68MB)
|
| 103 |
+
|
| 104 |
+
**Market metadata from Gamma API**
|
| 105 |
+
|
| 106 |
+
### Description
|
| 107 |
+
Complete market information including:
|
| 108 |
+
- Market questions
|
| 109 |
+
- Outcome names
|
| 110 |
+
- Token IDs
|
| 111 |
+
- Resolution status
|
| 112 |
+
|
| 113 |
+
### Schema
|
| 114 |
+
```
|
| 115 |
+
market_id string # Unique market ID
|
| 116 |
+
question string # Market question
|
| 117 |
+
description string # Market description
|
| 118 |
+
outcomes list # List of outcome names
|
| 119 |
+
tokens list # List of token IDs
|
| 120 |
+
volume float64 # Total trading volume
|
| 121 |
+
liquidity float64 # Market liquidity
|
| 122 |
+
resolved bool # Is market resolved?
|
| 123 |
+
resolution string # Resolution outcome
|
| 124 |
+
created_at timestamp # Market creation time
|
| 125 |
+
end_date timestamp # Market end date
|
| 126 |
+
```
|
| 127 |
+
|
| 128 |
+
### Use Cases
|
| 129 |
+
- Market information lookup
|
| 130 |
+
- Token ID to market mapping
|
| 131 |
+
- Market category analysis
|
| 132 |
+
|
| 133 |
+
---
|
| 134 |
+
|
| 135 |
+
## 4️⃣ quant.parquet (21GB) - Quantitative Trading Data
|
| 136 |
+
|
| 137 |
+
**Cleaned trades with unified token perspective and direction**
|
| 138 |
+
|
| 139 |
+
### Description
|
| 140 |
+
Optimized version of `trades.parquet` for quantitative analysis with:
|
| 141 |
+
1. **Unified Token Perspective**: All trades normalized to YES token (token1)
|
| 142 |
+
2. **Unified Direction**: All trades converted to BUY perspective
|
| 143 |
+
3. **Contract Filtering**: Removed contract-to-contract trades
|
| 144 |
+
|
| 145 |
+
### Data Cleaning Process
|
| 146 |
+
|
| 147 |
+
#### Step 1: Filter Invalid Data
|
| 148 |
+
```python
|
| 149 |
+
# Remove trades with NaN prices
|
| 150 |
+
df = df[~df['price'].isna()]
|
| 151 |
+
|
| 152 |
+
# Remove contract addresses as taker (internal contract operations)
|
| 153 |
+
contract_addresses = {
|
| 154 |
+
'0x4bfb41d5b3570defd03c39a9a4d8de6bd8b8982e', # CTF Exchange
|
| 155 |
+
'0xc5d563a36ae78145c45a50134d48a1215220f80a' # NegRisk CTF Exchange
|
| 156 |
+
}
|
| 157 |
+
df = df[~df['taker'].str.lower().isin(contract_addresses)]
|
| 158 |
+
```
|
| 159 |
+
|
| 160 |
+
#### Step 2: Unified Token Perspective (YES/token1)
|
| 161 |
+
```python
|
| 162 |
+
# If trade involves token2 (NO token), flip the price
|
| 163 |
+
is_token2 = df['nonusdc_side'] == 'token2'
|
| 164 |
+
df.loc[is_token2, 'price'] = 1 - df.loc[is_token2, 'price']
|
| 165 |
+
df['nonusdc_side'] = 'token1' # All normalized to token1/YES
|
| 166 |
+
|
| 167 |
+
# Example:
|
| 168 |
+
# Original: token2, price=0.3 → Normalized: token1, price=0.7
|
| 169 |
+
```
|
| 170 |
+
|
| 171 |
+
**Why?** In prediction markets:
|
| 172 |
+
- token1 = YES outcome (probability)
|
| 173 |
+
- token2 = NO outcome (1 - probability)
|
| 174 |
+
|
| 175 |
+
By normalizing all trades to YES perspective:
|
| 176 |
+
- price = 0.7 means 70% probability of YES
|
| 177 |
+
- Easier to compare across all trades
|
| 178 |
+
- Consistent time-series analysis
|
| 179 |
+
|
| 180 |
+
#### Step 3: Keep All Original Fields
|
| 181 |
+
Unlike `users.parquet`, `quant.parquet` preserves:
|
| 182 |
+
- Both maker and taker addresses
|
| 183 |
+
- Both maker_direction and taker_direction
|
| 184 |
+
- All blockchain metadata
|
| 185 |
+
|
| 186 |
+
### Schema
|
| 187 |
+
Same as `trades.parquet`, but with:
|
| 188 |
+
```
|
| 189 |
+
nonusdc_side string # Always 'token1' (unified)
|
| 190 |
+
price float64 # YES token price (unified)
|
| 191 |
+
```
|
| 192 |
+
|
| 193 |
+
### Key Features
|
| 194 |
+
- ✅ Unified YES token perspective for all trades
|
| 195 |
+
- ✅ Contract trades filtered out
|
| 196 |
+
- ✅ Maintains maker/taker structure
|
| 197 |
+
- ✅ Preserves all original fields
|
| 198 |
+
- ✅ Clean data for backtesting
|
| 199 |
+
|
| 200 |
+
### Use Cases
|
| 201 |
+
- **Algorithmic Trading**: Consistent price signals
|
| 202 |
+
- **Backtesting**: Unified direction simplifies strategy testing
|
| 203 |
+
- **Price Prediction**: Model YES probability trends
|
| 204 |
+
- **Market Making**: Analyze bid-ask spreads
|
| 205 |
+
- **Volume Analysis**: Track real trading activity (no contracts)
|
| 206 |
+
|
| 207 |
+
---
|
| 208 |
+
|
| 209 |
+
## 5️⃣ users.parquet (23GB) - User Behavior Data
|
| 210 |
+
|
| 211 |
+
**User-centric view with split maker/taker records**
|
| 212 |
+
|
| 213 |
+
### Description
|
| 214 |
+
Transformed view of trades optimized for user behavior analysis:
|
| 215 |
+
1. **Split Records**: Each trade becomes 2 records (maker + taker)
|
| 216 |
+
2. **Unified Token Perspective**: All normalized to YES token
|
| 217 |
+
3. **Unified Direction**: All trades converted to BUY, negative amounts for sells
|
| 218 |
+
4. **Sorted by User**: Easy to analyze individual user trajectories
|
| 219 |
+
|
| 220 |
+
### Data Cleaning Process
|
| 221 |
+
|
| 222 |
+
#### Step 1: Filter Invalid Data (Same as quant)
|
| 223 |
+
```python
|
| 224 |
+
# Remove NaN prices and contract trades
|
| 225 |
+
df = df[~df['price'].isna()]
|
| 226 |
+
df = df[~df['taker'].str.lower().isin(contract_addresses)]
|
| 227 |
+
```
|
| 228 |
+
|
| 229 |
+
#### Step 2: Split Maker and Taker into Separate Records
|
| 230 |
+
```python
|
| 231 |
+
# Common fields for both sides
|
| 232 |
+
common = ['timestamp', 'datetime', 'block_number', 'transaction_hash',
|
| 233 |
+
'market_id', 'price', 'token_amount', 'usd_amount']
|
| 234 |
+
|
| 235 |
+
# Maker record
|
| 236 |
+
maker_df = df[common + ['maker', 'maker_direction']].copy()
|
| 237 |
+
maker_df = maker_df.rename(columns={'maker': 'user', 'maker_direction': 'direction'})
|
| 238 |
+
maker_df['role'] = 'maker'
|
| 239 |
+
|
| 240 |
+
# Taker record
|
| 241 |
+
taker_df = df[common + ['taker', 'taker_direction']].copy()
|
| 242 |
+
taker_df = taker_df.rename(columns={'taker': 'user', 'taker_direction': 'direction'})
|
| 243 |
+
taker_df['role'] = 'taker'
|
| 244 |
+
|
| 245 |
+
# Concatenate
|
| 246 |
+
result = pd.concat([maker_df, taker_df])
|
| 247 |
+
|
| 248 |
+
# Original 1 trade → 2 records (expansion ratio ~2x)
|
| 249 |
+
```
|
| 250 |
+
|
| 251 |
+
#### Step 3: Unified Token Perspective (YES/token1)
|
| 252 |
+
```python
|
| 253 |
+
# If token2 trade, flip price (same as quant)
|
| 254 |
+
is_token2 = result['nonusdc_side'] == 'token2'
|
| 255 |
+
result.loc[is_token2, 'price'] = 1 - result.loc[is_token2, 'price']
|
| 256 |
+
```
|
| 257 |
+
|
| 258 |
+
#### Step 4: Unified Direction to BUY
|
| 259 |
+
```python
|
| 260 |
+
# Convert all SELL to BUY with negative token_amount
|
| 261 |
+
is_sell = result['direction'] == 'SELL'
|
| 262 |
+
result.loc[is_sell, 'token_amount'] = -result.loc[is_sell, 'token_amount']
|
| 263 |
+
result['direction'] = 'BUY' # All records are now 'BUY'
|
| 264 |
+
|
| 265 |
+
# Example:
|
| 266 |
+
# Original SELL: direction='SELL', token_amount=100
|
| 267 |
+
# Unified BUY: direction='BUY', token_amount=-100
|
| 268 |
+
```
|
| 269 |
+
|
| 270 |
+
**Why?**
|
| 271 |
+
- **BUY** (token_amount > 0): User bought YES tokens, spent USDC
|
| 272 |
+
- **SELL** (token_amount < 0): User sold YES tokens, received USDC
|
| 273 |
+
- Single direction simplifies aggregation: `sum(token_amount)` = net position
|
| 274 |
+
|
| 275 |
+
#### Step 5: Sort by User and Time
|
| 276 |
+
```python
|
| 277 |
+
result = result.sort_values(['user', 'timestamp'])
|
| 278 |
+
```
|
| 279 |
+
|
| 280 |
+
### Schema
|
| 281 |
+
```
|
| 282 |
+
timestamp int64 # Unix timestamp
|
| 283 |
+
datetime string # Human-readable datetime
|
| 284 |
+
block_number int64 # Block number
|
| 285 |
+
transaction_hash string # Transaction hash
|
| 286 |
+
event_id string # Unique event identifier
|
| 287 |
+
market_id string # Market ID
|
| 288 |
+
condition_id string # Condition ID
|
| 289 |
+
user string # User address (was maker/taker)
|
| 290 |
+
role string # 'maker' or 'taker'
|
| 291 |
+
price float64 # YES token price (unified)
|
| 292 |
+
token_amount int64 # Token amount (negative if originally SELL)
|
| 293 |
+
usd_amount int64 # USDC amount (wei)
|
| 294 |
+
```
|
| 295 |
+
|
| 296 |
+
### Key Features
|
| 297 |
+
- ✅ Each user appears in their own records
|
| 298 |
+
- ✅ Easy to track user trading history
|
| 299 |
+
- ✅ Unified BUY direction with signed amounts
|
| 300 |
+
- ✅ Sorted by user → timestamp for sequential analysis
|
| 301 |
+
- ✅ 2x expansion ratio (1 trade → 2 records)
|
| 302 |
+
|
| 303 |
+
### Use Cases
|
| 304 |
+
- **User Profiling**: Track individual user strategies
|
| 305 |
+
- **Wallet Analysis**: PnL calculation per user
|
| 306 |
+
- **Cohort Analysis**: User behavior segmentation
|
| 307 |
+
- **Position Tracking**: Sum token_amount = net position
|
| 308 |
+
- **Trading Pattern Detection**: Identify market makers, arbitrageurs
|
| 309 |
+
- **User Journey**: Sequential trade analysis
|
| 310 |
+
|
| 311 |
+
### Example: Calculate User Net Position
|
| 312 |
+
```python
|
| 313 |
+
import pandas as pd
|
| 314 |
+
|
| 315 |
+
users = pd.read_parquet('users.parquet')
|
| 316 |
+
|
| 317 |
+
# Net position per user per market
|
| 318 |
+
position = users.groupby(['user', 'market_id'])['token_amount'].sum()
|
| 319 |
+
|
| 320 |
+
# User with long position (bought more than sold)
|
| 321 |
+
positive_position = position[position > 0]
|
| 322 |
+
|
| 323 |
+
# User with short position (sold more than bought)
|
| 324 |
+
negative_position = position[position < 0]
|
| 325 |
+
```
|
| 326 |
+
|
| 327 |
+
---
|
| 328 |
+
|
| 329 |
+
## 🔄 Data Processing Pipeline
|
| 330 |
+
|
| 331 |
+
```
|
| 332 |
+
Polygon Blockchain
|
| 333 |
+
↓
|
| 334 |
+
RPC Query (OrderFilled events)
|
| 335 |
+
↓
|
| 336 |
+
Decode ABI
|
| 337 |
+
↓
|
| 338 |
+
orderfilled.parquet (31GB)
|
| 339 |
+
├─→ Link market_id via Gamma API
|
| 340 |
+
↓
|
| 341 |
+
trades.parquet (32GB)
|
| 342 |
+
├─→ Filter + Unified YES perspective
|
| 343 |
+
├─→ Keep maker/taker structure
|
| 344 |
+
↓
|
| 345 |
+
quant.parquet (21GB)
|
| 346 |
+
│
|
| 347 |
+
└─→ Split maker/taker + Unified BUY direction
|
| 348 |
+
↓
|
| 349 |
+
users.parquet (23GB)
|
| 350 |
+
```
|
| 351 |
+
|
| 352 |
+
---
|
| 353 |
+
|
| 354 |
+
## 🆚 Comparison: quant vs users
|
| 355 |
+
|
| 356 |
+
| Feature | quant.parquet | users.parquet |
|
| 357 |
+
|---------|---------------|---------------|
|
| 358 |
+
| **Perspective** | Trade-centric | User-centric |
|
| 359 |
+
| **Records per trade** | 1 | 2 (maker + taker) |
|
| 360 |
+
| **Size** | 21GB | 23GB |
|
| 361 |
+
| **Token normalization** | ✅ YES (token1) | ✅ YES (token1) |
|
| 362 |
+
| **Direction** | Preserved (BUY/SELL) | Unified (BUY only) |
|
| 363 |
+
| **Maker/Taker** | Both preserved | Split into rows |
|
| 364 |
+
| **Sort order** | Original | User → Time |
|
| 365 |
+
| **Use case** | Trading algorithms | User behavior |
|
| 366 |
+
|
| 367 |
+
---
|
| 368 |
+
|
| 369 |
+
## 💡 Usage Examples
|
| 370 |
+
|
| 371 |
+
### Example 1: Load Quant Data for Backtesting
|
| 372 |
+
```python
|
| 373 |
+
import pandas as pd
|
| 374 |
+
|
| 375 |
+
quant = pd.read_parquet('quant.parquet')
|
| 376 |
+
|
| 377 |
+
# All trades in YES token perspective
|
| 378 |
+
# Price represents YES probability
|
| 379 |
+
market_data = quant[quant['market_id'] == 'specific_market']
|
| 380 |
+
|
| 381 |
+
# Calculate returns
|
| 382 |
+
market_data = market_data.sort_values('timestamp')
|
| 383 |
+
market_data['returns'] = market_data['price'].pct_change()
|
| 384 |
+
```
|
| 385 |
+
|
| 386 |
+
### Example 2: Analyze User Trading Patterns
|
| 387 |
+
```python
|
| 388 |
+
users = pd.read_parquet('users.parquet')
|
| 389 |
+
|
| 390 |
+
# Get one user's trading history
|
| 391 |
+
user_trades = users[users['user'] == '0x123...']
|
| 392 |
+
|
| 393 |
+
# Calculate net position (positive = long, negative = short)
|
| 394 |
+
net_position = user_trades.groupby('market_id')['token_amount'].sum()
|
| 395 |
+
|
| 396 |
+
# Identify strategy
|
| 397 |
+
if (user_trades['role'] == 'maker').mean() > 0.7:
|
| 398 |
+
strategy = 'Market Maker'
|
| 399 |
+
elif net_position.abs().mean() < 1000:
|
| 400 |
+
strategy = 'Scalper'
|
| 401 |
+
else:
|
| 402 |
+
strategy = 'Position Trader'
|
| 403 |
+
```
|
| 404 |
+
|
| 405 |
+
---
|
| 406 |
+
|
| 407 |
+
## 📊 Data Quality
|
| 408 |
+
|
| 409 |
+
### Completeness
|
| 410 |
+
- ✅ All OrderFilled events since contract deployment
|
| 411 |
+
- ✅ No missing blocks (failed fetches are retried)
|
| 412 |
+
- ✅ All blockchain fields preserved
|
| 413 |
+
|
| 414 |
+
### Cleaning Rules
|
| 415 |
+
- ❌ Removed: Contract-to-contract trades
|
| 416 |
+
- ❌ Removed: Trades with NaN prices
|
| 417 |
+
- ✅ Kept: All user-to-user trades
|
| 418 |
+
- ✅ Kept: All fee information
|
| 419 |
+
|
| 420 |
+
### Token Normalization
|
| 421 |
+
- All `quant.parquet` and `users.parquet` prices represent **YES token probability**
|
| 422 |
+
- Original token2 prices are flipped: `price_yes = 1 - price_no`
|
| 423 |
+
- Consistent for time-series and cross-market analysis
|
| 424 |
+
|
| 425 |
+
---
|
| 426 |
+
|
| 427 |
+
## 🔗 Relationships
|
| 428 |
+
|
| 429 |
+
```
|
| 430 |
+
markets.parquet
|
| 431 |
+
↓ (market_id)
|
| 432 |
+
trades.parquet
|
| 433 |
+
↓ (filter + normalize)
|
| 434 |
+
quant.parquet (trade-level)
|
| 435 |
+
users.parquet (user-level)
|
| 436 |
+
```
|
| 437 |
+
|
| 438 |
+
---
|
| 439 |
+
|
| 440 |
+
## ⚖️ License
|
| 441 |
+
|
| 442 |
+
MIT License - Free for commercial and research use
|
| 443 |
+
|
| 444 |
+
---
|
| 445 |
+
|
| 446 |
+
## 📞 Questions?
|
| 447 |
+
|
| 448 |
+
- GitHub Issues: [polymarket-data](https://github.com/SII-WANGZJ/polymarket-data/issues)
|
| 449 |
+
- Dataset: [HuggingFace](https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data)
|
README.md
ADDED
|
@@ -0,0 +1,429 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 <sup>2</sup>Westlake University <sup>3</sup>Shanghai Jiao Tong University
|
| 17 |
+
<br>
|
| 18 |
+
<sup>4</sup>Harbin Institute of Technology <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 **107GB of historical on-chain trading data** from Polymarket, containing **1.1 billion records** across 268K+ 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 carefully curated datasets serving different research needs - from raw blockchain events to user-level behavior analysis, with unified data transformations for easy analysis.
|
| 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 |
+
| `orderfilled.parquet` | 31GB | 293.3M | Raw blockchain events from OrderFilled logs |
|
| 63 |
+
| `trades.parquet` | 32GB | 293.3M | Processed trades with market metadata linkage |
|
| 64 |
+
| `markets.parquet` | 68MB | 268,706 | Market information and metadata |
|
| 65 |
+
| `quant.parquet` | 21GB | 170.3M | Clean market data with unified YES perspective |
|
| 66 |
+
| `users.parquet` | 23GB | 340.6M | User behavior data split by maker/taker roles |
|
| 67 |
+
|
| 68 |
+
**Total**: 107GB, 1.1 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 clean market data
|
| 110 |
+
df = pd.read_parquet('quant.parquet')
|
| 111 |
+
print(f"Total trades: {len(df):,}")
|
| 112 |
+
|
| 113 |
+
# Load user behavior data
|
| 114 |
+
users = pd.read_parquet('users.parquet')
|
| 115 |
+
print(f"Total user actions: {len(users):,}")
|
| 116 |
+
|
| 117 |
+
# Load market metadata
|
| 118 |
+
markets = pd.read_parquet('markets.parquet')
|
| 119 |
+
print(f"Total markets: {len(markets):,}")
|
| 120 |
+
```
|
| 121 |
+
|
| 122 |
+
### Load from HuggingFace Datasets
|
| 123 |
+
|
| 124 |
+
```python
|
| 125 |
+
from datasets import load_dataset
|
| 126 |
+
|
| 127 |
+
# Load specific file
|
| 128 |
+
dataset = load_dataset(
|
| 129 |
+
"SII-WANGZJ/Polymarket_data",
|
| 130 |
+
data_files="quant.parquet"
|
| 131 |
+
)
|
| 132 |
+
|
| 133 |
+
# Load multiple files
|
| 134 |
+
dataset = load_dataset(
|
| 135 |
+
"SII-WANGZJ/Polymarket_data",
|
| 136 |
+
data_files=["quant.parquet", "markets.parquet"]
|
| 137 |
+
)
|
| 138 |
+
```
|
| 139 |
+
|
| 140 |
+
### Download Specific Files
|
| 141 |
+
|
| 142 |
+
```bash
|
| 143 |
+
# Download using HuggingFace CLI
|
| 144 |
+
pip install huggingface_hub
|
| 145 |
+
|
| 146 |
+
# Download a specific file
|
| 147 |
+
hf download SII-WANGZJ/Polymarket_data quant.parquet --repo-type dataset
|
| 148 |
+
|
| 149 |
+
# Download all files
|
| 150 |
+
hf download SII-WANGZJ/Polymarket_data --repo-type dataset
|
| 151 |
+
```
|
| 152 |
+
|
| 153 |
+
## Data Structure
|
| 154 |
+
|
| 155 |
+
### quant.parquet - Clean Market Data
|
| 156 |
+
|
| 157 |
+
Filtered and normalized trade data with unified token perspective (YES token).
|
| 158 |
+
|
| 159 |
+
**Key Features:**
|
| 160 |
+
- Unified perspective: All trades normalized to YES token (token1)
|
| 161 |
+
- Clean data: Contract trades filtered out, only real user trades
|
| 162 |
+
- Complete information: Maker/taker roles preserved
|
| 163 |
+
- Best for: Market analysis, price studies, time-series forecasting
|
| 164 |
+
|
| 165 |
+
**Schema:**
|
| 166 |
+
```python
|
| 167 |
+
{
|
| 168 |
+
'transaction_hash': str, # Blockchain transaction hash
|
| 169 |
+
'block_number': int, # Block number
|
| 170 |
+
'datetime': datetime, # Transaction timestamp
|
| 171 |
+
'market_id': str, # Market identifier
|
| 172 |
+
'maker': str, # Maker wallet address
|
| 173 |
+
'taker': str, # Taker wallet address
|
| 174 |
+
'token_amount': float, # Amount of tokens traded
|
| 175 |
+
'usd_amount': float, # USD value
|
| 176 |
+
'price': float, # Trade price (0-1)
|
| 177 |
+
}
|
| 178 |
+
```
|
| 179 |
+
|
| 180 |
+
### users.parquet - User Behavior Data
|
| 181 |
+
|
| 182 |
+
Split maker/taker records with unified buy direction for user analysis.
|
| 183 |
+
|
| 184 |
+
**Key Features:**
|
| 185 |
+
- Split records: Each trade becomes 2 records (one maker, one taker)
|
| 186 |
+
- Unified direction: All converted to BUY (negative amounts = selling)
|
| 187 |
+
- User sorted: Ordered by user for trajectory analysis
|
| 188 |
+
- Best for: User profiling, PnL calculation, wallet analysis
|
| 189 |
+
|
| 190 |
+
**Schema:**
|
| 191 |
+
```python
|
| 192 |
+
{
|
| 193 |
+
'transaction_hash': str, # Transaction hash
|
| 194 |
+
'block_number': int, # Block number
|
| 195 |
+
'datetime': datetime, # Timestamp
|
| 196 |
+
'market_id': str, # Market identifier
|
| 197 |
+
'user': str, # User wallet address
|
| 198 |
+
'role': str, # 'maker' or 'taker'
|
| 199 |
+
'token_amount': float, # Signed amount (+ buy, - sell)
|
| 200 |
+
'usd_amount': float, # USD value
|
| 201 |
+
'price': float, # Trade price
|
| 202 |
+
}
|
| 203 |
+
```
|
| 204 |
+
|
| 205 |
+
### markets.parquet - Market Metadata
|
| 206 |
+
|
| 207 |
+
Market information and outcome token details.
|
| 208 |
+
|
| 209 |
+
**Best for:** Linking trades to market context, filtering by market attributes
|
| 210 |
+
|
| 211 |
+
### trades.parquet - Processed Blockchain Data
|
| 212 |
+
|
| 213 |
+
Raw OrderFilled events with market linkage but no transformations.
|
| 214 |
+
|
| 215 |
+
**Best for:** Custom analysis requiring original blockchain data
|
| 216 |
+
|
| 217 |
+
### orderfilled.parquet - Raw Blockchain Events
|
| 218 |
+
|
| 219 |
+
Unprocessed OrderFilled events directly from blockchain logs.
|
| 220 |
+
|
| 221 |
+
**Best for:** Blockchain research, verification, custom processing pipelines
|
| 222 |
+
|
| 223 |
+
## Example Analysis
|
| 224 |
+
|
| 225 |
+
### 1. Calculate Market Statistics
|
| 226 |
+
|
| 227 |
+
```python
|
| 228 |
+
import pandas as pd
|
| 229 |
+
|
| 230 |
+
df = pd.read_parquet('quant.parquet')
|
| 231 |
+
|
| 232 |
+
# Market-level statistics
|
| 233 |
+
market_stats = df.groupby('market_id').agg({
|
| 234 |
+
'usd_amount': ['sum', 'mean'], # Total volume and average trade size
|
| 235 |
+
'price': ['mean', 'std', 'min', 'max'], # Price statistics
|
| 236 |
+
'transaction_hash': 'count' # Number of trades
|
| 237 |
+
}).round(4)
|
| 238 |
+
|
| 239 |
+
print(market_stats.head())
|
| 240 |
+
```
|
| 241 |
+
|
| 242 |
+
### 2. Track Price Evolution
|
| 243 |
+
|
| 244 |
+
```python
|
| 245 |
+
import pandas as pd
|
| 246 |
+
import matplotlib.pyplot as plt
|
| 247 |
+
|
| 248 |
+
df = pd.read_parquet('quant.parquet')
|
| 249 |
+
df['datetime'] = pd.to_datetime(df['datetime'])
|
| 250 |
+
|
| 251 |
+
# Select a specific market
|
| 252 |
+
market_id = 'your-market-id'
|
| 253 |
+
market_data = df[df['market_id'] == market_id].sort_values('datetime')
|
| 254 |
+
|
| 255 |
+
# Plot price over time
|
| 256 |
+
plt.figure(figsize=(12, 6))
|
| 257 |
+
plt.plot(market_data['datetime'], market_data['price'])
|
| 258 |
+
plt.title(f'Price Evolution - Market {market_id}')
|
| 259 |
+
plt.xlabel('Date')
|
| 260 |
+
plt.ylabel('Price')
|
| 261 |
+
plt.show()
|
| 262 |
+
```
|
| 263 |
+
|
| 264 |
+
### 3. Analyze User Behavior
|
| 265 |
+
|
| 266 |
+
```python
|
| 267 |
+
import pandas as pd
|
| 268 |
+
|
| 269 |
+
df = pd.read_parquet('users.parquet')
|
| 270 |
+
|
| 271 |
+
# Calculate net position per user per market
|
| 272 |
+
user_positions = df.groupby(['user', 'market_id']).agg({
|
| 273 |
+
'token_amount': 'sum', # Net position (positive = long, negative = short)
|
| 274 |
+
'usd_amount': 'sum', # Total USD traded
|
| 275 |
+
'transaction_hash': 'count' # Number of trades
|
| 276 |
+
}).reset_index()
|
| 277 |
+
|
| 278 |
+
# Find most active users
|
| 279 |
+
active_users = user_positions.groupby('user').agg({
|
| 280 |
+
'market_id': 'count', # Number of markets traded
|
| 281 |
+
'usd_amount': 'sum' # Total volume
|
| 282 |
+
}).sort_values('usd_amount', ascending=False)
|
| 283 |
+
|
| 284 |
+
print(active_users.head(10))
|
| 285 |
+
```
|
| 286 |
+
|
| 287 |
+
### 4. Market Volume Analysis
|
| 288 |
+
|
| 289 |
+
```python
|
| 290 |
+
import pandas as pd
|
| 291 |
+
|
| 292 |
+
df = pd.read_parquet('quant.parquet')
|
| 293 |
+
markets = pd.read_parquet('markets.parquet')
|
| 294 |
+
|
| 295 |
+
# Join with market metadata
|
| 296 |
+
df = df.merge(markets[['market_id', 'question']], on='market_id', how='left')
|
| 297 |
+
|
| 298 |
+
# Top markets by volume
|
| 299 |
+
top_markets = df.groupby(['market_id', 'question']).agg({
|
| 300 |
+
'usd_amount': 'sum'
|
| 301 |
+
}).sort_values('usd_amount', ascending=False).head(20)
|
| 302 |
+
|
| 303 |
+
print(top_markets)
|
| 304 |
+
```
|
| 305 |
+
|
| 306 |
+
## Data Processing Pipeline
|
| 307 |
+
|
| 308 |
+
```
|
| 309 |
+
Polygon Blockchain (RPC)
|
| 310 |
+
↓
|
| 311 |
+
orderfilled.parquet (Raw events)
|
| 312 |
+
↓
|
| 313 |
+
trades.parquet (+ Market linkage)
|
| 314 |
+
↓
|
| 315 |
+
├─→ quant.parquet (Trade-level, unified YES perspective)
|
| 316 |
+
│ └─→ Filter contracts + Normalize tokens
|
| 317 |
+
│
|
| 318 |
+
└─→ users.parquet (User-level, split maker/taker)
|
| 319 |
+
└─→ Split records + Unified BUY direction
|
| 320 |
+
```
|
| 321 |
+
|
| 322 |
+
**Key Transformations:**
|
| 323 |
+
|
| 324 |
+
1. **quant.parquet**:
|
| 325 |
+
- Filter out contract trades (keep only user trades)
|
| 326 |
+
- Normalize all trades to YES token perspective
|
| 327 |
+
- Preserve maker/taker information
|
| 328 |
+
- Result: 170.3M records (from 293.3M)
|
| 329 |
+
|
| 330 |
+
2. **users.parquet**:
|
| 331 |
+
- Split each trade into 2 records (maker + taker)
|
| 332 |
+
- Convert all to BUY direction (signed amounts)
|
| 333 |
+
- Sort by user for easy querying
|
| 334 |
+
- Result: 340.6M records (from 293.3M × 2, some filtered)
|
| 335 |
+
|
| 336 |
+
## Documentation
|
| 337 |
+
|
| 338 |
+
- **[DATA_DESCRIPTION.md](DATA_DESCRIPTION.md)** - Comprehensive documentation
|
| 339 |
+
- Detailed schema for all 5 files
|
| 340 |
+
- Data cleaning and transformation process
|
| 341 |
+
- Usage examples and best practices
|
| 342 |
+
- Comparison between different files
|
| 343 |
+
|
| 344 |
+
## Data Quality
|
| 345 |
+
|
| 346 |
+
- **Complete History**: No missing blocks or gaps in blockchain data
|
| 347 |
+
- **Verified Sources**: All OrderFilled events from 2 official exchange contracts
|
| 348 |
+
- **Blockchain Verified**: Cross-checked against Polygon RPC nodes
|
| 349 |
+
- **Regular Updates**: Automated daily pipeline for fresh data
|
| 350 |
+
- **Open Source**: Fully reproducible collection process
|
| 351 |
+
|
| 352 |
+
**Contracts Tracked:**
|
| 353 |
+
- Exchange Contract 1: `0x4bFb41d5B3570DeFd03C39a9A4D8dE6Bd8B8982E`
|
| 354 |
+
- Exchange Contract 2: `0xC5d563A36AE78145C45a50134d48A1215220f80a`
|
| 355 |
+
|
| 356 |
+
## Collection Tools
|
| 357 |
+
|
| 358 |
+
Data collected using our open-source toolkit: [polymarket-data](https://github.com/SII-WANGZJ/Polymarket_data)
|
| 359 |
+
|
| 360 |
+
**Features:**
|
| 361 |
+
- Direct blockchain RPC integration
|
| 362 |
+
- Efficient batch processing
|
| 363 |
+
- Automatic retry and error handling
|
| 364 |
+
- Data validation and verification
|
| 365 |
+
|
| 366 |
+
## Dataset Statistics
|
| 367 |
+
|
| 368 |
+
**Last Updated**: 2026-01-01
|
| 369 |
+
|
| 370 |
+
**Coverage**:
|
| 371 |
+
- Time Range: [Polymarket inception] to [Latest update]
|
| 372 |
+
- Total Markets: 268,706
|
| 373 |
+
- Total Trades: 293.3 million
|
| 374 |
+
- Total Volume: $[To be calculated] billion
|
| 375 |
+
- Unique Users: [To be calculated]
|
| 376 |
+
|
| 377 |
+
**Data Freshness**: Updated daily via automated pipeline
|
| 378 |
+
|
| 379 |
+
## Contributing
|
| 380 |
+
|
| 381 |
+
We welcome contributions to improve the dataset and tools:
|
| 382 |
+
|
| 383 |
+
1. **Report Issues**: Found data quality issues? [Open an issue](https://github.com/SII-WANGZJ/Polymarket_data/issues)
|
| 384 |
+
2. **Suggest Features**: Ideas for new data transformations? Let us know!
|
| 385 |
+
3. **Contribute Code**: Improve our collection pipeline via pull requests
|
| 386 |
+
|
| 387 |
+
## License
|
| 388 |
+
|
| 389 |
+
MIT License - Free for commercial and research use.
|
| 390 |
+
|
| 391 |
+
See [LICENSE](LICENSE) file for details.
|
| 392 |
+
|
| 393 |
+
## Contact & Support
|
| 394 |
+
|
| 395 |
+
- **Email**: [wangzhengjie@sii.edu.cn](mailto:wangzhengjie@sii.edu.cn)
|
| 396 |
+
- **Issues**: [GitHub Issues](https://github.com/SII-WANGZJ/Polymarket_data/issues)
|
| 397 |
+
- **Dataset**: [HuggingFace](https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data)
|
| 398 |
+
- **Code**: [GitHub Repository](https://github.com/SII-WANGZJ/Polymarket_data)
|
| 399 |
+
|
| 400 |
+
## Citation
|
| 401 |
+
|
| 402 |
+
If you use this dataset in your research, please cite:
|
| 403 |
+
|
| 404 |
+
```bibtex
|
| 405 |
+
@misc{polymarket_data_2026,
|
| 406 |
+
title={Polymarket Data: Complete Data Infrastructure for Polymarket},
|
| 407 |
+
author={Wang, Zhengjie and Chao, Leiyu and Bao, Yu and Cheng, Lian and Liao, Jianhan and Li, Yikang},
|
| 408 |
+
year={2026},
|
| 409 |
+
howpublished={\url{https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data}},
|
| 410 |
+
note={A comprehensive dataset and toolkit for Polymarket prediction markets}
|
| 411 |
+
}
|
| 412 |
+
```
|
| 413 |
+
|
| 414 |
+
## Acknowledgments
|
| 415 |
+
|
| 416 |
+
- **Polymarket** for building the leading prediction market platform
|
| 417 |
+
- **Polygon** for providing reliable blockchain infrastructure
|
| 418 |
+
- **HuggingFace** for hosting and distributing large datasets
|
| 419 |
+
- The open-source community for tools and libraries
|
| 420 |
+
|
| 421 |
+
---
|
| 422 |
+
|
| 423 |
+
<div align="center">
|
| 424 |
+
|
| 425 |
+
**Built for the research and data science community**
|
| 426 |
+
|
| 427 |
+
[HuggingFace](https://huggingface.co/datasets/SII-WANGZJ/Polymarket_data) • [GitHub](https://github.com/SII-WANGZJ/Polymarket_data) • [Documentation](DATA_DESCRIPTION.md)
|
| 428 |
+
|
| 429 |
+
</div>
|
markets.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:0e4533e08cebba2bc22a4c089df7b23e96451cacafed693a4ec9d0a48b230921
|
| 3 |
+
size 70941035
|
orderfilled.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:481809ee64543da09ed84f282c4f2805c7b4d1ff8d1cefd631a6df7d5dd6c055
|
| 3 |
+
size 33518172323
|
quant.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:46079dbe3b4aa16dbfd4535b10846529fcd189dbdc4ebd38d1e7a391eb6b9bba
|
| 3 |
+
size 22859967175
|
trades.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:17386c6ebd146f756548b4be05cac3d8ee511a7f5e4e720340b22edd04412ca4
|
| 3 |
+
size 34709564052
|
users.parquet
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:766b1925196f5003f4f1e2868f6c8ef825f87da023fca5b01e1b11afcc4e45c1
|
| 3 |
+
size 28929603335
|