3 Architecture
Fabian Frank edited this page 2025-12-03 16:12:34 +02:00
This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

Architecture Overview

This page describes the overall architecture of the Stock Market Analysis Tool, including the main components, their interactions, and the data flow.


🔹 High-Level Overview

The application follows a modular structure with clear separation between:

  1. Data Layer fetching, storing, and preprocessing financial data
  2. Core Logic Layer calculation of indicators, portfolio management, network analysis, and prediction
  3. Visualization / UI Layer Streamlit interface and interactive plots
  4. Entry Point main.py, which connects all modules

🔹 Component Breakdown

1. Data Layer (/data)

  • fetch_data.py: Retrieves stock and market data from external APIs (Yahoo Finance).
  • /data_saved/: Static CSV or Parquet files for historical data, caching, and precomputed results.

Responsibilities:

  • Provide clean, structured data to core modules
  • Ensure data is valid and formatted for indicator and visualization modules

2. Core Logic Layer (/core)

  • indicators.py: Computes SMA, EMA, ATR, RSI, MACD, etc.
  • market_screener.py: Screens market data, computes correlations, prepares input for heatmaps and network graphs.
  • network_graphing.py: Builds interactive correlation networks using Plotly and Louvain clustering.
  • portfolio.py: Tracks user-defined portfolios and calculates performance.
  • prediction.py: Runs a deterministic forecasting model for price prediction.

Responsibilities:

  • Perform all calculations and analyses
  • Maintain modularity so each component can be extended independently
  • Reference official documentation where applicable

3. Visualization / UI Layer (/GUI)

  • user_interface.py: Creates the Streamlit interface, handles user input, and routes actions to the core logic.
  • colour_coding.py: Provides color schemes for heatmaps and other visuals.

Responsibilities:

  • Render charts, heatmaps, networks, and tables
  • Ensure interactive, user-friendly experience
  • Separate UI logic from core calculations

4. Entry Point (main.py)

  • Initializes the Streamlit environment
  • Imports core modules and GUI
  • Handles user navigation between pages and visualizations

Responsibilities:

  • Connect data layer, core logic, and UI
  • Serve as the single entry point for developers and users

🔹 Data Flow

  1. User input: Ticker, portfolio data, or parameters via Streamlit UI
  2. Data fetch: fetch_data.py retrieves data from Yahoo Finance or loads cached files
  3. Processing: Core modules compute indicators, correlations, predictions
  4. Visualization: Heatmaps, network graphs, charts, and portfolio results rendered in UI
  5. Feedback: Users see results and can adjust input to repeat the cycle

Here you can see how the program files interact with eachother: stock_market_analyzer_dependency_graph


🔹 Notes for Developers

  • The modular design allows easy replacement or extension of:
    • Prediction methods
    • Visualization types
    • Data sources
  • Each module should operate independently of UI logic
  • All modules reference official documentation where applicable for correctness