How kaffy-qaiser/sentiment-analysis-stock-predictor works
Purpose and entry point
This is a Python Dash dashboard for comparing actual stock prices with sentiment-informed LSTM predictions. The executable entry point is app.py; users run it locally and interact through the Dash server at port 8050.
Application orchestration
app.py is the central application boundary: it hosts the Dash layout, user ticker submission flow, data retrieval, sentiment processing, model execution, and Plotly visualization updates. There is no separate package structure, API service, worker, or persistence layer in the repository tree.
Sentiment data pipeline
The dashboard combines social/news text sentiment with market data. Reddit access is intended through PRAW and r/wallstreetbets; news is intended through News API. NLP dependencies include NLTK and VADER sentiment scoring. A bundled dataset, wsb_posts_sentiment.csv, provides local WallStreetBets sentiment data and is the only repository-managed data artifact.
Market-data integration
Stock-history retrieval is delegated to Yahoo Finance through yfinance. Ticker input drives the external market-data request and supplies the actual-price series used for comparison against predictions. This creates an external-service boundary where availability, ticker validity, and returned history affect dashboard results.
Prediction stage
The stated forecasting mechanism is a PyTorch LSTM model that uses sentiment-derived inputs to predict price trends. Numerical preparation and feature handling rely on pandas, numpy, and scikit-learn. Model training/inference logic, if implemented, resides in the monolithic app.py; no serialized model artifact or dedicated training pipeline is present in the tree.
Presentation layer
Dash provides the interactive UI and callback runtime, while Plotly renders actual-versus-predicted stock-price charts and sentiment-trend charts. The browser communicates only with the local Dash application; upstream Reddit, News API, and Yahoo Finance calls occur server-side in Python.
Runtime and configuration boundaries
The runtime is Python 3.8+ with dependencies declared in requirements.txt. Credentials are expected from environment variables for Reddit and News API, rather than committed configuration. Required external resources include Reddit API, News API, Yahoo Finance, and downloadable NLTK corpora/lexicons. Key paths: app.py, requirements.txt, wsb_posts_sentiment.csv.
Components 14
Local Dashboard
Single-process Python Dash application.
- Dash application · Hosts UI, callbacks, retrieval, processing, inference, and chart updates.
app.py - Runtime dependencies · Declares Python 3.8+ package dependencies.
requirements.txt - Environment credentials · Provides Reddit and News API credentials.
- Plotly charts · Renders actual-versus-predicted prices and sentiment trends.
Data Sources
Local and external inputs used server-side.
- WSB sentiment dataset · Repository-managed WallStreetBets sentiment data.
wsb_posts_sentiment.csv - Reddit r/wallstreetbets · Social-text source accessed through PRAW.
- News API · News-text source.
- Yahoo Finance · Returns ticker-driven stock-price history through yfinance.
Analytics Pipeline
Sentiment processing and forecast preparation inside the app.
- Sentiment text inputs
- VADER sentiment scoring · Scores text using NLTK/VADER resources.
- Feature preparation · Prepares sentiment-derived numerical model inputs.
- PyTorch LSTM · Predicts price trends; training and inference are implemented in the app.
- Actual price history · Ticker-specific series used as the actual comparison baseline.
Other components
- User browser · Interacts with the local dashboard on port 8050.
Connections 17
- User browser → Dash application: ticker input and UI events
- Dash application → Yahoo Finance: requests ticker history
- Yahoo Finance → Actual price history: returns market history
- Dash application → Reddit r/wallstreetbets: fetches social posts
- Dash application → News API: fetches news text
- WSB sentiment dataset → Sentiment text inputs: local sentiment records
- Reddit r/wallstreetbets → Sentiment text inputs: post text
- News API → Sentiment text inputs: article text
- Sentiment text inputs → VADER sentiment scoring: score text
- VADER sentiment scoring → Feature preparation: sentiment features
- Feature preparation → PyTorch LSTM: model inputs
- PyTorch LSTM → Plotly charts: predicted trends
- Actual price history → Plotly charts: actual prices
- Dash application → Plotly charts: updates callback output
- Plotly charts → User browser: interactive visualizations
- Environment credentials → Dash application: credentials
- Runtime dependencies → Dash application: runtime packages