# shashankvemuri/finance architecture

> Architecture diagram of the GitHub repository shashankvemuri/finance, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shashankvemuri/finance
- Repository: https://github.com/shashankvemuri/finance

## Overview

##### Project type and purpose
- This is an open-source Python toolkit for financial data gathering, analysis, modeling, and strategy simulation.
- No UI or web frontend; each script is a standalone CLI program.
- Key use-cases: ingest stock data, compute indicators, screen stocks, run statistical analyses, build simple ML models, backtest strategies.

##### File structure
- Top-level directories represent functional layers:
- stock_data – data ingestion layer (web scraping, API clients)
- technical_indicators – pure functions for computing indicators
- find_stocks – screener layer (filters, ratings, signals)
- stock_analysis – statistical and ratio analyses, visualization tools
- machine_learning – prediction/classification models and evaluation
- portfolio_strategies – backtesting and portfolio simulations
- Root files: configuration (requirements.txt), static CSV tickers, helper modules (ta_functions.py, tickers.py).
- No build or deployment scripts—everything runs as a Python script.

##### README for insights
- It documents the six major sections listed above.

a. Main components
- User/CLI layer – entry point for running scripts
- Data Ingestion – stock_data directory, external services (Yahoo Finance API, Finviz web-scraping, Twitter, TradingView, IBD, etc.)
- Indicator Library – technical_indicators directory
- Screening Layer – find_stocks directory
- Analysis Layer – stock_analysis directory
- Modeling Layer – machine_learning directory
- Strategy Layer – portfolio_strategies directory
- Shared Utilities – ta_functions.py, tickers.csv files
b. Relationships and interactions
- Data flows from Data Ingestion into Indicator Library or directly into Screening/Analysis
- Screening/Analysis consume data and indicator outputs
- Analysis layer feeds cleaned data into the Modeling layer
- Modeling outputs (predictions, signals) can feed into Strategy layer
- Strategy layer optionally requests fresh data and indicators, then produces backtest results
c. Architectural patterns and principles
- Layered architecture: each directory is a logical layer with a clear purpose
- Shared library of pure functions (technical_indicators) avoids duplication
- Loose coupling: scripts import only the modules they need
- Extensibility: new scrapers, indicators, models, or strategies plug into their respective layer
d. Key technologies
- Python 3.x, standard modules (requests, pandas, numpy)
- Web-scraping (autoscraper, BeautifulSoup)
- APIs: yfinance, Twilio, Twitter
- ML frameworks: scikit-learn, Keras/TensorFlow, Prophet, ARIMA
- Backtesting: backtrader or custom routines

##### Additional notes
- Shared CSV files and helper modules as a “Utilities” block.
- Maintain readability: group similar modules but document that each script is a standalone entry point.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Entry Point
    User["CLI User"]:::cli

    %% Data Ingestion Layer
    subgraph "Data Ingestion Layer"
        StockData["stock_data/"]:::ingestion
        Yahoo["Yahoo Finance API"]:::external
        Finviz["Finviz Scraper"]:::external
        Twitter["Twitter API"]:::external
        TradingView["TradingView API"]:::external
    end

    %% Indicator Library
    subgraph "Indicator Library"
        Indicators["technical_indicators/"]:::processing
    end

    %% Screening Layer
    subgraph "Screening Layer"
        Screener["find_stocks/"]:::processing
    end

    %% Analysis Layer
    subgraph "Analysis Layer"
        Analysis["stock_analysis/"]:::analysis
    end

    %% Modeling Layer
    subgraph "Modeling Layer"
        Modeling["machine_learning/"]:::modeling
    end

    %% Strategy Layer
    subgraph "Strategy Layer"
        Strategy["portfolio_strategies/"]:::strategy
    end

    %% Utilities
    subgraph "Shared Utilities"
        TA["ta_functions.py"]:::utils
        TickersModule["tickers.py"]:::utils
        CSVs["Static CSV Tick ers"]:::utils
        Amex["amex_tickers.csv"]:::utils
        Nasdaq["nasdaq_tickers.csv"]:::utils
        Nyse["nyse_tickers.csv"]:::utils
        Russell["russell3000_tickers.csv"]:::utils
        SP500["s&p500_tickers.csv"]:::utils
    end

    %% Data Flow
    User -->|triggers| StockData
    StockData -->|provides raw data| Indicators
    StockData -->|provides raw data| Screener
    Indicators -->|computes| Screener
    StockData -->|provides raw data| Analysis
    Indicators -->|computes| Analysis
    Screener -->|filtered data| Analysis
    Analysis -->|clean data| Modeling
    Modeling -->|predictions| Strategy
    Strategy -->|requests fresh data| StockData
    Strategy -->|requests indicators| Indicators

    %% Utilities Connections
    TA --> Indicators
    TA --> Screener
    TA --> Analysis
    TickersModule --> StockData
    CSVs --> StockData
    CSVs --> Screener

    %% External Services
    Yahoo --> StockData
    Finviz --> StockData
    Twitter --> StockData
    TradingView --> StockData

    %% Click Events
    click StockData "https://github.com/shashankvemuri/finance/tree/master/stock_data/"
    click Indicators "https://github.com/shashankvemuri/finance/tree/master/technical_indicators/"
    click Screener "https://github.com/shashankvemuri/finance/tree/master/find_stocks/"
    click Analysis "https://github.com/shashankvemuri/finance/tree/master/stock_analysis/"
    click Modeling "https://github.com/shashankvemuri/finance/tree/master/machine_learning/"
    click Strategy "https://github.com/shashankvemuri/finance/tree/master/portfolio_strategies/"
    click TA "https://github.com/shashankvemuri/finance/blob/master/ta_functions.py"
    click TickersModule "https://github.com/shashankvemuri/finance/blob/master/tickers.py"
    click Amex "https://github.com/shashankvemuri/finance/blob/master/amex_tickers.csv"
    click Nasdaq "https://github.com/shashankvemuri/finance/blob/master/nasdaq_tickers.csv"
    click Nyse "https://github.com/shashankvemuri/finance/blob/master/nyse_tickers.csv"
    click Russell "https://github.com/shashankvemuri/finance/blob/master/russell3000_tickers.csv"
    click SP500 "https://github.com/shashankvemuri/finance/blob/master/s&p500_tickers.csv"

    %% Styles
    classDef cli fill:#f9f,stroke:#333,stroke-width:1px
    classDef ingestion fill:#bbdefb,stroke:#0d47a1,stroke-width:1px
    classDef processing fill:#c8e6c9,stroke:#2e7d32,stroke-width:1px
    classDef analysis fill:#ffe0b2,stroke:#ef6c00,stroke-width:1px
    classDef modeling fill:#fff9c4,stroke:#f9a825,stroke-width:1px
    classDef strategy fill:#e1bee7,stroke:#6a1b9a,stroke-width:1px
    classDef utils fill:#eceff1,stroke:#607d8b,stroke-width:1px
    classDef external fill:#ffcdd2,stroke:#b71c1c,stroke-width:1px
```
