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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)
|