Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Musk Tweet → Tesla Signal Pipeline

Minimal skeleton for testing: "Does LLM-scored Musk tweet sentiment predict weekly TSLA returns?"

Data Sources (Minimal)

Data Source Notes
Tweets Kaggle: Elon Musk Tweets 2010-2021 13K tweets, free download
Kaggle: Elon Musk Tweets (updated) More recent, ~50K tweets
Prices yfinance Auto-fetched, no setup needed

Quick Start

# 1. Install dependencies
pip install -r requirements.txt

# 2. Validate pipeline logic with synthetic data
python test_synthetic.py

# 3. Download tweet data from Kaggle, place in ./data/elonmusk_tweets.csv

# 4. Set your Anthropic API key
export ANTHROPIC_API_KEY=sk-ant-...

# 5. Run real backtest
python pipeline.py

What Gets Tested

  1. Correlation: Does weekly sentiment score correlate with next week's return?
  2. Directional accuracy: Does positive sentiment → positive return (>50% = better than random)
  3. Quintile spread: Do high-sentiment weeks outperform low-sentiment weeks?
  4. Strategy vs buy-hold: Does trading on signal beat holding?

Expected Runtime

  • Synthetic test: instant
  • Real data (5000 tweets): ~30 min for LLM scoring (cached after first run)
  • Subsequent runs: seconds (uses cache)

File Structure

musk_signal/
├── pipeline.py          # Main pipeline
├── test_synthetic.py    # Validates logic with fake data
├── requirements.txt
├── README.md
└── data/
    ├── elonmusk_tweets.csv   # You provide this
    ├── scored_tweets.json    # Generated (LLM score cache)
    └── backtest_results.csv  # Generated (final output)

Extending to Other CEOs

The hypothesis is this works for volatile/high-profile executives. To test others:

  1. Find tweet archive (or scrape with appropriate tools)
  2. Change TWEET_FILE and ticker in load_prices()
  3. Potentially adjust SCORING_PROMPT to mention the relevant company

Candidates: Chamath Palihapitiya, Michael Saylor, Ryan Cohen, etc.

About

hal-bot is the bot training LLMs off of tweets/socials for stock predictions

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages