StakeBench / data_processing.md
greenday123's picture
Add StakeBench v1.1.2: dataset card, license, croissant.json, data_processing.md
f618909 verified
|
Raw History Blame Contribute Delete
28.3 kB

Data Processing Documentation

Dataset: StakeBench — Evaluating Language Understanding Grounded in Market Commitment (working name during collection: PolySent) Updated: 2026-10-27 (v1.1: §6 now points to the released raw files and scripts; collection documentation unchanged since 2026-03-18) Platforms: Polymarket (polymarket_data/) · Manifold Markets (manifold_data/)


Table of Contents

  1. Overview
  2. Polymarket Dataset
  3. Manifold Dataset
  4. Schema Comparison
  5. Descriptive Statistics
  6. Raw Files and Scripts

1. Overview

Polymarket Manifold
Market type Real-money binary/multi-outcome prediction markets Virtual-currency (Mana) binary prediction markets
API gamma-api.polymarket.com + data-api.polymarket.com api.manifold.markets/v0
Market filter (collection) Event-level: total volume ≥ $10,000 USD + comments ≥ 100 Market-level: volume ≥ 10,000 M$ + bettors ≥ 50 + has comments
Comment filter (collection) ≥ 3 chars; ≥ 10 per market ≥ 3 chars; ≥ 10 per market; within market lifecycle
Comment filter (cleaning) Markets with < 10 comments removed; empty questions removed Markets with < 100 comments removed; empty questions removed
Cleaned comments 514,314 46,562
Cleaned markets 2,070 191
Unique users 24,909 3,250
Date range 2024-05-02 → 2026-03-12 2022-01-14 → 2026-03-07

2. Polymarket Dataset

2.1 Topic Collection

Script: get_polymarket_topics.py Output: polysent_data/valid_topics.jsonl, polysent_data/valid_topics_summary.csv

Pipeline

GET gamma-api.polymarket.com/markets
  └─ params: closed=True, limit=500, offset=0..N
  └─ paginate until empty response (≤ MAX_PAGES=2000, ~1M markets)
  └─ per market: extract event_id, volume, comment_count
  └─ aggregate by event_id:
       total_volume  = Σ volume across all markets in the event
       comment_count = event-level commentCount (shared)
       best_market   = highest-volume market (representative)
  └─ filter: total_volume ≥ $10,000  AND  comment_count ≥ 100
  └─ classify category by keyword matching (crypto/politics/economics/sports/technology)

Key Parameters

Parameter Value Description
MIN_TOTAL_VOLUME 10,000 Minimum USD trading volume per event
MIN_COMMENT_COUNT 100 Minimum comments per event
PAGE_LIMIT 500 Markets per API request
SLEEP 0.15 s Inter-request delay

Category Classification

Keywords are matched against the representative market's question text (case-insensitive substring match). The category with the most keyword hits wins; no match → "other".

Categories: crypto, politics, economics, sports, technology, other


2.2 Comment Collection

Script: get_polymarket_comments.py Input: polysent_data/valid_topics_summary.csv (column best_market_id) Output: polysent_data/comments.csv

Pipeline

For each target market_id:
  1. GET gamma-api.polymarket.com/comments
       └─ params: parent_entity_type=market, parent_entity_id=<id>
       └─ fallback: Event → Series (auto-detected)
       └─ paginate with offset until exhausted

  2. For each commenter's user_address:
       GET data-api.polymarket.com/activity
         └─ parallel fetch (8 threads, ThreadPoolExecutor)
         └─ reconstruct historical position at comment creation time:
              position_side  = Yes / No / <team> (market-specific)
              position_size  = USD net cost (Σ BUY − Σ SELL; can be negative when profitable)
              position_shares = net shares held

  3. Write rows to comments.csv (append / resumable via progress.json)

Anti-Ban Measures

  • Random User-Agent rotation (5 browser strings)
  • Exponential backoff + jitter on HTTP 429/5xx (max 120 s)
  • Optional proxy pool rotation (proxies.txt)
  • Inter-request jitter sleep: BASE_SLEEP ± JITTER = 0.12 ± 0.08 s
  • Resume support: progress.json tracks done / skipped / failed per market

Collection Filters

Filter Value Note
MIN_COMMENT_LENGTH 3 chars Loose; stricter post-hoc filter recommended (>20)
MIN_COMMENTS_PER_MARKET 10 Markets below this are marked skipped
Time window [market_start_time, market_end_time] Comments outside market lifecycle dropped

Output Schema (raw comments.csv)

Field Type Description
market_id str Polymarket market ID
slug str URL slug
question str Market question
condition_id str On-chain condition ID
category_validated str Keyword-classified category (5 classes)
market_start_time ISO8601 Market open time
market_end_time ISO8601 Market close/settlement time
parent_entity_type_used str Event or Series (fallback tracking)
parent_entity_id_used str Entity ID used for comment API call
comment_id str Unique comment ID (may repeat across markets sharing a Series)
created_at ISO8601 Comment timestamp (UTC)
text str Comment body
pseudonym str Anonymized display name
user_address str On-chain ETH wallet address
proxy_wallet str Polymarket proxy wallet
position_side str Yes / No / team name at comment time
position_size float USD net cost (can be negative when profitable)
position_shares float Net shares held at comment time
reactions JSON str Raw reaction array
reaction_count int Total reactions (occasional −1 from API bug)
report_count int Number of reports
parent_comment_id str Parent comment ID (NaN for top-level)
reply_count int Replies received (within collection window)

Note on comment_id duplicates: Markets sharing a Polymarket Series pool share the same comment thread. The script collects comments for each market with its own time window, so the same comment_id may appear with different market_id values. Deduplicate by comment_id for unique-comment analysis.


2.3 Cleaning

Script: polymarket_data/clean_comments.py

Step Operation Effect
1 Drop category column 100% missing (Gamma API does not expose this field)
2 Strip whitespace from question; remove markets where question is empty/"nan" Data integrity
3 Remove markets with < 10 valid comments Minimum discussion threshold
4 Reorder columns to reference schema order Consistency

Run summary (from run.log):

  • Input: 2,469 markets from valid_topics_summary.csv
  • Completed: 2,070 / Skipped: 399 / Failed: 0
  • Runtime: ~9.7 hours

3. Manifold Dataset

3.1 Topic Collection

Script: get_manifold_topics.py Output: manifold_data/valid_markets.jsonl, manifold_data/valid_markets_summary.csv

Pipeline

GET api.manifold.markets/v0/search-markets
  └─ params: filter=resolved, contractType=BINARY, sort=liquidity
  └─ paginate with offset (100 per page, up to MAX_PAGES=5000)
  └─ per market apply filters:
       volume   ≥ 10,000 M$ (Mana)
       bettors  ≥ 50
       lastCommentTime is not None
  └─ classify category by keyword matching (same keyword dict as Polymarket)
  └─ NOTE: comment-count filter deferred to cleaning step

Key Parameters

Parameter Value Description
MIN_VOLUME_MANA 10,000 Minimum Mana (M$) trading volume
MIN_BETTORS 50 Minimum unique bettors
PAGE_LIMIT 100 Markets per API request
BASE_SLEEP 0.15 s Inter-request delay (Manifold limit: 500 req/min)

Currency note: Manifold uses virtual currency Mana (M$), not real USD. volume and position_size are not directly comparable to Polymarket figures.


3.2 Comment Collection

Script: get_manifold_comments.py Input: manifold_data/valid_markets.jsonl Output: manifold_data/comments.csv

Pipeline

For each market (resolution = YES or NO only):
  1. GET api.manifold.markets/v0/comments
       └─ params: contractId=<id>, limit=1000
       └─ cursor-based pagination (before=<last_id>)
       └─ extract plain text from ProseMirror JSON (recursive content node walk)
       └─ filter: created_at ∈ [market.created_time, market.resolution_time]

  2. For each unique commenter's userId (parallel, 8 threads):
       GET /v0/bets?contractId=<id>&userId=<uid>
         └─ cursor-based pagination
         └─ reconstruct position at comment time:
              net_mana[YES] = Σ amount for YES bets before comment_ts
              net_mana[NO]  = Σ amount for NO bets before comment_ts
              position_side = dominant side (or None if both ≤ 0)
         └─ prob_at_comment = probAfter of last bet before comment_ts

  3. Append rows to comments.csv (resumable via progress.json)

