How pikvik/stocksentimentanalysis works
Core project type
• This is a web-based stock analysis application built with Streamlit.
• The purpose is to provide real-time financial insights by fetching stock data and performing sentiment analysis using FinBERT.
Break down the file structure to highlight main components
• Frontend/UI: The Streamlit interface is driven by main.py and configured via .streamlit/config.toml along with custom styling from styles/custom.css.
• Data Fetching & Processing: In the utils directory, data_fetcher.py grabs real-time data from Yahoo Finance, chart_helper.py prepares interactive charts (likely using Plotly for candlestick and volume visualizations), and sentiment_analyzer.py performs news sentiment analysis using FinBERT and PyTorch.
• Configuration/Deployment: Files such as .replit, replit.nix, and uv.lock hint at the development and deployment setup but are not core to the runtime architecture.
Components and interactions
a. Main Components:
• User Interface (UI): Represented by the Streamlit web frontend (main.py, .streamlit/config.toml, styles).
• Data Module: Includes data_fetcher (for Yahoo Finance stock data) and chart_helper (for generating interactive price charts).
• Sentiment Analysis Module: Contains sentiment_analyzer, which integrates FinBERT through PyTorch.
• External Services: Show an external component for Yahoo Finance (via yfinance) and any external news data source if applicable.
b. Relationships and Data Flows:
• Flow from the UI (main.py) to the Data Module (data_fetcher) to fetch stock data from Yahoo Finance.
• Flow from main.py to the Chart Helper, which uses the fetched data to generate candlestick and volume charts.
• Similarly, flow from main.py to the Sentiment Analysis Module, which processes news sentiment.
• Finally, data flows back to the UI for rendering interactive charts and sentiment results.
c. Architectural Patterns and Design Principles:
• Separation of Concerns: Distinct modules for data fetching, chart generation, and sentiment analysis.
• Modular Design: Each util is responsible for a specific functional area, making the system easier to extend or update.
• UI-Logic Separation: The main.py acts as an orchestrator while delegating work to separate functions/modules.
d. Technologies, Frameworks, and Libraries:
• Streamlit: For the web-based user interface.
• yfinance: For interfacing with Yahoo Finance to retrieve real-time stock data.
• Plotly: Likely used in chart_helper for generating interactive charts.
• Transformers (FinBERT) & PyTorch: For implementing sentiment analysis on financial news.