# philwa/momentum architecture

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

- Interactive diagram: https://gitdiagram.com/philwa/momentum
- Repository: https://github.com/philwa/momentum

## Overview

##### Project Type Analysis
This is a data analysis/algorithmic trading project focused on momentum trading strategies. The structure suggests a Python-based analytical tool that processes market data and implements momentum trading logic.

##### Key Components

a. Data Processing Layer:
- 'prepare_data.py' - Data ingestion and preprocessing
- 'process_json.py' - JSON data handling
- 'combinations.json' - Configuration/parameters storage

b. Analysis Core:
- 'analyze.py' - Main analysis engine
- 'momentum.py' - Momentum strategy implementation
- 'gridsearch.py' - Parameter optimization

c. Execution Layer:
- 'app.py' - Main application entry point
- 'benchmark.py' - Performance evaluation

d. Utility Layer:
- 'utils/' directory - Shared functionality
- 'tests/' directory - Testing infrastructure

##### Input Layer (Top)
- Configuration input (combinations.json)

##### Processing Layer (Middle)
- Prepare_data.py and process_json.py components

##### Analysis Layer (Middle-Bottom)
- Momentum Analysis Module
- Grid Search Optimization
- Benchmark Evaluation

##### Output Layer (Bottom)
- Trading Signals/Results
- Performance Metrics

Use these visual elements:
- Blue rectangles for data processing components
- Green rectangles for analysis components
- Yellow diamonds for decision points
- Red rectangles for output/results

##### At the top, place data input sources
Data Input → Preparation → Processing → Analysis → Results

##### Interconnections
- How prepare_data.py feeds into analyze.py
- How momentum.py interfaces with the main analysis
- Demonstrate how gridsearch.py optimizes parameters
- Benchmark.py to the analysis results

##### A utilities section
- Utils as a shared resource accessed by multiple components
- Test coverage with a parallel testing framework

- Blue: Data processing components
- Green: Analysis components
- Yellow: Decision/optimization points
- Gray: Utility components
- Red: Output/results

Important Notes:
##### Optimization and benchmarking capabilities

- Component types (processors, analyzers, utilities)
- Key decision points

Level of Detail:
- Keep main components visible at a glance
- File names but avoid overwhelming detail
- Analytical pipeline and trading strategy implementation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Input
        MD[Market Data]
        CF["Configuration File"]:::config
    end

    subgraph "Data Processing Layer"
        DI["Data Ingestion"]:::processor
        JH["JSON Handler"]:::processor
        DI --> JH
    end

    subgraph "Analysis Core"
        AE["Analysis Engine"]:::analyzer
        MS["Momentum Strategy"]:::analyzer
        PO["Parameter Optimization"]:::optimizer
        
        AE --> MS
        MS --> PO
    end

    subgraph "Execution Layer"
        APP["Application Entry"]:::execution
        PE["Performance Evaluation"]:::execution
    end

    subgraph "Utility Layer"
        SU["Shared Utilities"]:::utility
        TI["Testing Infrastructure"]:::utility
    end

    MD --> DI
    CF --> JH
    JH --> AE
    AE --> APP
    MS --> PE
    PO --> PE
    
    SU -.-> DI
    SU -.-> AE
    SU -.-> PE
    TI -.-> DI
    TI -.-> AE

    subgraph Output
        TS["Trading Signals"]:::output
        PM["Performance Metrics"]:::output
    end

    APP --> TS
    PE --> PM

    %% Component Styles
    classDef processor fill:#3498db,stroke:#2980b9,color:white
    classDef analyzer fill:#2ecc71,stroke:#27ae60,color:white
    classDef optimizer fill:#f1c40f,stroke:#f39c12,color:black
    classDef execution fill:#e74c3c,stroke:#c0392b,color:white
    classDef utility fill:#95a5a6,stroke:#7f8c8d,color:white
    classDef output fill:#e74c3c,stroke:#c0392b,color:white
    classDef config fill:#9b59b6,stroke:#8e44ad,color:white

    %% Click Events
    click DI "https://github.com/PhilWa/momentum/blob/main/prepare_data.py"
    click JH "https://github.com/PhilWa/momentum/blob/main/process_json.py"
    click CF "https://github.com/PhilWa/momentum/blob/main/combinations.json"
    click AE "https://github.com/PhilWa/momentum/blob/main/analyze.py"
    click MS "https://github.com/PhilWa/momentum/blob/main/momentum.py"
    click PO "https://github.com/PhilWa/momentum/blob/main/gridsearch.py"
    click APP "https://github.com/PhilWa/momentum/blob/main/app.py"
    click PE "https://github.com/PhilWa/momentum/blob/main/benchmark.py"
    click SU "https://github.com/PhilWa/momentum/blob/main/utils/utils.py"
    click TI "https://github.com/PhilWa/momentum/blob/main/tests/test_data_source.py"

    %% Legend
    subgraph Legend
        L1["Processing Component"]:::processor
        L2["Analysis Component"]:::analyzer
        L3["Optimization Component"]:::optimizer
        L4["Execution Component"]:::execution
        L5["Utility Component"]:::utility
        L6["Output Component"]:::output
        L7["Configuration"]:::config
    end
```
