# delta-exchange/trading-bots architecture

> Architecture diagram of the GitHub repository delta-exchange/trading-bots, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/delta-exchange/trading-bots
- Repository: https://github.com/delta-exchange/trading-bots

## Overview

This repository is a Delta bitcoin-futures market-making bot. Its documented run path selects the unhedged strategy, which uses shared market-maker logic to generate and reconcile orders through Delta’s REST and websocket client. The strategy also checks liquidation risk and can add position margin. Configuration supplies account credentials and runtime settings; utility and error-handling modules support the trading path. The graph preserves README capabilities and source-indexed dependencies; some internal calls are not shown in the excerpts, so uncertain links are omitted.

Main entry points: [`clients/delta.py`](https://github.com/delta-exchange/trading-bots/blob/master/clients/delta.py) (Delta client), [`market_maker/unhedged.py`](https://github.com/delta-exchange/trading-bots/blob/master/market_maker/unhedged.py) (Unhedged strategy), [`market_maker/base.py`](https://github.com/delta-exchange/trading-bots/blob/master/market_maker/base.py) (Maker engine), [`strategy_runner.py`](https://github.com/delta-exchange/trading-bots/blob/master/strategy_runner.py) (Strategy runner)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry_config["Entry and configuration"]
  node_runner["Strategy runner<br/>[strategy_runner.py]"]
  node_env_config["Environment settings<br/>[dotenvs.py]"]
  node_account_config["Account credentials<br/>[accounts.py]"]
end

subgraph group_strategy["Market-making strategy"]
  node_unhedged["Unhedged strategy<br/>[unhedged.py]"]
  node_maker_base["Maker engine<br/>[base.py]"]
end

subgraph group_exchange["Exchange access"]
  node_delta["Delta client<br/>[delta.py]"]
  node_base_client["Client interface<br/>[base.py]"]
end

subgraph group_support["Trading support"]
  node_margin["Margin calculations<br/>[margin_helper.py]"]
  node_utilities["Trading utilities<br/>[utility.py]"]
  node_request_errors["Request error handling<br/>[decorators.py]"]
  node_exceptions["Trading exceptions"]
end

node_operator(("Bot operator"))
node_delta_exchange{{"Delta Exchange"}}

node_operator -->|"starts"| node_runner
node_runner -->|"selects strategy"| node_unhedged
node_unhedged -->|"inherits"| node_maker_base
node_unhedged -->|"subscribes and queries"| node_delta
node_maker_base -->|"uses exchange client"| node_delta
node_maker_base -->|"loads accounts"| node_account_config
node_unhedged -->|"calculates top-up"| node_margin
node_delta -->|"implements"| node_base_client
node_delta -->|"requests market data and trades"| node_delta_exchange
node_delta -->|"decorates requests"| node_request_errors
node_request_errors -->|"raises mapped errors"| node_exceptions
node_delta -->|"uses price helpers"| node_utilities

click node_runner "https://github.com/delta-exchange/trading-bots/blob/master/strategy_runner.py"
click node_env_config "https://github.com/delta-exchange/trading-bots/blob/master/config/dotenvs.py"
click node_account_config "https://github.com/delta-exchange/trading-bots/blob/master/config/accounts.py"
click node_unhedged "https://github.com/delta-exchange/trading-bots/blob/master/market_maker/unhedged.py"
click node_maker_base "https://github.com/delta-exchange/trading-bots/blob/master/market_maker/base.py"
click node_delta "https://github.com/delta-exchange/trading-bots/blob/master/clients/delta.py"
click node_base_client "https://github.com/delta-exchange/trading-bots/blob/master/clients/base.py"
click node_margin "https://github.com/delta-exchange/trading-bots/blob/master/utils/margin_helper.py"
click node_utilities "https://github.com/delta-exchange/trading-bots/blob/master/utils/utility.py"
click node_request_errors "https://github.com/delta-exchange/trading-bots/blob/master/utils/decorators.py"
click node_exceptions "https://github.com/delta-exchange/trading-bots/blob/master/custom_exceptions.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_env_config,node_account_config toneBlue
class node_unhedged,node_maker_base toneAmber
class node_delta,node_base_client toneMint
class node_margin,node_utilities,node_request_errors,node_exceptions toneRose
class node_operator,node_delta_exchange toneIndigo
```

## Components

### Entry and configuration

- [Strategy runner](https://github.com/delta-exchange/trading-bots/blob/master/strategy_runner.py): `strategy_runner.py`
- [Environment settings](https://github.com/delta-exchange/trading-bots/blob/master/config/dotenvs.py): `config/dotenvs.py`
- [Account credentials](https://github.com/delta-exchange/trading-bots/blob/master/config/accounts.py): `config/accounts.py`

### Market-making strategy

- [Unhedged strategy](https://github.com/delta-exchange/trading-bots/blob/master/market_maker/unhedged.py): `market_maker/unhedged.py`
- [Maker engine](https://github.com/delta-exchange/trading-bots/blob/master/market_maker/base.py): `market_maker/base.py`

### Exchange access

- [Delta client](https://github.com/delta-exchange/trading-bots/blob/master/clients/delta.py): `clients/delta.py`
- [Client interface](https://github.com/delta-exchange/trading-bots/blob/master/clients/base.py): `clients/base.py`

### Trading support

- [Margin calculations](https://github.com/delta-exchange/trading-bots/blob/master/utils/margin_helper.py): `utils/margin_helper.py`
- [Trading utilities](https://github.com/delta-exchange/trading-bots/blob/master/utils/utility.py): `utils/utility.py`
- [Request error handling](https://github.com/delta-exchange/trading-bots/blob/master/utils/decorators.py): `utils/decorators.py`
- [Trading exceptions](https://github.com/delta-exchange/trading-bots/blob/master/custom_exceptions.py): `custom_exceptions.py`

### Other components

- **Bot operator**
- **Delta Exchange**

## Connections

- Bot operator → Strategy runner: starts (evidence: `README.md`)
- Strategy runner → Unhedged strategy: selects strategy (evidence: `strategy_runner.py`)
- Unhedged strategy → Maker engine: inherits (evidence: `market_maker/unhedged.py`)
- Unhedged strategy → Delta client: subscribes and queries (evidence: `market_maker/unhedged.py`)
- Maker engine → Delta client: uses exchange client (evidence: `market_maker/base.py`)
- Maker engine → Account credentials: loads accounts (evidence: `market_maker/base.py`)
- Unhedged strategy → Margin calculations: calculates top-up (evidence: `market_maker/unhedged.py`)
- Delta client → Client interface: implements (evidence: `clients/delta.py`)
- Delta client → Delta Exchange: requests market data and trades (evidence: `clients/delta.py`)
- Delta client → Request error handling: decorates requests (evidence: `clients/delta.py`)
- Request error handling → Trading exceptions: raises mapped errors (evidence: `utils/decorators.py`)
- Delta client → Trading utilities: uses price helpers (evidence: `clients/delta.py`)
