Skip to content

RachGranville/sentimentstrading

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NewsSentimentScanner 📊

A complete sentiment analysis toolkit combining Google News RSS aggregation with FinBERT (finance-tuned transformer) for real-time market sentiment tracking.

Features

1. Notebook Pipeline (test.ipynb)

  • Fetch latest 10 Google News items per query
  • Multi-locale support (US, GB, CA, IN) with query variants
  • Per-article sentiment analysis with FinBERT or VADER
  • Aggregated summary across all queries and articles
  • Focused on INTC/Intel stock queries

2. Web App (app.py)

  • Flask-based REST API
  • Modern, responsive web interface
  • Real-time FinBERT sentiment analysis
  • Displays:
    • Primary sentiment label (Positive/Neutral/Negative)
    • Probability scores with visual progress bars
    • Compound score for quick reference
  • Handles long texts with automatic truncation (max 512 tokens)

Installation

  1. Clone and setup:
git clone https://github.com/RachGranville/sentimentstrading.git
cd sentimentstrading
python -m venv .venv
.venv\Scripts\activate  # On Windows
source .venv/bin/activate  # On macOS/Linux
  1. Install dependencies:
pip install -r requirements.txt

Usage

Option A: Jupyter Notebook (Batch Analysis)

jupyter notebook test.ipynb
  • Edit queries list (line ~12 in the code cell)
  • Choose method = "finbert" or "vader"
  • Run the Google News cell to analyze 100+ articles (10 per query)
  • View aggregated sentiment summary

Option B: Flask Web App (Interactive)

python app.py

Then open http://127.0.0.1:5000 in your browser and:

  • Type or paste text
  • Click "Analyze Sentiment" (or press Enter)
  • See instant FinBERT results

Project Structure

NewsSentimentScanner/
├── app.py                 # Flask web app
├── test.ipynb            # Jupyter notebook for batch analysis
├── sentiment_analysis.py  # Utility functions
├── requirements.txt      # Python dependencies
├── templates/
│   └── index.html        # Web UI
└── README.md

Key Technologies

  • FinBERT: Financial sentiment analysis (yiyanghkust/finbert-tone)
  • VADER: Alternative sentiment analyzer (nltk)
  • feedparser: Google News RSS parsing
  • Flask: Web framework
  • Transformers: HuggingFace model pipeline

Sentiment Scores Explained

FinBERT Output

  • Positive: Probability of positive sentiment (0.0–1.0)
  • Neutral: Probability of neutral sentiment (0.0–1.0)
  • Negative: Probability of negative sentiment (0.0–1.0)
  • Compound: Pseudo-compound score = Positive − Negative (−1.0 to 1.0)

Classification

  • Positive: Highest probability is Positive class
  • Neutral: Highest probability is Neutral class
  • Negative: Highest probability is Negative class

Notes

  • First FinBERT run downloads the model (~500 MB)
  • Long texts automatically truncated to 512 tokens (BERT limit)
  • Google News RSS queries fetch up to 10 articles with multi-locale fallbacks
  • Flask runs in debug mode; use WSGI server for production

License

MIT

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors