An AI-powered stock prediction system that analyzes news sentiment, market momentum, and volatility to generate a Buy / Hold / Sell recommendation for any company.
This system uses:
- FastAPI (backend)
- Streamlit (frontend)
- FinBERT (sentiment analysis)
- yfinance (market data)
- Newspaper3k + RSS (news ingestion)
- Scrapes recent news articles from Google News RSS & APIs
- Extracts full article text using Newspaper3k
- Predicts positive / neutral / negative sentiment
- Computes average sentiment of all news
- Fetches price history using yfinance
- Computes:
- 5-day momentum
- 20-day momentum
- Volatility
- Current price
Combines:
0.6 * sentiment + 0.3 * momentum - 0.1 * volatility
Outputs a final decision:
- BUY
- HOLD
- SELL
- Enter company + ticker
- Displays decision, features, signals, sentiment
- Clean, interactive interface
User → Streamlit UI → FastAPI Backend →
→ News Ingestion
→ Sentiment Analysis (FinBERT)
→ Market Signals (yfinance)
→ Recommendation Engine
→ Response → Streamlit Dashboard
Stock-prediction/
│
├── backend/
│ ├── main.py
│ ├── src/
│ │ ├── data_ingestion/
│ │ ├── sentiment_alz/
│ │ ├── market_data/
│ │ └── recommendation/
│ └── venv/
│
├── frontend/
│ └── streamlit_app.py
│
└── README.md
python3 -m venv venv
source venv/bin/activatepip install fastapi uvicorn transformers torch yfinance feedparser newspaper3kuvicorn main:app --reloadBackend runs on:
http://127.0.0.1:8000
Install Streamlit:
pip install streamlit plotly pandasRun the Streamlit UI:
streamlit run streamlit_app.pyOpens at:
http://localhost:8501
{
"company": "Apple",
"ticker": "AAPL"
}{
"company": "Apple",
"ticker": "AAPL",
"decision": "HOLD",
"features": {
"score": 0.0116,
"avg_sentiment": 0.035,
"momentum_5d": -0.028,
"volatility": 0.009
},
"market_signals": {
"price": 267.44,
"momentum_5d": -0.028,
"momentum_20d": 0.018,
"volatility": 0.009
},
"articles_used": 46
}- ML prediction using Scikit-Learn or XGBoost
- Backtesting engine (historical accuracy)
- Article preview section in Streamlit
- Stock price charts
- Redis caching
- Cloud deployment (AWS / Render / Railway)
This project is licensed under the MIT License.
Pull requests are welcome! Improve ingestion, sentiment accuracy, or UI dashboards.