# murad24-cuper/trading-bot- architecture

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

- Interactive diagram: https://gitdiagram.com/murad24-cuper/trading-bot-
- Repository: https://github.com/murad24-cuper/trading-bot-

## Overview

XM MT5 Trading Bot is a single-owner, locally run trading system. Its main workflow is to connect to the MT5 terminal, scan broker symbols, evaluate short-horizon opportunities, apply risk controls, and manage orders; SQLite records decisions and trades. A localhost panel displays status and queues bot commands, while research and simulation provide separate analysis capabilities. Evidence is limited to the README and sampled/indexed files; links without direct evidence are omitted.

Main entry points: [`src/panel/app.py`](https://github.com/murad24-cuper/trading-bot-/blob/main/src/panel/app.py) (Web panel), [`src/backtest/engine.py`](https://github.com/murad24-cuper/trading-bot-/blob/main/src/backtest/engine.py) (Backtest engine), [`src/hakim.py`](https://github.com/murad24-cuper/trading-bot-/blob/main/src/hakim.py) (Research assistant), [`src/bot.py`](https://github.com/murad24-cuper/trading-bot-/blob/main/src/bot.py) (Trading runtime)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_trading["Live trading"]
  node_bot["Trading runtime<br/>[bot.py]"]
  node_mt5client["Terminal client<br/>[mt5_client.py]"]
  node_risk["Risk controls<br/>[risk.py]"]
  node_executor["Order execution<br/>[executor.py]"]
  node_database[("Trade database<br/>[db.py]")]
end

subgraph group_market["Market analysis"]
  node_scanner["Symbol scanner<br/>[scanner.py]"]
  node_marketdata["Market data<br/>[market_data.py]"]
  node_indicators["Technical indicators<br/>[indicators.py]"]
  node_strategies["Trade strategies"]
end

subgraph group_panel["Local dashboard"]
  node_panel["Web panel<br/>[app.py]"]
  node_queries["Dashboard queries<br/>[queries.py]"]
  node_commands["Queued commands<br/>[commands.py]"]
  node_auth["Panel authentication<br/>[auth.py]"]
  node_panel_sim["Panel simulation<br/>[sim.py]"]
end

subgraph group_research["Research and simulation"]
  node_backtest["Backtest engine<br/>[engine.py]"]
  node_timesim["Historical analogs<br/>[time_machine.py]"]
  node_newsstudy["News impact study<br/>[news_study.py]"]
  node_history["External history"]
  node_hakim["Research assistant<br/>[hakim.py]"]
end

node_owner(("Bot owner"))
node_terminal[("MetaTrader 5")]

node_owner -->|"runs"| node_bot
node_bot -->|"connects"| node_terminal
node_bot -->|"records trades"| node_database
node_panel -->|"reads status"| node_database
node_panel -->|"authenticates"| node_auth
node_panel -->|"uses queries"| node_queries
node_panel -->|"queues commands"| node_commands
node_panel -->|"uses simulation"| node_panel_sim
node_backtest -->|"applies checks"| node_risk
node_backtest -->|"uses data"| node_marketdata
node_backtest -->|"uses scanner"| node_scanner
node_backtest -->|"computes indicators"| node_indicators
node_panel_sim -->|"runs simulation"| node_timesim
node_hakim -->|"uses study"| node_newsstudy
node_hakim -->|"uses analogs"| node_timesim
node_hakim -->|"uses history"| node_history

click node_bot "https://github.com/murad24-cuper/trading-bot-/blob/main/src/bot.py"
click node_mt5client "https://github.com/murad24-cuper/trading-bot-/blob/main/src/mt5_client.py"
click node_scanner "https://github.com/murad24-cuper/trading-bot-/blob/main/src/scanner.py"
click node_marketdata "https://github.com/murad24-cuper/trading-bot-/blob/main/src/market_data.py"
click node_indicators "https://github.com/murad24-cuper/trading-bot-/blob/main/src/indicators.py"
click node_strategies "https://github.com/murad24-cuper/trading-bot-/tree/main/src/strategies"
click node_risk "https://github.com/murad24-cuper/trading-bot-/blob/main/src/risk.py"
click node_executor "https://github.com/murad24-cuper/trading-bot-/blob/main/src/executor.py"
click node_database "https://github.com/murad24-cuper/trading-bot-/blob/main/src/db.py"
click node_panel "https://github.com/murad24-cuper/trading-bot-/blob/main/src/panel/app.py"
click node_queries "https://github.com/murad24-cuper/trading-bot-/blob/main/src/dashboard/queries.py"
click node_commands "https://github.com/murad24-cuper/trading-bot-/blob/main/src/commands.py"
click node_auth "https://github.com/murad24-cuper/trading-bot-/blob/main/src/dashboard/auth.py"
click node_backtest "https://github.com/murad24-cuper/trading-bot-/blob/main/src/backtest/engine.py"
click node_timesim "https://github.com/murad24-cuper/trading-bot-/blob/main/src/research/time_machine.py"
click node_panel_sim "https://github.com/murad24-cuper/trading-bot-/blob/main/src/panel/sim.py"
click node_newsstudy "https://github.com/murad24-cuper/trading-bot-/blob/main/src/research/news_study.py"
click node_history "https://github.com/murad24-cuper/trading-bot-/blob/main/src/external_history.py"
click node_hakim "https://github.com/murad24-cuper/trading-bot-/blob/main/src/hakim.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_bot,node_mt5client,node_risk,node_executor,node_database toneBlue
class node_scanner,node_marketdata,node_indicators,node_strategies,node_terminal toneAmber
class node_panel,node_queries,node_commands,node_auth,node_panel_sim toneMint
class node_backtest,node_timesim,node_newsstudy,node_history,node_hakim toneRose
class node_owner toneIndigo
```

## Components

### Live trading

- [Trading runtime](https://github.com/murad24-cuper/trading-bot-/blob/main/src/bot.py): `src/bot.py`
- [Terminal client](https://github.com/murad24-cuper/trading-bot-/blob/main/src/mt5_client.py): `src/mt5_client.py`
- [Risk controls](https://github.com/murad24-cuper/trading-bot-/blob/main/src/risk.py): `src/risk.py`
- [Order execution](https://github.com/murad24-cuper/trading-bot-/blob/main/src/executor.py): `src/executor.py`
- [Trade database](https://github.com/murad24-cuper/trading-bot-/blob/main/src/db.py): `src/db.py`

### Market analysis

- [Symbol scanner](https://github.com/murad24-cuper/trading-bot-/blob/main/src/scanner.py): `src/scanner.py`
- [Market data](https://github.com/murad24-cuper/trading-bot-/blob/main/src/market_data.py): `src/market_data.py`
- [Technical indicators](https://github.com/murad24-cuper/trading-bot-/blob/main/src/indicators.py): `src/indicators.py`
- [Trade strategies](https://github.com/murad24-cuper/trading-bot-/tree/main/src/strategies): `src/strategies`

### Local dashboard

- [Web panel](https://github.com/murad24-cuper/trading-bot-/blob/main/src/panel/app.py): `src/panel/app.py`
- [Dashboard queries](https://github.com/murad24-cuper/trading-bot-/blob/main/src/dashboard/queries.py): `src/dashboard/queries.py`
- [Queued commands](https://github.com/murad24-cuper/trading-bot-/blob/main/src/commands.py): `src/commands.py`
- [Panel authentication](https://github.com/murad24-cuper/trading-bot-/blob/main/src/dashboard/auth.py): `src/dashboard/auth.py`
- [Panel simulation](https://github.com/murad24-cuper/trading-bot-/blob/main/src/panel/sim.py): `src/panel/sim.py`

### Research and simulation

- [Backtest engine](https://github.com/murad24-cuper/trading-bot-/blob/main/src/backtest/engine.py): `src/backtest/engine.py`
- [Historical analogs](https://github.com/murad24-cuper/trading-bot-/blob/main/src/research/time_machine.py): `src/research/time_machine.py`
- [News impact study](https://github.com/murad24-cuper/trading-bot-/blob/main/src/research/news_study.py): `src/research/news_study.py`
- [External history](https://github.com/murad24-cuper/trading-bot-/blob/main/src/external_history.py): `src/external_history.py`
- [Research assistant](https://github.com/murad24-cuper/trading-bot-/blob/main/src/hakim.py): `src/hakim.py`

### Other components

- **Bot owner**
- **MetaTrader 5**

## Connections

- Bot owner → Trading runtime: runs (evidence: `README.md`)
- Trading runtime → MetaTrader 5: connects (evidence: `README.md`)
- Trading runtime → Trade database: records trades (evidence: `README.md`)
- Web panel → Trade database: reads status
- Web panel → Panel authentication: authenticates (evidence: `src/panel/app.py`)
- Web panel → Dashboard queries: uses queries (evidence: `src/panel/app.py`)
- Web panel → Queued commands: queues commands (evidence: `src/panel/app.py`)
- Web panel → Panel simulation: uses simulation (evidence: `src/panel/app.py`)
- Backtest engine → Risk controls: applies checks (evidence: `src/backtest/engine.py`)
- Backtest engine → Market data: uses data (evidence: `src/backtest/engine.py`)
- Backtest engine → Symbol scanner: uses scanner (evidence: `src/backtest/engine.py`)
- Backtest engine → Technical indicators: computes indicators (evidence: `src/backtest/engine.py`)
- Panel simulation → Historical analogs: runs simulation (evidence: `src/panel/sim.py`)
- Research assistant → News impact study: uses study (evidence: `src/hakim.py`)
- Research assistant → Historical analogs: uses analogs (evidence: `src/hakim.py`)
- Research assistant → External history: uses history (evidence: `src/hakim.py`)
