This project fetches real-time stock prices and news headlines, performs sentiment analysis, and visualizes the results.
- Fetch real-time stock prices using yfinance
- Fetch news headlines using NewsAPI
- Sentiment analysis combining TextBlob and VADER (NLTK), falling back to VADER when the two disagree strongly
- Interactive dashboard with Streamlit
- Sample data mode for trying the app without API keys or a network connection
- Dockerized for easy deployment
- CI pipeline with GitHub Actions (black, flake8)
- Sentiment Summary: Displays a bar chart of positive, negative, and neutral news counts for quick insights.
- Create a
.envfile in the project root and add your NewsAPI key (only needed for Real-Time mode):
NEWS_API_KEY=your_news_api_key_here
- Install dependencies:
pip install -r requirements.txt - Run app:
streamlit run src/app.py - Select between Real-Time or Sample Data mode.
- Real-Time fetches live stock prices (yfinance) and news (NewsAPI) for the ticker you enter.
- Sample Data uses the bundled
data/sample_stock.csvfor stock prices and still fetches live news, so it works without a NewsAPI key.
- Enter stock ticker in the app and click Fetch Data.
- Or run with Docker:
docker build -t stock-sentiment-app .
docker run -p 8501:8501 --env-file .env stock-sentiment-app
src/- Source codeapp.py- Streamlit entry pointfetch_stock.py- Stock price retrieval via yfinancefetch_news.py- News retrieval via NewsAPIsentiment.py- TextBlob/VADER sentiment analysisvisualization.py- Chart rendering
data/- Sample historical CSV used by Sample Data modeDockerfile- Container setup.github/workflows/- CI pipelinerequirements.txt- DependenciesREADME.md- Project overview