# kieran-mackle/autotrader architecture

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

- Interactive diagram: https://gitdiagram.com/kieran-mackle/autotrader
- Repository: https://github.com/kieran-mackle/autotrader

## Overview

##### Project type and purpose
- AutoTrader is a Python‐based trading framework/library (not a web app).
- It provides a CLI entrypoint, a core engine for backtesting and live trading, a plugins-style broker layer, built‐in indicators, plotting utilities, and notification/comms modules.
- Its main use cases: build, backtest, paper-trade and deploy automated strategies against historical or live market data.

##### File structure
- Top-level modules under `autotrader/`:
- core files: `autobot.py`, `autoplot.py`, `autotrader.py`, `strategy.py`, `indicators.py`, `utilities.py`
- `bin/cli.py`: CLI entrypoint (uses Click)
- `brokers/`: broker-interface abstraction + adapters (ccxt, ib, oanda, trading, virtual, yahoo)
- `comms/`: notification interfaces (e.g. Telegram notifier)
- `package_data/keys.yaml`: default config/data
- Configuration and packaging: `pyproject.toml`, `setup.py`, `requirements.txt`, pre-commit, CI workflows.
- Documentation under `docs/`: modules are documented by category (core, broker, features, tutorials).

##### README insights
- Emphasizes backtesting, paper trading (“virtual broker”), live trading via multiple venues.
- Interactive visualization with Bokeh via `AutoPlot`.
- Broker integration pattern (pluggable): CCXT, Oanda, IB, Yahoo, Virtual.
- Communication hooks for alerts/notifications.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% CLI Layer
    subgraph "CLI Layer"
        CLI["CLI Layer"]:::cli
    end

    %% Core Engine
    subgraph "Core Engine"
        AT["autotrader.py"]:::core
        AB["autobot.py"]:::core
    end

    %% Computation Modules
    subgraph "Computation"
        Data["indicators.py"]:::data
        Strategy["strategy.py"]:::strategy
    end

    %% Execution Manager
    subgraph "Order Execution Manager"
        ExecMgr["broker.py"]:::exec
    end

    %% Broker Plugins
    subgraph "Broker Plugins"
        CCXT["ccxt.py"]:::broker
        OANDA["oanda.py"]:::broker
        IB["ib.py"]:::broker
        TRADING["trading.py"]:::broker
        VIRTUAL["virtual.py"]:::broker
        YAHOO["yahoo.py"]:::broker
    end

    %% Comms Layer
    subgraph "Comms/Notifier Layer"
        Notifier["notifier.py"]:::comms
        TG["tg.py"]:::comms
    end

    %% Visualization Layer
    subgraph "Visualization Layer"
        AutoPlot["autoplot.py"]:::vis
    end

    %% Configuration Store
    Keys["keys.yaml"]:::config

    %% External Systems
    Exchanges["Exchanges"]:::external
    TelegramAPI["Telegram API"]:::external
    Bokeh["Bokeh"]:::external

    %% Connections
    CLI -->|invokes| AT
    AT -->|uses| AB
    AT -->|loads config| Keys
    AT -->|fetches data| Data
    Data -->|provides data| Strategy
    AT -->|orchestrates| Strategy
    Strategy -->|generates signals| ExecMgr
    ExecMgr -->|routes orders| CCXT
    ExecMgr -->|routes orders| OANDA
    ExecMgr -->|routes orders| IB
    ExecMgr -->|routes orders| TRADING
    ExecMgr -->|routes orders| VIRTUAL
    ExecMgr -->|routes orders| YAHOO
    CCXT -->|API calls| Exchanges
    OANDA -->|API calls| Exchanges
    IB -->|API calls| Exchanges
    TRADING -->|API calls| Exchanges
    VIRTUAL -->|simulates orders| Exchanges
    YAHOO -->|data feed| Exchanges
    ExecMgr -->|order events| Notifier
    Notifier -->|send alert| TG
    TG -->|via| TelegramAPI
    AT -->|outputs logs| AutoPlot
    AutoPlot -->|renders charts via| Bokeh

    %% Click Events
    click CLI "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/bin/cli.py"
    click AT "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/autotrader.py"
    click AB "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/autobot.py"
    click Strategy "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/strategy.py"
    click Data "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/indicators.py"
    click ExecMgr "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/broker.py"
    click CCXT "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/ccxt.py"
    click OANDA "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/oanda.py"
    click IB "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/ib.py"
    click TRADING "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/trading.py"
    click VIRTUAL "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/virtual.py"
    click YAHOO "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/brokers/yahoo.py"
    click Notifier "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/comms/notifier.py"
    click TG "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/comms/tg.py"
    click AutoPlot "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/autoplot.py"
    click Keys "https://github.com/kieran-mackle/autotrader/blob/main/autotrader/package_data/keys.yaml"

    %% Styles
    classDef cli fill:#f9f,stroke:#333,stroke-width:1px
    classDef core fill:#bbf,stroke:#333,stroke-width:1px
    classDef data fill:#fbf,stroke:#333,stroke-width:1px
    classDef strategy fill:#bfb,stroke:#333,stroke-width:1px
    classDef exec fill:#ffb,stroke:#333,stroke-width:1px
    classDef broker fill:#fbb,stroke:#333,stroke-width:1px
    classDef comms fill:#bff,stroke:#333,stroke-width:1px
    classDef vis fill:#fb8,stroke:#333,stroke-width:1px
    classDef config fill:#8fb,stroke:#333,stroke-width:1px
    classDef external fill:#ddd,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
```
