Aggregates social media sentiment to generate probability estimates for prediction market outcomes.
Prediction markets allow trading on future events (elections, sports, crypto prices, etc.). Social media contains valuable signals about these events - people share opinions, analysis, and predictions. This project:
- Collects relevant social media posts for prediction market events
- Filters posts by relevancy using LLMs (OpenAI + Claude)
- Extracts probability estimates from each post's sentiment
- Weights posts by author credibility and engagement
- Aggregates into final probability distributions for each market outcome
The goal is to turn unstructured social media discussion into structured probability estimates that can inform trading decisions or be compared against market prices.
pip install -r requirements.txtTWITTER_API_KEY=
OPENAI_API_KEY=
CLAUDE_API_KEY=
DATABASE_URL=
Edit config.toml:
[search]
query_type = "Top" # "Latest" or "Top"
max_pages = 10
parallel_requests = 10
[look_back]
year = 2026
month = 1python run_topics.pyThis runs for each topic:
search_tweets.py- Search tweetspredict_relevancy.py- Score relevancy using OpenAI + Claudepredict_sentiment.py- Predict outcome probabilities (posts with relevancy > 0.5)weight_posts.py- Calculate post weights
Then inserts results to database.
# Search tweets for a topic
python search_tweets.py <topic_slug>
# Predict relevancy
python predict_relevancy.py <topic_slug>
# Predict sentiment
python predict_sentiment.py <topic_slug>
# Weight posts
python weight_posts.py <topic_slug>
# Insert to database
python insert_topics.py
python insert_posts.pyTopics are defined in raw/*_topics.json files. Each topic has:
slug- Unique identifierdescription- Event descriptionmarkets- Available outcomesquery- Twitter search query