# muhammadaskar/stock-trading-bot architecture

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

- Interactive diagram: https://gitdiagram.com/muhammadaskar/stock-trading-bot
- Repository: https://github.com/muhammadaskar/stock-trading-bot

## Overview

This repository is an educational stock-analysis and intraday trading bot. Its user-facing workflow is to run the bot, obtain market data, evaluate stocks, rank recommendations, and report results through the console or Telegram; the README also describes historical-data moving-average decisions and simulated trades with profit/loss. The sampled code shows additional dynamic selection, technical indicators, and optional AI analysis. Source excerpts are incomplete, so uncertain internal wiring is omitted; no actual broker order execution is evidenced.

Main entry points: [`main.py`](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py) (Trading bot)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Trading workflow"]
  node_bot["Trading bot<br/>[main.py]"]
  node_ranking["Recommendation ranking<br/>[main.py]"]
  node_simulation["Trade simulation<br/>[main.py]"]
  node_report["Results and P/L<br/>[main.py]"]
  node_watchlist["Watchlist export<br/>[main.py]"]
  node_telegram["Telegram notifications<br/>[main.py]"]
end

subgraph group_analysis["Analysis and selection"]
  node_selector["Stock selection<br/>[main.py]"]
  node_marketdata["Market data fetch<br/>[main.py]"]
  node_indicators["Technical indicators<br/>[main.py]"]
  node_signals["Trading signals<br/>[main.py]"]
  node_ai["AI analysis<br/>[main.py]"]
end

subgraph group_integrations["External integrations"]
  node_yfinance["Yahoo Finance"]
  node_ai_services["AI providers"]
  node_telegram_service["Telegram API"]
end

node_user(("Bot operator"))

node_user -->|"runs"| node_bot
node_bot -->|"selects stocks"| node_selector
node_bot -->|"requests data"| node_marketdata
node_marketdata -->|"fetches prices"| node_yfinance
node_bot -->|"calculates indicators"| node_indicators
node_bot -->|"evaluates signals"| node_signals
node_bot -.->|"requests analysis"| node_ai
node_ai -.->|"sends prompts"| node_ai_services
node_bot -->|"ranks results"| node_ranking
node_bot -->|"simulates trades"| node_simulation
node_bot -->|"reports results"| node_report
node_bot -->|"exports"| node_watchlist
node_bot -.->|"dispatches messages"| node_telegram
node_telegram -.->|"sends messages"| node_telegram_service

click node_bot "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_selector "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_marketdata "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_indicators "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_signals "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_ai "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_ranking "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_simulation "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_report "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_watchlist "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py"
click node_telegram "https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.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_ranking,node_simulation,node_report,node_watchlist,node_telegram toneBlue
class node_selector,node_marketdata,node_indicators,node_signals,node_ai toneAmber
class node_yfinance,node_ai_services,node_telegram_service toneMint
class node_user toneIndigo
```

## Components

### Trading workflow

- [Trading bot](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Recommendation ranking](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Trade simulation](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Results and P/L](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Watchlist export](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Telegram notifications](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`

### Analysis and selection

- [Stock selection](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Market data fetch](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Technical indicators](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [Trading signals](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`
- [AI analysis](https://github.com/muhammadaskar/stock-trading-bot/blob/main/main.py): `main.py`

### External integrations

- **Yahoo Finance**
- **AI providers**
- **Telegram API**

### Other components

- **Bot operator**

## Connections

- Bot operator → Trading bot: runs
- Trading bot → Stock selection: selects stocks
- Trading bot → Market data fetch: requests data
- Market data fetch → Yahoo Finance: fetches prices
- Trading bot → Technical indicators: calculates indicators
- Trading bot → Trading signals: evaluates signals
- Trading bot → AI analysis: requests analysis
- AI analysis → AI providers: sends prompts
- Trading bot → Recommendation ranking: ranks results
- Trading bot → Trade simulation: simulates trades
- Trading bot → Results and P/L: reports results
- Trading bot → Watchlist export: exports
- Trading bot → Telegram notifications: dispatches messages
- Telegram notifications → Telegram API: sends messages
