# lucifer516-sudoer/syntiq_mt5 architecture

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

- Interactive diagram: https://gitdiagram.com/lucifer516-sudoer/syntiq_mt5
- Repository: https://github.com/lucifer516-sudoer/syntiq_mt5

## Overview

syntiq-mt5 is a typed Python interface to MetaTrader 5. The principal workflow is to create a managed session, initialize and authenticate the process-global terminal, request account, market, history, or trading data through the session, and receive validated typed values or operation-specific errors; leaving the context shuts the terminal down. The graph emphasizes the session and domain models, plus the adapter/native boundary and shared model/pricing layer. Several session methods and cleanup details are documented, but their implementation excerpts are incomplete, so those links are limited to indexed references or explicit README statements.

Main entry points: [`src/syntiq_mt5/session.py`](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/session.py) (Managed session), [`src/syntiq_mt5/_internal/model.py`](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/model.py) (Model base), [`src/syntiq_mt5/_internal/native.py`](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/native.py) (Native bridge), [`src/syntiq_mt5/symbols/models.py`](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/symbols/models.py) (Symbol and quote)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_lifecycle["Session and transport"]
  node_session["Managed session<br/>[session.py]"]
  node_adapter["Adapter seam<br/>[adapter.py]"]
  node_native["Native bridge<br/>[native.py]"]
  node_errors["Typed errors<br/>[errors.py]"]
end

subgraph group_market["Market data"]
  node_symbol["Symbol and quote<br/>[models.py]"]
  node_candles["OHLCV candles<br/>[candles.py]"]
  node_ticks["Tick records<br/>[models.py]"]
  node_book["Market book<br/>[models.py]"]
end

subgraph group_trading["Trading and history"]
  node_position["Open positions<br/>[models.py]"]
  node_orders["Orders and requests<br/>[models.py]"]
  node_deals["Trade history<br/>[models.py]"]
end

subgraph group_models["Typed models"]
  node_shared_model["Model base<br/>[model.py]"]
  node_pricing["Pip pricing<br/>[pricing.py]"]
  node_constants["Protocol constants<br/>[constants.py]"]
  node_enums["Typed enums<br/>[enums.py]"]
  node_account["Account snapshot<br/>[models.py]"]
  node_connection["Login credentials<br/>[models.py]"]
  node_terminal_info["Terminal snapshot<br/>[models.py]"]
end

node_user(("Python caller"))
node_terminal_service["MT5 terminal"]

node_user -->|"creates and enters"| node_session
node_session -->|"uses transport"| node_adapter
node_session -->|"uses bridge"| node_native
node_native -->|"references"| node_adapter
node_native -->|"raises"| node_errors
node_native -.->|"accesses extension"| node_terminal_service
node_session -->|"reports failures"| node_errors
node_session -->|"accepts credentials"| node_connection
node_session -->|"parses account"| node_account
node_session -->|"parses terminal state"| node_terminal_info
node_session -->|"parses symbol data"| node_symbol
node_session -->|"parses candle rows"| node_candles
node_session -->|"parses tick rows"| node_ticks
node_session -->|"parses book data"| node_book
node_session -->|"parses positions"| node_position
node_session -->|"handles trade results"| node_orders
node_session -->|"parses history"| node_deals
node_account -->|"extends"| node_shared_model
node_connection -->|"extends"| node_shared_model
node_terminal_info -->|"extends"| node_shared_model
node_symbol -->|"extends"| node_shared_model
node_symbol -->|"calculates pip size"| node_pricing
node_position -->|"extends"| node_shared_model
node_position -->|"calculates pip size"| node_pricing
node_candles -->|"extends"| node_shared_model
node_ticks -->|"extends"| node_shared_model
node_ticks -->|"checks flags"| node_constants
node_book -->|"extends"| node_shared_model
node_orders -->|"extends"| node_shared_model
node_orders -->|"uses enum types"| node_enums
node_deals -->|"extends"| node_shared_model
node_deals -->|"uses enum types"| node_enums
node_enums -->|"defines values from"| node_constants

click node_session "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/session.py"
click node_adapter "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/adapter.py"
click node_native "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/native.py"
click node_errors "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/errors.py"
click node_shared_model "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/model.py"
click node_pricing "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/pricing.py"
click node_constants "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/constants.py"
click node_enums "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/enums.py"
click node_account "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/account/models.py"
click node_connection "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/connection/models.py"
click node_terminal_info "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/terminal/models.py"
click node_symbol "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/symbols/models.py"
click node_candles "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/market/candles.py"
click node_ticks "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/ticks/models.py"
click node_book "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/market_book/models.py"
click node_position "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/positions/models.py"
click node_orders "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/orders/models.py"
click node_deals "https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/history/models.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_session,node_adapter,node_native,node_errors toneBlue
class node_symbol,node_candles,node_ticks,node_book toneAmber
class node_position,node_orders,node_deals toneMint
class node_shared_model,node_pricing,node_constants,node_enums,node_account,node_connection,node_terminal_info toneRose
class node_user,node_terminal_service toneIndigo
```

## Components

### Session and transport

- [Managed session](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/session.py): `src/syntiq_mt5/session.py`
- [Adapter seam](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/adapter.py): `src/syntiq_mt5/adapter.py`
- [Native bridge](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/native.py): `src/syntiq_mt5/_internal/native.py`
- [Typed errors](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/errors.py): `src/syntiq_mt5/errors.py`

### Market data

- [Symbol and quote](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/symbols/models.py): `src/syntiq_mt5/symbols/models.py`
- [OHLCV candles](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/market/candles.py): `src/syntiq_mt5/market/candles.py`
- [Tick records](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/ticks/models.py): `src/syntiq_mt5/ticks/models.py`
- [Market book](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/market_book/models.py): `src/syntiq_mt5/market_book/models.py`

### Trading and history

- [Open positions](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/positions/models.py): `src/syntiq_mt5/positions/models.py`
- [Orders and requests](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/orders/models.py): `src/syntiq_mt5/orders/models.py`
- [Trade history](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/history/models.py): `src/syntiq_mt5/history/models.py`

### Typed models

- [Model base](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/model.py): `src/syntiq_mt5/_internal/model.py`
- [Pip pricing](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/_internal/pricing.py): `src/syntiq_mt5/_internal/pricing.py`
- [Protocol constants](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/constants.py): `src/syntiq_mt5/constants.py`
- [Typed enums](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/enums.py): `src/syntiq_mt5/enums.py`
- [Account snapshot](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/account/models.py): `src/syntiq_mt5/account/models.py`
- [Login credentials](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/connection/models.py): `src/syntiq_mt5/connection/models.py`
- [Terminal snapshot](https://github.com/lucifer516-sudoer/syntiq_mt5/blob/main/src/syntiq_mt5/terminal/models.py): `src/syntiq_mt5/terminal/models.py`

### Other components

- **Python caller**
- **MT5 terminal**

## Connections

- Python caller → Managed session: creates and enters (evidence: `README.md`)
- Managed session → Adapter seam: uses transport (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Native bridge: uses bridge (evidence: `src/syntiq_mt5/session.py`)
- Native bridge → Adapter seam: references (evidence: `src/syntiq_mt5/_internal/native.py`)
- Native bridge → Typed errors: raises (evidence: `src/syntiq_mt5/_internal/native.py`)
- Native bridge → MT5 terminal: accesses extension (evidence: `README.md`)
- Managed session → Typed errors: reports failures (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Login credentials: accepts credentials (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Account snapshot: parses account (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Terminal snapshot: parses terminal state (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Symbol and quote: parses symbol data (evidence: `src/syntiq_mt5/session.py`)
- Managed session → OHLCV candles: parses candle rows (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Tick records: parses tick rows (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Market book: parses book data (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Open positions: parses positions (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Orders and requests: handles trade results (evidence: `src/syntiq_mt5/session.py`)
- Managed session → Trade history: parses history (evidence: `src/syntiq_mt5/session.py`)
- Account snapshot → Model base: extends (evidence: `src/syntiq_mt5/account/models.py`)
- Login credentials → Model base: extends (evidence: `src/syntiq_mt5/connection/models.py`)
- Terminal snapshot → Model base: extends (evidence: `src/syntiq_mt5/terminal/models.py`)
- Symbol and quote → Model base: extends (evidence: `src/syntiq_mt5/symbols/models.py`)
- Symbol and quote → Pip pricing: calculates pip size (evidence: `src/syntiq_mt5/symbols/models.py`)
- Open positions → Model base: extends (evidence: `src/syntiq_mt5/positions/models.py`)
- Open positions → Pip pricing: calculates pip size (evidence: `src/syntiq_mt5/positions/models.py`)
- OHLCV candles → Model base: extends (evidence: `src/syntiq_mt5/market/candles.py`)
- Tick records → Model base: extends (evidence: `src/syntiq_mt5/ticks/models.py`)
- Tick records → Protocol constants: checks flags (evidence: `src/syntiq_mt5/ticks/models.py`)
- Market book → Model base: extends (evidence: `src/syntiq_mt5/market_book/models.py`)
- Orders and requests → Model base: extends (evidence: `src/syntiq_mt5/orders/models.py`)
- Orders and requests → Typed enums: uses enum types (evidence: `src/syntiq_mt5/orders/models.py`)
- Trade history → Model base: extends (evidence: `src/syntiq_mt5/history/models.py`)
- Trade history → Typed enums: uses enum types (evidence: `src/syntiq_mt5/history/models.py`)
- Typed enums → Protocol constants: defines values from (evidence: `src/syntiq_mt5/enums.py`)
