# depacifier/trading-strategy-optimizer architecture

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

- Interactive diagram: https://gitdiagram.com/depacifier/trading-strategy-optimizer
- Repository: https://github.com/depacifier/trading-strategy-optimizer

## Overview

- Binance API → Data Loader → Strategy Layer → Optimization Engine → Evaluation System → Reporting System

- Optimization Engine ⇢ Strategy Layer (Parameter updates)
- Evaluation System ⇢ Optimization Engine (Performance feedback)

##### Components Details

a. For each Strategy:
- Input parameters
- Optimization objectives (win rate, total return, etc.)
- Performance metrics

b. For Optimization Engine:
- Parameter space
- Objective functions
- Convergence criteria

##### Technical Details Layer

- Python 3.x requirement
- External dependencies
- Configuration requirements (config.py)
- File storage structure

##### Deployment View

How the system interacts with:
- Binance API (external)
- Local storage (data and reports directories)
- Telegram notification service

Important Considerations:

##### Parallel processing capabilities
- Multiple strategy evaluation
- Concurrent optimization runs
- Independent report generation

##### Error handling and monitoring flows
- Data validation paths
- Error notification routes
- Performance monitoring feedback

- Nested components
- Custom annotations
- Export to high-resolution formats

Remember to maintain a balance between detail and clarity, focusing on the key architectural decisions while avoiding overwhelming technical implementation details.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph External
        BA[Binance API]
        TG[Telegram Service]
    end

    subgraph Data
        DL[Data Loader]:::data
        RD[(Raw Market Data)]
    end

    subgraph Strategies
        SM[Strategy Manager]:::strategy
        BSI[Base Strategy Interface]:::strategy
        SI1[Strategy Implementation 1]:::strategy
        SI2[Strategy Implementation 2]:::strategy
    end

    subgraph "Optimization Engine"
        OI[Optimizer Interface]:::optimizer
        GA[Genetic Algorithm]:::optimizer
        DE[Differential Evolution]:::optimizer
        BO[Bayesian Optimization]:::optimizer
        PS[Particle Swarm]:::optimizer
        HO[Hybrid Optimizer]:::optimizer
    end

    subgraph Evaluation
        RA[Result Analyzer]:::evaluation
        PM[Performance Metrics]:::evaluation
    end

    subgraph Reporting
        RG[Report Generator]:::reporting
        PR[PDF Reports]:::reporting
        NS[Notification System]:::reporting
    end

    TSC[Trading System Controller]:::controller

    %% Main Data Flow
    BA --> DL
    DL --> RD
    RD --> SM
    SM --> BSI
    BSI --> SI1
    BSI --> SI2
    SI1 & SI2 --> OI
    OI --> GA & DE & BO & PS & HO
    GA & DE & BO & PS & HO --> RA
    RA --> PM
    PM --> RG
    RG --> PR
    RG --> NS
    NS --> TG

    %% Controller Connections
    TSC --> DL
    TSC --> SM
    TSC --> OI
    TSC --> RA
    TSC --> RG

    %% Feedback Loops
    RA -.-> OI
    OI -.-> SM

    %% Click Events
    click DL "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/data/data_loader.py"
    click BSI "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/strategies/base_strategy.py"
    click SI1 "https://github.com/DePacifier/trading-strategy-optimizer/tree/main/strategies/"
    click SI2 "https://github.com/DePacifier/trading-strategy-optimizer/tree/main/strategies/"
    click SM "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/strategy_manager.py"
    click OI "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/optimizer.py"
    click GA "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/genetic_algorithm.py"
    click DE "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/differential_evolution.py"
    click BO "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/bayesian_optimization.py"
    click PS "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/particle_swarm.py"
    click HO "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/optimization/hybrid_optimizer.py"
    click RA "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/evaluation/result_analyzer.py"
    click RG "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/reporting/report_generator.py"
    click PR "https://github.com/DePacifier/trading-strategy-optimizer/tree/main/reports/"
    click NS "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/notifiers/telegram_notifier.py"
    click TSC "https://github.com/DePacifier/trading-strategy-optimizer/blob/main/trading_system_controller.py"

    %% Styling
    classDef data fill:#3498db
    classDef strategy fill:#2ecc71
    classDef optimizer fill:#e67e22
    classDef evaluation fill:#9b59b6
    classDef reporting fill:#e74c3c
    classDef controller fill:#34495e
    classDef external fill:#95a5a6

    %% Legend
    subgraph Legend
        L1[Data Component]:::data
        L2[Strategy Component]:::strategy
        L3[Optimizer Component]:::optimizer
        L4[Evaluation Component]:::evaluation
        L5[Reporting Component]:::reporting
        L6[Controller Component]:::controller
        L7[External Service]:::external
    end
```
