A Reddit-based sentiment analysis tool for stock investment recommendations.
This tool collects stock mentions from Reddit, analyzes sentiment, and provides BUY/SELL/HOLD recommendations based on community sentiment.
- Data Collection: Scrapes stock mentions from Reddit (r/WallStreetBets)
- Sentiment Analysis: Analyzes sentiment of mentions using keyword-based scoring
- Investment Recommendations: Provides BUY/SELL/HOLD advice based on sentiment thresholds
- CLI Tools: Easy-to-use command line interfaces for data collection and analysis
pip3 install -r requirements.txt- Go to https://www.reddit.com/prefs/apps
- Create a new "script" application
- Copy
.env.exampleto.env:cp .env.example .env
- Edit
.envwith your Reddit API credentials:CLIENT_ID="your_reddit_client_id" CLIENT_SECRET="your_reddit_client_secret" USER_AGENT="script:advisor-sentiment:v1.0 (by /u/your_username)"
python3 run_assistant.pyThis will:
- Connect to Reddit API
- Scan r/WallStreetBets for stock mentions (AAPL, TSLA, GOOG)
- Store mentions in local SQLite database
python3 run_advisor.pyThis will:
- Analyze sentiment of all collected mentions
- Provide BUY/SELL/HOLD recommendations
- Show sentiment scores and mention counts
# Collect data from Reddit (default)
python3 run_assistant.py
# Specify source explicitly
python3 run_assistant.py --source reddit
# Use custom config file
python3 run_assistant.py --config my_config.json# Analyze all tracked stocks
python3 run_advisor.py
# Analyze specific stocks
python3 run_advisor.py --stocks AAPL TSLA
# Get detailed analysis for one stock
python3 run_advisor.py --detail AAPLEdit advisor/scrapers/reddit/config.json to change tracked stocks:
{
"max_days": 3,
"min_days": 1,
"subreddits": ["WallStreetBets"],
"tickers": ["AAPL", "TSLA", "GOOG", "MSFT"]
}Recommendation logic (configured in advisor/core/config.py):
- BUY: Sentiment ≥ 0.7 with ≥5 mentions
- SELL: Sentiment ≤ 0.3 with ≥5 mentions
- HOLD: Otherwise (neutral sentiment or insufficient data)
advisor/
├── core/ # Core functionality
│ ├── config.py # Configuration management
│ ├── database.py # SQLite operations
│ └── data_source.py # Base scraper class
├── scrapers/ # Data collection
│ └── reddit/ # Reddit scraper
├── analysis/ # Sentiment analysis
│ └── sentiment.py
└── cli/ # Command line interfaces
├── assistant.py # Data collection CLI
└── advisor.py # Analysis CLI
The tool uses SQLite with two main tables:
stocks: Stock symbols being trackedmentions: Individual Reddit mentions with sentiment scores
Database file: advisor.db (created automatically)
- API credentials are stored in
.envfile (not committed to git) - No sensitive data is logged or exposed
- All database queries use parameterized statements
- Create new scraper in
advisor/scrapers/ - Inherit from
DataSourcebase class - Implement required methods
- Add to assistant CLI
The current implementation uses keyword-based sentiment analysis. To integrate with LLM APIs:
- Add API credentials to
.env - Modify
SentimentAnalyzer.analyze_text()method - Replace keyword logic with API calls
This project is for educational purposes. Ensure compliance with Reddit's API terms and rate limits.