# shivadixt/trading_bot architecture

> Architecture diagram of the GitHub repository shivadixt/trading_bot, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-20). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shivadixt/trading_bot
- Repository: https://github.com/shivadixt/trading_bot

## Overview

This is a Python CLI for placing MARKET, LIMIT, and STOP-LIMIT orders on Binance Futures Testnet. Users enter orders through either the guided interactive flow or the headless command; each mode validates inputs before dispatching to order placement, which obtains a configured client and submits the request. Logging is a shared internal layer that writes to the log file and terminal. The sampled source shows these calls directly; broader capabilities and behavior are documented in the README, but unsampled implementation details are not inferred.

Main entry points: [`bot/logging_config.py`](https://github.com/shivadixt/trading_bot/blob/main/bot/logging_config.py) (Logger Setup), [`bot/ui_interactive.py`](https://github.com/shivadixt/trading_bot/blob/main/bot/ui_interactive.py) (Interactive Flow), [`bot/ui_headless.py`](https://github.com/shivadixt/trading_bot/blob/main/bot/ui_headless.py) (Headless Command), [`bot/orders.py`](https://github.com/shivadixt/trading_bot/blob/main/bot/orders.py) (Order Placement)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["CLI Entry"]
  node_cli["CLI Router<br/>[cli.py]"]
end

subgraph group_input["Input Modes"]
  node_interactive["Interactive Flow<br/>[ui_interactive.py]"]
  node_headless["Headless Command<br/>[ui_headless.py]"]
  node_validators["Input Validators<br/>[validators.py]"]
end

subgraph group_trading["Order Execution"]
  node_orders["Order Placement<br/>[orders.py]"]
  node_client["Testnet Client<br/>[client.py]"]
end

subgraph group_ops["Logging"]
  node_logging["Logger Setup<br/>[logging_config.py]"]
  node_logfile["Trading Log"]
end

node_user(("Trader"))
node_binance{{"Binance Futures Testnet"}}

node_user -->|"enters commands"| node_cli
node_cli -->|"launches default"| node_interactive
node_cli -->|"registers command"| node_headless
node_user -->|"provides answers"| node_interactive
node_interactive -->|"validates inputs"| node_validators
node_interactive -->|"dispatches order"| node_orders
node_user -->|"provides options"| node_headless
node_headless -->|"validates inputs"| node_validators
node_headless -->|"dispatches order"| node_orders
node_orders -->|"gets client"| node_client
node_orders -->|"submits orders"| node_binance
node_client -->|"configures testnet"| node_binance
node_cli -->|"sets up logger"| node_logging
node_interactive -->|"sets up logger"| node_logging
node_headless -->|"sets up logger"| node_logging
node_orders -->|"sets up logger"| node_logging
node_client -->|"sets up logger"| node_logging
node_validators -->|"sets up logger"| node_logging
node_logging -->|"writes logs"| node_logfile
node_logging -->|"prints log events"| node_user

click node_cli "https://github.com/shivadixt/trading_bot/blob/main/cli.py"
click node_interactive "https://github.com/shivadixt/trading_bot/blob/main/bot/ui_interactive.py"
click node_headless "https://github.com/shivadixt/trading_bot/blob/main/bot/ui_headless.py"
click node_validators "https://github.com/shivadixt/trading_bot/blob/main/bot/validators.py"
click node_orders "https://github.com/shivadixt/trading_bot/blob/main/bot/orders.py"
click node_client "https://github.com/shivadixt/trading_bot/blob/main/bot/client.py"
click node_logging "https://github.com/shivadixt/trading_bot/blob/main/bot/logging_config.py"
click node_logfile "https://github.com/shivadixt/trading_bot/tree/main/logs"

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_cli toneBlue
class node_interactive,node_headless,node_validators toneAmber
class node_orders,node_client toneMint
class node_logging,node_logfile toneRose
class node_user,node_binance toneIndigo
```

## Components

### CLI Entry

- [CLI Router](https://github.com/shivadixt/trading_bot/blob/main/cli.py): `cli.py`

### Input Modes

- [Interactive Flow](https://github.com/shivadixt/trading_bot/blob/main/bot/ui_interactive.py): `bot/ui_interactive.py`
- [Headless Command](https://github.com/shivadixt/trading_bot/blob/main/bot/ui_headless.py): `bot/ui_headless.py`
- [Input Validators](https://github.com/shivadixt/trading_bot/blob/main/bot/validators.py): `bot/validators.py`

### Order Execution

- [Order Placement](https://github.com/shivadixt/trading_bot/blob/main/bot/orders.py): `bot/orders.py`
- [Testnet Client](https://github.com/shivadixt/trading_bot/blob/main/bot/client.py): `bot/client.py`

### Logging

- [Logger Setup](https://github.com/shivadixt/trading_bot/blob/main/bot/logging_config.py): `bot/logging_config.py`
- [Trading Log](https://github.com/shivadixt/trading_bot/tree/main/logs): `logs`

### Other components

- **Trader**
- **Binance Futures Testnet**

## Connections

- Trader → CLI Router: enters commands (evidence: `README.md`)
- CLI Router → Interactive Flow: launches default (evidence: `cli.py`)
- CLI Router → Headless Command: registers command (evidence: `cli.py`)
- Trader → Interactive Flow: provides answers (evidence: `README.md`)
- Interactive Flow → Input Validators: validates inputs (evidence: `bot/ui_interactive.py`)
- Interactive Flow → Order Placement: dispatches order (evidence: `bot/ui_interactive.py`)
- Trader → Headless Command: provides options (evidence: `README.md`)
- Headless Command → Input Validators: validates inputs (evidence: `bot/ui_headless.py`)
- Headless Command → Order Placement: dispatches order (evidence: `bot/ui_headless.py`)
- Order Placement → Testnet Client: gets client (evidence: `bot/orders.py`)
- Order Placement → Binance Futures Testnet: submits orders (evidence: `bot/orders.py`)
- Testnet Client → Binance Futures Testnet: configures testnet (evidence: `bot/client.py`)
- CLI Router → Logger Setup: sets up logger (evidence: `cli.py`)
- Interactive Flow → Logger Setup: sets up logger (evidence: `bot/ui_interactive.py`)
- Headless Command → Logger Setup: sets up logger (evidence: `bot/ui_headless.py`)
- Order Placement → Logger Setup: sets up logger (evidence: `bot/orders.py`)
- Testnet Client → Logger Setup: sets up logger (evidence: `bot/client.py`)
- Input Validators → Logger Setup: sets up logger (evidence: `bot/validators.py`)
- Logger Setup → Trading Log: writes logs (evidence: `bot/logging_config.py`)
- Logger Setup → Trader: prints log events (evidence: `bot/logging_config.py`)
