# murad24-cuper/bottrading-v2 architecture

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

- Interactive diagram: https://gitdiagram.com/murad24-cuper/bottrading-v2
- Repository: https://github.com/murad24-cuper/bottrading-v2

## Overview

XM MT5 Trading Bot is a local, single-owner trading application. Its principal workflow connects to the broker terminal, discovers and scans symbols, analyzes market data with strategy families, applies trade and risk rules, then manages orders and records outcomes. A localhost dashboard reads that recorded state and queues operator commands. The README documents these runtime stages and risk controls; the excerpts show selected market-data, strategy, dashboard, and backtest internals. The bot, scanner, executor, and database implementations were not sampled, so detailed links among them are documented rather than source-verified.

Main entry points: [`src/bot.py`](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/bot.py) (Bot runtime), [`src/scanner.py`](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/scanner.py) (Symbol scanner), [`src/dashboard/app.py`](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/dashboard/app.py) (Dashboard), [`src/strategies/research_families.py`](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/strategies/research_families.py) (Strategy families)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_market["Market inputs"]
  node_mt5["MT5 terminal<br/>[mt5_client.py]"]
  node_universe["Symbol discovery<br/>[symbols.py]"]
  node_marketdata["Market data<br/>[market_data.py]"]
end

subgraph group_signals["Signal analysis"]
  node_indicators["Indicators<br/>[indicators.py]"]
  node_features["Market features<br/>[features.py]"]
  node_strategies["Strategy families"]
end

subgraph group_trading["Trading runtime"]
  node_scanner["Symbol scanner<br/>[scanner.py]"]
  node_rules["Trade rules<br/>[trade_rules.py]"]
  node_risk["Risk controls<br/>[risk.py]"]
  node_executor["Order execution<br/>[executor.py]"]
  node_bot["Bot runtime<br/>[bot.py]"]
  node_database[("Trade database<br/>[db.py]")]
end

subgraph group_oversight["Operations dashboard"]
  node_dashboard["Dashboard<br/>[app.py]"]
  node_dashqueries["Dashboard queries<br/>[queries.py]"]
end

subgraph group_learning["Research and learning"]
  node_brain["Trading brain<br/>[live.py]"]
  node_memory["Situation memory<br/>[memory.py]"]
  node_backtest["Backtesting<br/>[engine.py]"]
  node_validation["Strategy validation<br/>[validation.py]"]
end

node_owner(("Bot operator"))

node_owner -->|"starts runtime"| node_bot
node_bot -->|"connects to"| node_mt5
node_bot -->|"scans symbols"| node_universe
node_bot -->|"runs scan"| node_scanner
node_scanner -.->|"loads bars"| node_marketdata
node_strategies -->|"calculates with"| node_indicators
node_strategies -->|"uses features"| node_features
node_scanner -.->|"analyzes movers"| node_strategies
node_scanner -.->|"filters signals"| node_rules
node_bot -->|"checks exposure"| node_risk
node_bot -->|"submits orders"| node_executor
node_bot -->|"records trades"| node_database
node_bot -.->|"serves status"| node_dashboard
node_dashboard -->|"reads through"| node_dashqueries
node_dashqueries -->|"reads SQLite"| node_database
node_dashboard -->|"queues commands"| node_bot
node_brain -.->|"uses memory"| node_memory
node_backtest -->|"reuses scan logic"| node_scanner
node_backtest -->|"applies checks"| node_risk
node_validation -.->|"evaluates results"| node_backtest

click node_mt5 "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/mt5_client.py"
click node_universe "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/symbols.py"
click node_marketdata "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/market_data.py"
click node_indicators "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/indicators.py"
click node_features "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/features.py"
click node_strategies "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/strategies/research_families.py"
click node_scanner "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/scanner.py"
click node_rules "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/trade_rules.py"
click node_risk "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/risk.py"
click node_executor "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/executor.py"
click node_bot "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/bot.py"
click node_database "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/db.py"
click node_dashboard "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/dashboard/app.py"
click node_dashqueries "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/dashboard/queries.py"
click node_brain "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/brain/live.py"
click node_memory "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/brain/memory.py"
click node_backtest "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/backtest/engine.py"
click node_validation "https://github.com/murad24-cuper/bottrading-v2/blob/main/src/research/validation.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_mt5,node_universe,node_marketdata toneBlue
class node_indicators,node_features,node_strategies toneAmber
class node_scanner,node_rules,node_risk,node_executor,node_bot,node_database toneMint
class node_dashboard,node_dashqueries toneRose
class node_brain,node_memory,node_backtest,node_validation,node_owner toneIndigo
```

## Components

### Market inputs

- [MT5 terminal](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/mt5_client.py): `src/mt5_client.py`
- [Symbol discovery](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/symbols.py): `src/symbols.py`
- [Market data](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/market_data.py): `src/market_data.py`

### Signal analysis

- [Indicators](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/indicators.py): `src/indicators.py`
- [Market features](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/features.py): `src/features.py`
- [Strategy families](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/strategies/research_families.py): `src/strategies/research_families.py`

### Trading runtime

- [Symbol scanner](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/scanner.py): `src/scanner.py`
- [Trade rules](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/trade_rules.py): `src/trade_rules.py`
- [Risk controls](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/risk.py): `src/risk.py`
- [Order execution](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/executor.py): `src/executor.py`
- [Bot runtime](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/bot.py): `src/bot.py`
- [Trade database](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/db.py): `src/db.py`

### Operations dashboard

- [Dashboard](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/dashboard/app.py): `src/dashboard/app.py`
- [Dashboard queries](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/dashboard/queries.py): `src/dashboard/queries.py`

### Research and learning

- [Trading brain](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/brain/live.py): `src/brain/live.py`
- [Situation memory](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/brain/memory.py): `src/brain/memory.py`
- [Backtesting](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/backtest/engine.py): `src/backtest/engine.py`
- [Strategy validation](https://github.com/murad24-cuper/bottrading-v2/blob/main/src/research/validation.py): `src/research/validation.py`

### Other components

- **Bot operator**

## Connections

- Bot operator → Bot runtime: starts runtime
- Bot runtime → MT5 terminal: connects to
- Bot runtime → Symbol discovery: scans symbols
- Bot runtime → Symbol scanner: runs scan
- Symbol scanner → Market data: loads bars
- Strategy families → Indicators: calculates with (evidence: `src/strategies/research_families.py`)
- Strategy families → Market features: uses features
- Symbol scanner → Strategy families: analyzes movers
- Symbol scanner → Trade rules: filters signals
- Bot runtime → Risk controls: checks exposure
- Bot runtime → Order execution: submits orders
- Bot runtime → Trade database: records trades
- Bot runtime → Dashboard: serves status
- Dashboard → Dashboard queries: reads through (evidence: `src/dashboard/app.py`)
- Dashboard queries → Trade database: reads SQLite (evidence: `src/dashboard/queries.py`)
- Dashboard → Bot runtime: queues commands (evidence: `src/dashboard/app.py`)
- Trading brain → Situation memory: uses memory
- Backtesting → Symbol scanner: reuses scan logic (evidence: `src/backtest/engine.py`)
- Backtesting → Risk controls: applies checks (evidence: `src/backtest/engine.py`)
- Strategy validation → Backtesting: evaluates results
