Skip to content

Real-time dashboard combining social media sentiment and stock prices to visualize market trends.

Notifications You must be signed in to change notification settings

Addy0606/sentimentanalyser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

30 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Š Sentiment Analyser Dashboard Overview:

The Sentiment Analyser Dashboard is a data-driven web application built with Streamlit that collects Reddit posts and news articles, performs sentiment analysis, and provides interactive visualizations to help users understand market sentiment around specific keywords.

Users can:

Fetch Reddit and news data for selected keywords.

Analyze sentiment (positive, negative, neutral) using NLP techniques.

Visualize trends through charts, tables, and summaries.

Customize analysis by adding their own keywords dynamically.

This project demonstrates the integration of data collection, storage, processing, visualization, and interactivity in a seamless workflow.

✨ Key Features

πŸ” Keyword-based sentiment analysis on Reddit + news data.

πŸ“₯ Automatic data fetching from Reddit & news APIs.

πŸ“Š Interactive visualizations (bar charts, tables, sentiment summaries).

πŸ“ User-defined keywords via Streamlit UI.

πŸ—„ Persistent storage using PostgreSQL.

⚑ Fast and lightweight dashboard powered by Streamlit.

πŸ›  Technologies Used: Frontend / Dashboard:

Streamlit β†’ For building the interactive web UI.

Backend & Data Collection:

PRAW / Reddit API β†’ To fetch Reddit posts.

News API β†’ To fetch latest news headlines.

Requests β†’ For making API calls.

JSON β†’ Handling API responses.

Data Processing & Analysis

Pandas β†’ Data wrangling and summarization.

NumPy β†’ Numeric computations.

VADER Sentiment Analyzer β†’ Rule-based sentiment classification.

Database:

PostgreSQL β†’ Storing Reddit + news posts and sentiment results.

SQLAlchemy β†’ ORM for database interaction.

Visualization:

Matplotlib / Plotly β†’ Charts and graphs.

Streamlit Tables / DataFrames β†’ Interactive data exploration.

Environment & Project Structure:

Python 3.10+

πŸ”Ή Demo

Click the "Fetch Latest Data" button to pull new Reddit posts and News articles and see the sentiment comparison.

πŸ”Ή Features

βœ… Fetch Reddit posts from relevant subreddits

βœ… Fetch News articles via NewsAPI

βœ… Perform sentiment analysis using VADER

βœ… Label posts/articles as Positive / Negative / Neutral

βœ… Compare sentiment across Reddit and News

βœ… Interactive bar charts and summary tables in Streamlit

βš™οΈ Getting Started (Local Setup)

Requirements: PostgreSQL, Reddit API credentials, NewsAPI credentials

  1. Setup Reddit API

Go to Reddit Developer Portal

Create an app

Copy REDDIT_CLIENT_ID (highlighted in the app page)

Copy REDDIT_CLIENT_SECRET

Set a REDDIT_USER_AGENT (any descriptive string)

  1. Setup NewsAPI

Go to NewsAPI

Click Get API Key

Copy your NEWS_API_KEY

  1. Setup PostgreSQL

Download PostgreSQL from postgresql.org

Create a database and note: DB_USER, DB_PASSWORD, DB_HOST, DB_PORT, DB_NAME

  1. Clone the repo git clone https://github.com/Addy0606/sentimentanalyser/ cd sentimentanalyser

  2. Create a virtual environment python -m venv sentimentanalyser-venv

Windows

sentimentanalyser-venv\Scripts\activate

Mac/Linux

source sentimentanalyser-venv/bin/activate

  1. Install dependencies pip install -r requirements.txt

  2. Configure environment variables

Create a .env file in the main project directory with:

DB_USER=your_postgres_user

DB_PASSWORD=your_postgres_password

DB_HOST=localhost

DB_PORT=5432

DB_NAME=your_db_name

REDDIT_CLIENT_ID=your_reddit_client_id

REDDIT_CLIENT_SECRET=your_reddit_client_secret

REDDIT_USER_AGENT=your_reddit_user_agent

NEWS_API_KEY=your_newsapi_key

  1. Create PostgreSQL tables

Reddit Posts Table

CREATE TABLE reddit_posts ( post_id TEXT PRIMARY KEY, subreddit TEXT, keyword TEXT, title TEXT, url TEXT, created_utc TIMESTAMP, selftext TEXT, sentiment FLOAT, label TEXT );

News Posts Table

CREATE TABLE news_posts ( id SERIAL PRIMARY KEY, title TEXT, url TEXT, published_at TIMESTAMP, source TEXT, keyword TEXT, description TEXT, content TEXT, sentiment FLOAT, label TEXT );

▢️ Run the App streamlit run src/app.py

Open the URL displayed in the terminal (usually http://localhost:8501)

Add stocks/keywords as desired.

Click "πŸ”„ Fetch Latest Data" to fetch, analyze, and display data.

πŸ“ Project Structure sentimentanalyser/ β”‚

β”œβ”€ src/

β”‚ β”œβ”€ init.py

β”‚ β”œβ”€ app.py # Streamlit dashboard

β”‚ β”œβ”€ fetchreddit.py # Reddit fetching module

β”‚ β”œβ”€ fetchnews.py # NewsAPI fetching module

β”‚ β”œβ”€ sentiment.py # Sentiment analysis & summary

β”‚ └─ config.py # Keywords and subreddits

β”‚ β”œβ”€ .env # Environment variables (not in repo)

β”œβ”€ .gitignore

β”œβ”€ requirements.txt # Python dependencies

└─ README.md

⚠️ Notes

Free API limits: NewsAPI and Reddit API have request restrictions

Ensure PostgreSQL is running and accessible before fetching data

image image

About

Real-time dashboard combining social media sentiment and stock prices to visualize market trends.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages