Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

1 Commit
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“Š SentimentSignal - Social-Driven Market Intelligence

Professional sentiment analysis dashboard for retail investors

SentimentSignal is a sleek, AI-powered trading dashboard that analyzes market sentiment from news sources and generates actionable trading signals for NIFTY 50 stocks. Built with Flask, transformers (FinBERT & RoBERTa), and a premium dark-mode frontend.


โœจ Features

๐Ÿง  AI-Powered Sentiment Analysis

  • Dual-Model Approach: Combines FinBERT (financial news) and RoBERTa (social context) for accurate sentiment scoring
  • Real-Time News Aggregation: Fetches historical news from Google News RSS
  • Sentiment Scoring: Classifies sentiment as Positive, Neutral, or Negative with confidence metrics

๐Ÿ“ˆ Interactive Visualizations

  • Sentiment vs Price Chart: Overlay sentiment trends on stock price movements
  • Buy/Sell Signal Markers: Visual indicators for trading signals
  • Time Range Selection: Analyze 1M, 3M, or 6M periods

๐Ÿ”ฌ Backtesting Engine

  • Strategy Comparison: AI Sentiment Strategy vs Buy & Hold
  • Performance Metrics: Returns, Alpha, Max Drawdown, Win Rate
  • Historical Validation: Correlate sentiment with actual price movements

๐Ÿ’น Top Signal Drivers

  • News Impact Analysis: Identify headlines that moved the market
  • Sentiment Attribution: See which news drove positive/negative sentiment
  • Source Tracking: Know where the signal originated

๐ŸŽจ Premium UI/UX

  • Dark Mode First: Professional trading terminal aesthetic
  • Glassmorphism Design: Modern, sleek panels with backdrop blur
  • Neon Accents: Color-coded signals (Green=Buy, Red=Sell, Amber=Hold)
  • Smooth Animations: Micro-interactions for premium feel
  • Fully Responsive: Works on desktop, tablet, and mobile

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.8+
  • pip (Python package manager)
  • Modern web browser (Chrome, Firefox, Edge)

Installation

  1. Clone or navigate to the project directory

    cd "C:\Users\Mamta Sharma\Downloads\Sentimental"
  2. Install Python dependencies

    pip install -r requirements.txt

    This will install:

    • Flask & Flask-CORS (API server)
    • transformers & torch (ML models)
    • pandas, numpy (data processing)
    • yfinance (stock data)
    • feedparser (news aggregation)
  3. Start the Flask API server

    python app.py

    Note: First startup will take 10-30 seconds to load ML models (FinBERT & RoBERTa). You'll see:

    Loading sentiment models...
    Models loaded successfully!
    ๐Ÿš€ SentimentSignal API Server
    ๐Ÿ“ Server running at: http://localhost:5000
    
  4. Open the frontend

    • Open index.html in your web browser
    • Or use a local server:
      python -m http.server 8000
      Then visit: http://localhost:8000

๐Ÿ“– Usage

Analyzing a Stock

  1. Enter Stock Ticker

    • Type a NIFTY 50 ticker in the search bar (e.g., TCS.NS, RELIANCE.NS, INFY.NS)
    • Use the autocomplete suggestions for common stocks
  2. Select Time Range

    • Choose 1M, 3M, or 6M analysis period
    • Default is 3 months (90 days)
  3. Click "Analyze"

    • The system will:
      • Fetch historical news articles
      • Analyze sentiment using AI models
      • Generate trading signals
      • Run backtesting simulation
      • Display comprehensive results
  4. Review Results

    • Sentiment Overview: Current sentiment score and BUY/HOLD/SELL signal
    • Chart: Sentiment trend overlayed on price movement
    • Top Drivers: News headlines that influenced sentiment
    • Backtest Results: Strategy performance vs benchmark
    • Strategy Summary: Plain-English explanation

Supported Stock Tickers

NIFTY 50 Examples:

  • TCS.NS - Tata Consultancy Services
  • INFY.NS - Infosys
  • RELIANCE.NS - Reliance Industries
  • HDFCBANK.NS - HDFC Bank
  • ICICIBANK.NS - ICICI Bank
  • TATASTEEL.NS - Tata Steel
  • WIPRO.NS - Wipro
  • SBIN.NS - State Bank of India
  • And more...

Format: SYMBOL.NS (for NSE) or SYMBOL.BO (for BSE)


๐Ÿ—๏ธ Architecture

Backend (app.py)

  • Framework: Flask REST API
  • ML Models:
    • FinBERT (ProsusAI/finbert) - Financial sentiment
    • RoBERTa (cardiffnlp/twitter-roberta-base-sentiment-latest) - Social nuance
  • Data Sources:
    • Google News RSS (news aggregation)
    • Yahoo Finance (stock prices via yfinance)

Frontend

  • HTML: Semantic structure with accessibility
  • CSS: Custom design system with CSS variables
  • JavaScript: Vanilla JS with Chart.js for visualizations
  • No frameworks: Pure web technologies for maximum performance

ML Model (havanagila.py)

  • Sentiment Scoring: Dual-model ensemble approach
  • News Fetching: Historical news with date filtering
  • Backtesting: Real sentiment-based trading simulation
  • Signal Generation: Threshold-based BUY/HOLD/SELL logic

๐Ÿ“ก API Endpoints

GET /api/health

Health check endpoint

Response:

{
  "status": "healthy",
  "models_loaded": true,
  "timestamp": "2026-01-23T13:00:00"
}

POST /api/analyze

Analyze stock sentiment and generate signals

Request:

{
  "ticker": "TCS.NS",
  "days": 90
}

Response:

{
  "ticker": "TCS.NS",
  "days": 90,
  "sentiment": {
    "score": 0.234,
    "signal": "BUY",
    "confidence": 85,
    "article_count": 42
  },
  "backtest": {
    "strategy_return": 12.5,
    "buyhold_return": 8.3,
    "alpha": 4.2
  },
  "news": {
    "top_positive": [...],
    "top_negative": [...]
  },
  "chart_data": {...}
}

๐ŸŽฏ SDG Alignment

This project addresses:

  • SDG 8 - Decent Work and Economic Growth: Empowers retail investors with professional-grade tools
  • SDG 10 - Reduced Inequalities: Democratizes access to sentiment analysis previously limited to institutional traders

๐Ÿ› ๏ธ Troubleshooting

Models Not Loading

  • Issue: API shows "Loading Models..." for too long
  • Solution: Ensure you have stable internet (models download on first run) and sufficient RAM (2GB+)

No News Found

  • Issue: "No news found for ticker"
  • Solution:
    • Verify ticker format (e.g., TCS.NS not TCS)
    • Try a more popular stock
    • Check internet connection

CORS Errors

  • Issue: Frontend can't connect to API
  • Solution:
    • Ensure Flask server is running on http://localhost:5000
    • Check that Flask-CORS is installed
    • Try opening frontend via http:// not file://

Chart Not Rendering

  • Issue: Blank chart area
  • Solution:
    • Check browser console for errors
    • Ensure Chart.js CDN is accessible
    • Try refreshing the page

๐Ÿ“Š Performance Notes

  • First Analysis: 20-40 seconds (news fetching + sentiment analysis)
  • Subsequent Analyses: 15-30 seconds
  • Model Loading: 10-30 seconds (one-time on server start)
  • Recommended: Analyze 3-month periods for balance of data and speed

๐Ÿ”ฎ Future Enhancements

  • Real-time sentiment updates
  • Reddit/Twitter integration
  • Portfolio tracking
  • Email alerts for signals
  • Mobile app
  • Multi-stock comparison
  • Custom backtesting parameters

๐Ÿ“„ License

This project is for educational and research purposes. Not financial advice.


๐Ÿ‘ฅ Credits

ML Model: FinBERT (ProsusAI), RoBERTa (Cardiff NLP)
Data Sources: Google News, Yahoo Finance
Framework: Flask, Chart.js
Design Inspiration: TradingView, Bloomberg Terminal, Zerodha Kite


๐Ÿ“ž Support

For issues or questions:

  1. Check the Troubleshooting section
  2. Verify all dependencies are installed
  3. Ensure API server is running
  4. Check browser console for errors

Built with โค๏ธ for retail investors

About

Your finance assistance in one go.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages