# lucasaraujoo/iqoption-telegram-bot architecture

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

- Interactive diagram: https://gitdiagram.com/lucasaraujoo/iqoption-telegram-bot
- Repository: https://github.com/lucasaraujoo/iqoption-telegram-bot

## Overview

##### Main System Components
- Telegram Integration: The bot listens for commands and sends/receives messages to/from Telegram. This is indicated by the instructions to create and configure a Telegram bot via BotFather and the use of “TELEGRAM_TOKEN” and “TELEGRAM_ID” environment variables in config.txt.
- Core Bot Logic & Signal Processing: Represented by the main scripts (AutoBot_24h.py and Inclusor_Sinais.py), which are responsible for loading configurations, handling real-time signals, and managing internal state. This module also handles threading to improve optimization and precision.
- IQ Option API Integration:
– HTTP Module: Inside the iqoptionapi/http folder are multiple files (login.py, auth.py, profile.py, etc.) that handle RESTful interactions such as authentication, registration, billing, and other operations.
– WebSocket (WS) Module: Located in iqoptionapi/ws and further divided into “channels” and “objects” directories. This module manages real-time data such as market data, orders, and trading updates.
– Stable API Wrapper: Wrappers such as stable_api.py and api.py serve as a higher-level abstraction for interacting with the underlying HTTP and WS components.
- Configuration & Logging: The config.txt file, signals file (sinais.txt), and logs directory collectively represent the configuration settings and runtime logs for monitoring operations.

##### Relationships and Interactions
- The Telegram integration component serves as the user interface. It sends user commands to the core bot logic.
- The core bot logic, upon receiving a Telegram command or signal, uses threads to perform operations concurrently. It then communicates with the IQ Option API modules to execute trades.
- The IQ Option API integration has two main communication paths: one using HTTP for tasks like login, registration, and profile queries, and another using WebSockets for receiving real-time market feed, order updates, and executing trades.
- Configuration settings from config.txt drive the runtime behavior while log files record significant events.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Different modules/components are clearly separated (Telegram interface, core logic, HTTP and WS API integrations).
- Modular Design: The iqoptionapi package is organized into submodules (http and ws) which encapsulate API-specific functionality.
- Concurrency: Use of threads in the main scripts to manage simultaneous tasks and ensure trade execution precision.
- Extensibility: The “channels” in the ws submodule are organized per functionality, making it easier to add or modify trading commands and features.

##### Final Touches for Detail
- Integration points by noting which environment variables (from config.txt) affect behavior.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Global Components
    A["Configuration Module (config.txt)"]:::config
    B["Telegram Integration (Bot API)"]:::telegram

    subgraph "Core Bot Logic & Signal Processing"
        C["AutoBot_24h.py"]:::core
        D["Inclusor_Sinais.py"]:::core
    end

    E["Stable API Wrapper"]:::stable

    subgraph "IQ Option API Integration"
        F["HTTP Handler (iqoptionapi/http)"]:::http
        G["WebSocket Handler (iqoptionapi/ws)"]:::ws
    end

    H["Logging & Diagnostics (logs)"]:::logging
    I["Signal File (sinais.txt)"]:::signal

    %% Connections
    A -->|"env_config"| B
    A -->|"env_config"| C
    B -->|"telegram_command"| C
    B -->|"telegram_command"| D
    C -->|"process_signal"| E
    D -->|"process_signal"| E
    E -->|"HTTP_call"| F
    E -->|"WS_call"| G
    F -->|"HTTP_response"| E
    G -->|"WS_response"| E
    E -->|"feedback"| C
    E -->|"feedback"| D
    C -->|"log_event"| H
    D -->|"log_event"| H
    D -->|"signal_input"| I

    %% Click Events
    click A "https://github.com/lucasaraujoo/iqoption-telegram-bot/blob/main/config.txt"
    click C "https://github.com/lucasaraujoo/iqoption-telegram-bot/blob/main/AutoBot_24h.py"
    click D "https://github.com/lucasaraujoo/iqoption-telegram-bot/blob/main/Inclusor_Sinais.py"
    click F "https://github.com/lucasaraujoo/iqoption-telegram-bot/tree/main/iqoptionapi/http"
    click G "https://github.com/lucasaraujoo/iqoption-telegram-bot/tree/main/iqoptionapi/ws"
    click E "https://github.com/lucasaraujoo/iqoption-telegram-bot/blob/main/iqoptionapi/api.py"
    click H "https://github.com/lucasaraujoo/iqoption-telegram-bot/tree/main/logs"
    click I "https://github.com/lucasaraujoo/iqoption-telegram-bot/blob/main/sinais.txt"

    %% Styles
    classDef config fill:#e1bee7,stroke:#333,stroke-width:2px;
    classDef telegram fill:#bbdefb,stroke:#333,stroke-width:2px;
    classDef core fill:#c8e6c9,stroke:#333,stroke-width:2px;
    classDef stable fill:#fff9c4,stroke:#333,stroke-width:2px;
    classDef http fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef ws fill:#f8bbd0,stroke:#333,stroke-width:2px;
    classDef logging fill:#e0e0e0,stroke:#333,stroke-width:2px;
    classDef signal fill:#b3e5fc,stroke:#333,stroke-width:2px;
```
