# white07s/tradingpatternscanner architecture

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

- Interactive diagram: https://gitdiagram.com/white07s/tradingpatternscanner
- Repository: https://github.com/white07s/tradingpatternscanner

## Overview

##### Project Type and Purpose
- This is a Python library focused on identifying “trading patterns” (such as head and shoulders, triangles, wedges, etc.) in financial time series data.
- Its goal is to offer multiple algorithms (window-based, Savitzky-Golay filtered, Kalman Filter, Wavelet Denoising) for robust pattern detection.
- It is designed to be lightweight (using primarily Pandas and NumPy) and fast, with testing and CI/CD already set up through GitHub Actions.
- The README highlights not only the usage but also planned future enhancements (visualization, extended testing, additional patterns).

##### Analyzing the File Structure
- Top-level Directories and Files:
- .github (with GitHub workflows for CI and publishing): Indicates continuous integration and automated release processes.
- docs: Contains documentation sources (reStructuredText and Makefile) that likely generate a static docs site.
- tests: Holds unit tests, specifically for verifying some aspects of the pattern detection.
- tradingpatterns: The core package that holds the implementation. Its modules include:
· __init__.py – package initializer.
· analysis.py – likely contains higher-level analysis functions, possibly integrating various pattern detection methods.
· hard_data.py – might deal with data pre-processing or handling “hard” (e.g., static) data used during analysis.
· tradingpatterns.py – possibly the main module that exposes key detection functions.
· tradingpatterns_tech.py – probably contains implementations of the technical analysis algorithms or variations (e.g., Kalman filter, wavelet denoising).
- Other files (pyproject.toml, requirements.txt, LICENSE.md, update_docs.sh, etc.) indicate packaging, dependency management, and documentation updating.

##### Key Components
a. Core Library (tradingpatterns package):
- Four major algorithmic implementations for head-shoulder detection (basic, Savitzky-Golay filter, Kalman Filter, and Wavelet Denoising).
- Modules: analysis.py, tradingpatterns.py, tradingpatterns_tech.py, and hard_data.py.
b. Testing Component:
- Tests directory, emphasizing automated tests such as tests/test_hs.py.
- CI integration via GitHub workflows.
c. Documentation:
d. Development & Deployment:
- CI/CD pipelines (.github/workflows) that ensure code quality and packaging (with pyproject.toml, setup configuration files).
e. Usage/Client Component:

##### Relationships and Data Flow
- Internal interactions within the core package between modules (e.g., analysis.py calling functions in tradingpatterns.py and tradingpatterns_tech.py).
- Testing component ‘validating’ the outcomes of the core algorithms.
- CI/CD system’s role in automatically testing and packaging the module.

##### Architectural Patterns and Design Principles
- Modular design: Each module is separated by responsibility—detection algorithms, analysis logic, and data handling.
- Emphasis on vectorization and minimal dependencies (only Pandas/NumPy), which is vital for accurate and fast pattern detection.
- The inclusion of multiple algorithmic methods (filter-based, recursive filters) suggests an extensible design pattern where new detection strategies could be added.

## Diagram (Mermaid)

```mermaid
flowchart TD
    Client["User/Client (pip install tradingpatterns)"]:::client

    subgraph "Core Library (tradingpatterns)"
        analysis["analysis.py"]:::core
        tp["tradingpatterns.py"]:::core
        tech["tradingpatterns_tech.py"]:::core
        hard["hard_data.py"]:::core
    end

    subgraph "Testing"
        tests["tests"]:::test
        testFile["test_hs.py"]:::test
    end

    subgraph "CI/CD Pipeline"
        ci[".github/workflows"]:::ci
        ci_ci["python-ci.yml"]:::ci
        ci_pub["python-publish.yml"]:::ci
    end

    subgraph "Packaging & Dependency"
        pyproject["pyproject.toml"]:::pack
        req["requirements.txt"]:::pack
    end

    subgraph "Documentation"
        docs_source["docs/source (conf.py,index.rst)"]:::docs
        docs_make["docs/Makefile"]:::docs
        docs_images["docs/images"]:::docs
    end

    Client -->|"calls"| analysis
    analysis -->|"uses"| tp
    analysis -->|"uses"| tech
    analysis -->|"uses"| hard
    testFile -->|"validates"| analysis
    tests --> testFile
    ci --> ci_ci
    ci --> ci_pub
    ci_ci -->|"triggers"| tests
    ci_pub -->|"triggers"| pyproject
    ci_ci -->|"updates"| docs_source
    pyproject --> req
    analysis -->|"documented_in"| docs_source
    tests -->|"feedback"| analysis

    classDef core fill:#A9DFBF,stroke:#333,stroke-width:2px;
    classDef test fill:#F9E79F,stroke:#333,stroke-width:2px;
    classDef docs fill:#AED6F1,stroke:#333,stroke-width:2px;
    classDef ci fill:#F5B7B1,stroke:#333,stroke-width:2px;
    classDef pack fill:#D2B4DE,stroke:#333,stroke-width:2px;
    classDef client fill:#FAD7A0,stroke:#333,stroke-width:2px;

    click analysis "https://github.com/white07s/tradingpatternscanner/blob/main/tradingpatterns/analysis.py"
    click tp "https://github.com/white07s/tradingpatternscanner/blob/main/tradingpatterns/tradingpatterns.py"
    click tech "https://github.com/white07s/tradingpatternscanner/blob/main/tradingpatterns/tradingpatterns_tech.py"
    click hard "https://github.com/white07s/tradingpatternscanner/blob/main/tradingpatterns/hard_data.py"
    click tests "https://github.com/white07s/tradingpatternscanner/tree/main/tests/"
    click testFile "https://github.com/white07s/tradingpatternscanner/blob/main/tests/test_hs.py"
    click docs_source "https://github.com/white07s/tradingpatternscanner/tree/main/docs/source/"
    click docs_make "https://github.com/white07s/tradingpatternscanner/tree/main/docs/Makefile"
    click docs_images "https://github.com/white07s/tradingpatternscanner/tree/main/docs/images"
    click ci "https://github.com/white07s/tradingpatternscanner/tree/main/.github/workflows/"
    click ci_ci "https://github.com/white07s/tradingpatternscanner/blob/main/.github/workflows/python-ci.yml"
    click ci_pub "https://github.com/white07s/tradingpatternscanner/blob/main/.github/workflows/python-publish.yml"
    click pyproject "https://github.com/white07s/tradingpatternscanner/blob/main/pyproject.toml"
    click req "https://github.com/white07s/tradingpatternscanner/blob/main/requirements.txt"
```
