Skip to content

VishvakR/MarketSense-AI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Stock Prediction System — News + Market Analysis (FastAPI + Streamlit)

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)

Features

✔ News Ingestion

  • Scrapes recent news articles from Google News RSS & APIs
  • Extracts full article text using Newspaper3k

✔ Sentiment Analysis (FinBERT)

  • Predicts positive / neutral / negative sentiment
  • Computes average sentiment of all news

✔ Market Data Processing

  • Fetches price history using yfinance
  • Computes:
    • 5-day momentum
    • 20-day momentum
    • Volatility
    • Current price

✔ Recommendation Engine

Combines:

0.6 * sentiment + 0.3 * momentum - 0.1 * volatility

Outputs a final decision:

  • BUY
  • HOLD
  • SELL

✔ Frontend Dashboard (Streamlit)

  • Enter company + ticker
  • Displays decision, features, signals, sentiment
  • Clean, interactive interface

Project Architecture

User → Streamlit UI → FastAPI Backend →  
   → News Ingestion  
   → Sentiment Analysis (FinBERT)  
   → Market Signals (yfinance)  
   → Recommendation Engine  
→ Response → Streamlit Dashboard

Folder Structure

Stock-prediction/
│
├── backend/
│   ├── main.py
│   ├── src/
│   │   ├── data_ingestion/
│   │   ├── sentiment_alz/
│   │   ├── market_data/
│   │   └── recommendation/
│   └── venv/
│
├── frontend/
│   └── streamlit_app.py
│
└── README.md

Backend Setup (FastAPI)

Create virtual environment:

python3 -m venv venv
source venv/bin/activate

Install dependencies:

pip install fastapi uvicorn transformers torch yfinance feedparser newspaper3k

Run FastAPI:

uvicorn main:app --reload

Backend runs on:

http://127.0.0.1:8000

Frontend Setup (Streamlit)

Install Streamlit:

pip install streamlit plotly pandas

Run the Streamlit UI:

streamlit run streamlit_app.py

Opens at:

http://localhost:8501

API Example

POST /predict

Request:

{
  "company": "Apple",
  "ticker": "AAPL"
}

Response:

{
  "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
}

Future Improvements

  • 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)

License

This project is licensed under the MIT License.


Contributing

Pull requests are welcome! Improve ingestion, sentiment accuracy, or UI dashboards.

About

An AI-powered stock prediction system that analyzes real-time news sentiment and market data to generate Buy/Hold/Sell recommendations. Uses FastAPI backend, FinBERT sentiment analysis, yfinance signals, and a Streamlit dashboard for interactive insights.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors