This project is a pipeline that fetches historical stock data, extracts sentiment from Wikipedia content related to selected companies, and trains a logistic regression model to predict stock movement direction based on sentiment. It also includes a user-friendly Streamlit interface for interaction and visualization.
- ✅ Fetches and updates historical stock data daily using Yahoo Finance
- ✅ Extracts Wikipedia summaries for major tech companies
- ✅ Performs sentiment analysis using VADER on the Wikipedia content
- ✅ Builds a dataset linking sentiment scores to stock price movements
- ✅ Trains a Logistic Regression model to predict upward or downward price movement
- ✅ Saves trained model using
joblib - ✅ Provides a responsive web UI via Streamlit
- ✅ Automatically runs the update pipeline every day at 6 PM
- 🔄 Future scope: pattern-based predictions from stock graphs
GSOC/
├── main.py # Main pipeline script (data + training)
├── app.py # Streamlit app for UI
├── sentiment_stock_model.joblib # Trained ML model
├── stock_data.csv # Historical stock data
├── wiki_sentiment.csv # Sentiment + direction dataset
├── schedule_task.bat # Scheduler script for Windows (optional)
├── README.md # You are here!
Install the required packages using:
pip install -r requirements.txtSample requirements.txt:
pandas
yfinance
wikipedia
scikit-learn
vaderSentiment
joblib
streamlit
Downloads daily stock data for the tickers:
["TSLA", "GOOGL", "AAPL", "AMZN", "MSFT"]Using Yahoo Finance (yfinance) and stores in stock_data.csv.
For each company, fetches up to 3000 characters from its Wikipedia summary and runs VADER sentiment analysis. Example:
- Ticker:
TSLA - Sentiment Score:
0.63
Builds a dataset with:
- Date
- Ticker
- Sentiment Score
- Direction (1 if Close > Open, else 0)
Then trains a Logistic Regression model using scikit-learn.
streamlit run app.pyFeatures:
- Button to run the full pipeline (update → sentiment → train)
- Shows success messages and logs
- Ready to integrate graphs, predictions, and more!
A scheduled task runs main.py every day at 6 PM.
You can use:
schedulemodule for Python automationcron(Linux/macOS)Task Scheduler(Windows with.batfile)
- 📈 Graph-based pattern recognition and predictions
- 📉 Compare sentiment predictions with actual market movement
- 📊 Visual analytics dashboard in Streamlit
- 🌐 Optional API support for integrating external sources (e.g., GDELT, NewsAPI)
Debajeet Mandal
Google Summer of Code 2025 Contributor
This project is open-sourced under the MIT License.