Key Differences from Polymarket

Aspect Polymarket Manifold
Position currency USD (real money) Mana (virtual currency)
Position source Dedicated activity API per user Bet records reconstructed per user
Market probability Dedicated /prices-history endpoint Interpolated from probAfter in bet records
Text format Plain text ProseMirror JSON → recursively extracted
Reply count Provided by API Not in API; back-calculated from replyToCommentId
Resolution ground truth Not in API YES / NO in market metadata

Collection Filters

Filter Value
MIN_COMMENT_LENGTH 3 chars
MIN_COMMENTS_PER_MARKET 10
Resolution filter Only YES / NO markets (excludes MKT, CANCEL, N/A)
Lifecycle filter Comments outside [created_time, resolution_time] dropped

Output Schema (raw comments.csv)

Field Type Description
market_id str Manifold market ID
slug str URL slug
question str Market question
outcome_type str Always BINARY
category str Keyword-classified category
resolution str YES / NO (ground truth)
comment_id str Unique comment ID
created_at ISO8601 Comment timestamp (UTC, ms precision)
text str Extracted plain text
user_id str Manifold user ID
user_name str Username
position_side str YES / NO / empty
position_mana float Net Mana invested at comment time
position_shares float Net shares held at comment time
prob_at_comment float Market probability snapshot at comment time
likes int Like count
parent_comment_id str Parent comment ID (NaN for top-level)
reply_count str Empty (back-calculated during cleaning)

3.3 Cleaning

Script: manifold_data/clean_comments.py

Step Operation Effect
1 Back-calculate reply_count from parent_comment_id value counts API does not provide reply_count
2 Rename columns to align with Polymarket schema user_id→user_address, user_name→pseudonym, position_mana→position_size, likes→reaction_count
3 Drop markets where question is empty/"nan" Data integrity
4 Remove markets with < 100 valid comments Ensures sufficient discussion depth per market for NLP tasks
5 Reorder columns (retain Manifold-specific fields: outcome_type, resolution, prob_at_comment) Schema alignment

Threshold change: The minimum comments per market was raised from 10 to 100 to retain only well-discussed markets with sufficient context for sentiment analysis. This reduces market count from ~2,926 to 191 but increases average comment depth from 21 to 163 per market.


4. Schema Comparison

Field Polymarket Manifold Notes
market_id ✓ ✓ Different ID systems (numeric vs. alphanumeric)
slug ✓ ✓
question ✓ ✓
condition_id ✓ — On-chain condition (Polymarket only)
outcome_type — ✓ Always BINARY (Manifold only)
category_validated / category ✓ ✓ Same keyword logic; different field names
resolution — ✓ YES/NO ground truth (Manifold only)
market_start_time ✓ —
market_end_time ✓ —
parent_entity_type_used ✓ — API fallback tracking (Polymarket only)
comment_id ✓ (may repeat) ✓ (unique)
created_at ✓ ✓ ISO8601 UTC
text ✓ ✓
pseudonym ✓ ✓ (renamed from user_name)
user_address ✓ ✓ (renamed from user_id)
proxy_wallet ✓ — Polymarket on-chain proxy
position_side Yes/No/team YES/NO Format differs; Polymarket has 73 distinct values
position_size USD (can be negative) Mana M$ Not directly comparable
position_shares ✓ ✓
prob_at_comment — ✓ Market probability snapshot (Manifold only)
reactions JSON str — Raw reactions (Polymarket only)
reaction_count ✓ ✓ (renamed from likes); Polymarket occasionally −1
report_count ✓ —
parent_comment_id ✓ ✓
reply_count ✓ ✓ Back-calculated for Manifold

5. Descriptive Statistics

Analysis scripts: data/analysis/descriptive_stats.py and data/analysis/plot_stats.py Run from data/ directory: python analysis/descriptive_stats.py


5.1 Basic Scale

Metric Polymarket Manifold
Total comments (cleaned) 514,314 46,562
Unique comment_id (deduplicated) 266,446 46,562
Unique markets 2,070 191
Unique users 24,909 3,250
Fields per row 23 18
Date range 2024-05-02 → 2026-03-12 2022-01-14 → 2026-03-07
Time span ~22 months ~50 months

Polymarket duplicate rows: 48.2% of rows share a comment_id with another row (same comment collected under different market_id for markets sharing a Series comment pool). Deduplicate with df.drop_duplicates(subset='comment_id', keep='first') before unique-comment analyses.


5.2 Market Coverage

Comments per Market

Statistic Polymarket Manifold
Count (markets) 2,070 191
Mean 248.5 243.8
Std 1,284.1 197.1
Min 10 100
25th pct 41 126
Median 70 163
75th pct 127 275
Max 25,049 990

Market Depth Brackets (Polymarket)

Threshold Markets Share
≥ 10 comments 2,070 100%
≥ 50 comments 1,363 65.8%
≥ 100 comments 692 33.4%
≥ 200 comments 259 12.5%

Top 10 Markets by Comment Count

Polymarket:

Rank Market ID Comments Question
1 519075 25,049 Will Hunor Kelemen win the Romanian presidential election?
2 516767 22,444 Will Pierre Poilievre be the next Canadian Prime Minister?
3 514139 19,284 Will Rafał Trzaskowski be the next President of Poland?
4 253591 17,034 Will Donald Trump win the 2024 US Presidential Election?
5 546814 16,326 Will Zelenskyy wear a suit before July?
6 506968 14,810 Will Israel invade Syria in 2024?
7 507276 12,949 TikTok banned in the US before May 2025?
8 532741 11,074 US military action against Iran before July?
9 551650 11,037 US military action against Iran before August?
10 552650 9,331 Fordow nuclear facility destroyed before July?

Manifold:

Rank Market ID Comments Question
1 l2Pci4rwD2S50eFGZiCj 990 Is the probability of dying in the Snake Eyes Paradox 1/36?
2 1sfbjcTu6zgqjCVjqWA2 961 Will LK-99 room-temperature superconductivity be confirmed?
3 7RZ7CnNVPKOGSh3v5pnn 933 Will @firstuserhere walk 100,000 steps in a day before 2023?
4 d1t4k3nz3t 927 Will Trump win the 2024 Election?
5 gPA029Rcyh 919 Will Manifold solve my puzzle?
6 YTIuuSsNRn2OlA4KykRM 918 Will Biden be the 2024 Democratic Nominee?
7 U3zLgOZkGUE7cvG98961 891 Whales vs. Minnows: Will traders hold at least 10000x as many shares?
8 0EVOQyEBz624ooYpOCfc 844 Hamas command center under al-Shifa Hospital?
9 PXd5l5qBVArJrSYZhivM 808 Will Tumbles be late to pay back a loan?
10 NRLwgQYqCLk5zTasmxOn 762 Will the average percentage of this market be above 50%?

Polymarket: parent_entity_type Distribution

Type Comments Share
Series 323,082 62.8%
Event 191,232 37.2%

Series markets (comment pool shared across multiple related markets) account for 62.8% of all rows and are the primary source of comment_id duplication.


5.3 Comment Text Analysis

Text Length (characters)

Statistic Polymarket Manifold
Mean 69.4 208.5
Std 87.9 347.5
Min 2 3
25th pct 22 49
Median 44 107
75th pct 85 230
90th pct ~160 ~470
Max 1,492 9,132

Manifold comments are ~2.4× longer on average (median 107 vs. 44 chars). This reflects Manifold's community culture of extended argumentative discussion, compared to Polymarket's shorter reaction-style comments.

Text Length Brackets

Bracket Polymarket Manifold
< 20 chars ~124,000 (24.1%) ~5,600 (12.0%)
20–100 chars ~243,000 (47.3%) ~14,900 (32.0%)
> 100 chars ~147,000 (28.6%) ~26,100 (56.1%)

Polymarket MIN_COMMENT_LENGTH=3 (not the Guide-recommended 20). For downstream tasks requiring substantive text, apply len(text) > 20 post-hoc filter.


5.4 Position (Stake) Data

Position data links each comment to the commenter's financial stake at the time of writing — a key feature for the Polymarket Sentiment Analysis (PSA) task.

Coverage Summary

Metric Polymarket Manifold
Comments with position_side 155,205 (30.2%) 37,497 (80.5%)
Comments with position_size > 0 139,848 (27.2%) 37,430 (80.4%)
Comments with position_size < 0 15,336 (3.0%) 0
No position (NaN) 359,109 (69.8%) 9,065 (19.5%)

Manifold's much higher position coverage (80.5%) reflects the fact that Manifold users generally bet before commenting, whereas many Polymarket users comment without holding a position. The >= 100 market filter further concentrates well-engaged markets.

Position Side Distribution

Value Polymarket Polymarket % Manifold Manifold %
Yes / YES 77,062 15.0% 19,258 41.4%
No / NO 63,760 12.4% 18,239 39.2%
Team / other names ~14,383 2.8% — —
No position (NaN) 359,109 69.8% 9,065 19.5%

Polymarket position_side has 73 distinct values: Yes/No (90.8% of positioned comments), Up/Down (crypto markets), and team names (NBA/MLB sports markets).

Position Size Distribution (comments with size > 0)

Statistic Polymarket (USD) Manifold (Mana M$)
Count 139,848 37,430
Mean $3,164 M$24,408
Std $22,472 M$182,496
25th pct $45.7 M$123
Median $242 M$949
75th pct $1,174 M$6,000
Max $2,956,218 M$4,404,784

Polymarket position_size < 0 (15,336 rows): Legitimate data — occurs when a user's total SELL proceeds exceed BUY costs (i.e., trading profit; the user remains in a net-long position as position_shares > 0). Do not remove; add is_profit_state flag for downstream handling.

Position Size Tier Breakdown (Polymarket, > 0 only)

Tier Range (USD) Count % of positioned
Retail < $100 52,259 37.4%
Small $100–$500 35,042 25.1%
Medium $500–$1,000 14,162 10.1%
Large $1,000–$5,000 23,865 17.1%
XLarge $5,000–$10,000 6,315 4.5%
Whale $10,000–$50,000 6,732 4.8%
Mega > $50,000 1,473 1.1%

Position Size Tier Breakdown (Manifold, > 0 only)

Tier Range (M$) Count % of positioned
Retail < M$100 8,621 23.0%
Small M$100–500 7,191 19.2%
Medium M$500–1,000 3,480 9.3%
Large M$1,000–5,000 7,981 21.3%
XLarge M$5,000–10,000 3,008 8.0%
Whale M$10,000–50,000 4,944 13.2%
Mega > M$50,000 2,205 5.9%

5.5 Reply Structure

Metric Polymarket Manifold
Is a reply (has parent_comment_id) 259,226 (50.4%) 33,020 (70.9%)
Has received replies (reply_count > 0) 101,081 (19.7%) 7,217 (15.5%)
reply_count mean 0.46 0.55
reply_count max 152 78

Manifold's very high reply rate (70.9%) reflects its forum-style discussion culture. Note that reply_count is locally computed (within the collection window), not the API's authoritative total.


5.6 Engagement (Reactions/Likes)

Metric Polymarket (reaction_count) Manifold (reaction_count / likes)
Mean 1.06 1.72
Median 0 1
75th pct 1 2
Max 160 81
With ≥ 1 reaction 230,329 (44.8%) —
With ≥ 5 reactions 26,329 (5.1%) —
reaction_count = −1 (API anomaly) 42 0

Polymarket reaction_count = −1 (42 rows) is an API-side bug; replace with 0 during downstream cleaning.


5.7 User Behavior

Activity Distribution

Statistic Polymarket Manifold
Unique users 24,909 3,250
Mean comments/user 20.6 14.3
Median comments/user 3 2
75th pct 10 9
Max 6,054 1,194

Both platforms show a long-tail distribution. The most active Polymarket user posted 6,054 comments (vs. 279,347 in the earlier v0312 dataset), indicating the v2 collection script substantially reduced bot-like behavior.

Top 5 Most Active Users

Polymarket (by ETH address prefix):

Rank user_address Comments
1 0x6e26a51e... 6,054
2 0x5cc591f9... 5,844
3 0xf3a34b19... 4,748
4 0x238b427f... 4,664
5 0x4711c314... 4,473

Manifold (by user ID prefix):

Rank user_address Comments
1 4JuXgDx47x... 1,194
2 y1hb6k7txd... 762
3 zgCIqq8AmR... 757
4 sCOvPc5J2s... 698
5 uIA81X2m3a... 653

5.8 Temporal Distribution

Monthly Comment Volume

Polymarket (2024-05 to 2026-03):

Month Comments Note
2024-05 9 Platform cold-start
2024-08 372
2024-10 9,485 Pre-election ramp-up
2024-11 25,143 US election
2024-12 48,980 Post-election activity
2025-01 46,020
2025-04 43,632
2025-06 123,040 Peak (Iran/nuclear crisis markets)
2025-07 53,050
2025-08 15,425
2025-11 407 Sharp drop in market activity
2025-12 6,739
2026-01–03 ~224 Tail (incomplete months)

Manifold (2022-01 to 2026-03):

Period Comments Note
2022-01–10 < 500/month Early platform growth
2022-11 1,165 Growth inflection
2023-01–12 1,350–3,089/month Steady growth phase
2023-12 3,089 Peak year for 2023
2024-07 2,603 Election season
2024-11 1,456 US election
2025-05 1,575
2026-01–03 654–102 Recent (within-collection)

5.9 Category Distribution

Polymarket

Category Comments Share (of all) Share (deduplicated)
politics 99,858 19.4% 36.3%
crypto 50,508 9.8% 9.0%
economics 13,486 2.6% 2.8%
sports 5,500 1.1% 0.4%
NaN / other 345,062 67.1% 51.6%

category_validated is keyword-matched; 67.1% of rows (51.6% deduplicated) fall outside the five defined categories. The high NaN rate reflects question phrasings that don't match any keyword.

Manifold

Category Comments Share
other 30,875 66.3%
politics 6,252 13.4%
technology 3,759 8.1%
crypto 3,758 8.1%
sports 1,174 2.5%
economics 744 1.6%

Manifold category is assigned at collection time; other dominates because many Manifold questions are platform-community or science/culture topics not covered by the five keyword sets.


5.10 Manifold-Specific: Resolution & Probability

Market Resolution

Resolution Comments Share
YES 25,009 53.7%
NO 21,553 46.3%

A near-balanced YES/NO split avoids class imbalance issues for binary prediction tasks.

Market Probability at Comment Time (prob_at_comment)

Metric Value
Coverage 40,914 / 46,562 (87.9%)
Mean 0.506
Median ~0.5
Std —

The mean probability of ~0.5 indicates comments are distributed across the full lifecycle of markets, not concentrated near resolution (when probability collapses to 0 or 1).


5.11 Cross-Platform Comparison

Metric Polymarket Manifold
Total comments 514,314 46,562
Unique markets 2,070 191
Unique users 24,909 3,250
Median text length 44 chars 107 chars
Median comments/market 70 163
Position coverage 30.2% 80.5%
Reply rate (has parent) 50.4% 70.9%
Reaction mean 1.06 1.72
Ground-truth resolution ✗ ✓
Market probability ✗ ✓ (87.9% coverage)
Currency Real USD Virtual Mana

Key trade-offs:

  • Polymarket: larger scale (11× more comments, 11× more markets), real financial stakes, but lower position coverage and no built-in resolution ground truth.
  • Manifold: smaller but higher-depth markets (min 100 comments), near-complete position data (80.5%), resolution ground truth, and market probability snapshots; however, Mana is virtual currency, limiting financial signal interpretation.

6. Raw Files and Scripts

The raw outputs named in §2–§3 (valid_topics.jsonl, valid_markets.jsonl, comments.csv, user_positions.csv) are released unmodified in the raw/ folder of this dataset; raw/README.md gives their row counts, columns and the exact steps that produce the *_clean.csv files. The collection scripts (get_*_topics.py, get_*_comments.py, get_*_position.py, get_*_data.py) and the cleaning scripts (clean_comments.py, clean_positions.py) are in the code repository under collection/: https://github.com/PEIYUNHUA/stakebench_code_NeurIPS26.

Note on the released polymarket/comments_clean.csv: it is GB18030-encoded and 32 rows shorter than the raw crawl output; the raw file is UTF-8. See raw/README.md (Encoding note).


Generated: 2026-03-18