# poarlim/crypto-auto-trading architecture

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

- Interactive diagram: https://gitdiagram.com/poarlim/crypto-auto-trading
- Repository: https://github.com/poarlim/crypto-auto-trading

## Overview

a. Data Flow
- Upbit API ↔ Trading Engine (real-time price data, order execution)
- Trading Engine → Slack (notifications)
- Historical Data → Backtesting Module

b. Process Flow
- Authentication → Trading Engine → Order Execution
- Strategy Calculation → Trading Decisions → Order Placement

##### Technical Details to Note

- Python version and key dependencies (pyupbit, requests, etc.)
- Background processing capabilities
- Logging and monitoring components

##### Specific Implementation Notes

- Performance metrics from backtesting
- Time-based execution flow (especially for the volatility breakout strategy)

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph Legend
        L1[Core Trading]:::core
        L2[External Services]:::external
        L3[Data Processing]:::data
        L4[Critical Path]:::critical
    end

    subgraph "Authentication Layer"
        Auth[Authentication Manager]:::security
        APIKeys[API Keys Storage]:::security
    end

    subgraph "External Services"
        UpbitAPI[Upbit Exchange API]:::external
        SlackAPI[Slack API]:::external
    end

    subgraph "Core Trading Engine"
        direction TB
        TradingEngine[Trading Engine Controller]:::core
        
        subgraph "Strategy Implementations"
            direction TB
            MAStrategy["Moving Average Crossover (v0)"]:::core
            VBStrategy["Volatility Breakout (v1)"]:::core
            EnhancedVB["Enhanced VB with Best K (v2)"]:::core
            SlackVB["Slack-Integrated VB (v3)"]:::core
        end
        
        OrderManager[Order Manager]:::critical
        PriceCollector[Price Data Collector]:::data
    end

    subgraph "Data Processing & Analysis"
        HistoricalData[Historical Price Data]:::data
        BacktestingV1[Volatility Strategy Backtesting]:::data
        BacktestingV2[Enhanced Strategy Backtesting]:::data
        PerfMetrics[Performance Metrics]:::data
    end

    subgraph "Monitoring & Logging"
        Logger[Logging System]:::core
        Monitor[System Monitor]:::core
    end

    Auth --> TradingEngine
    APIKeys --> Auth
    TradingEngine --> OrderManager
    PriceCollector --> TradingEngine
    UpbitAPI <--> PriceCollector
    OrderManager --> UpbitAPI
    TradingEngine --> SlackAPI
    HistoricalData --> BacktestingV1
    HistoricalData --> BacktestingV2
    TradingEngine --> Logger
    Logger --> Monitor

    click MAStrategy "https://github.com/poArlim/crypto-auto-trading/blob/master/cryptoAutoTrade_v0.py"
    click VBStrategy "https://github.com/poArlim/crypto-auto-trading/blob/master/cryptoAutoTrade_v1.py"
    click EnhancedVB "https://github.com/poArlim/crypto-auto-trading/blob/master/cryptoAutoTrade_v2.py"
    click SlackVB "https://github.com/poArlim/crypto-auto-trading/blob/master/cryptoAutoTrade_v3.py"
    click BacktestingV1 "https://github.com/poArlim/crypto-auto-trading/blob/master/backtesting_v1.py"
    click BacktestingV2 "https://github.com/poArlim/crypto-auto-trading/blob/master/backtesting_v2.py"

    classDef core fill:#2374f7,stroke:#000,stroke-width:2px,color:#fff
    classDef external fill:#85c075,stroke:#000,stroke-width:2px,color:#000
    classDef data fill:#f4d03f,stroke:#000,stroke-width:2px,color:#000
    classDef critical fill:#e74c3c,stroke:#000,stroke-width:2px,color:#fff
    classDef security fill:#8e44ad,stroke:#000,stroke-width:2px,color:#fff
```
