Files
aiomql/docs/core/models.md
T

112 lines
2.7 KiB
Markdown
Raw Normal View History

2026-02-21 07:43:33 +01:00
# models
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
`aiomql.core.models` — Data models mirroring MetaTrader 5 structures.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
## Overview
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
Defines data-model classes that correspond to the named-tuple structures returned by the
MetaTrader 5 terminal. All models inherit from [`Base`](base.md) and provide typed attributes,
dictionary conversion, and string representations.
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
## Classes
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
### `AccountInfo`
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
> Trading account information.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
Key fields: `login`, `server`, `trade_mode`, `balance`, `leverage`, `profit`, `equity`,
`margin`, `margin_free`, `margin_level`, `currency`.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
---
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
### `TerminalInfo`
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
> MetaTrader 5 terminal details.
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
Key fields: `connected`, `trade_allowed`, `tradeapi_disabled`, `build`, `company`,
`name`, `path`, `data_path`.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
---
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
### `SymbolInfo`
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
> Trading instrument (symbol) properties.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
Extensive attributes covering pricing, volume limits, spread, margin parameters, swap
settings, option properties, and session schedules.
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
| Method / Property | Description |
|-------------------|-------------|
| `__repr__()` | `"SymbolInfo(name=<name>)"` |
| `__str__()` | The symbol name |
| `__eq__(other)` | Equality by symbol name |
| `__hash__()` | Hash of the symbol name |
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
---
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
### `BookInfo`
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
> Market depth entry.
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
Fields: `type` (`BookType`), `price`, `volume`, `volume_dbl`.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
---
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
### `TradeOrder`
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
> Pending or historical order.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
Key fields: `ticket`, `type` (`OrderType`), `state`, `time_setup`, `volume_current`,
`volume_initial`, `price_open`, `sl`, `tp`, `symbol`, `comment`.
2024-11-15 21:13:19 +01:00
2026-02-21 07:43:33 +01:00
---
### `TradeRequest`
> Trade request structure sent to `order_send` / `order_check`.
Key fields: `action` (`TradeAction`), `type` (`OrderType`), `symbol`, `volume`,
`price`, `sl`, `tp`, `deviation`, `magic`, `comment`, `type_filling`, `type_time`.
---
### `OrderCheckResult`
> Result of `order_check`.
Key fields: `retcode`, `balance`, `equity`, `profit`, `margin`, `margin_free`,
`margin_level`, `request` (`TradeRequest`), `comment`.
| Method | Description |
|--------|-------------|
| `__init__(**kwargs)` | Converts `request` dict to `TradeRequest` |
| `__getstate__()` | Serialises `request` as a plain dict |
| `__setstate__(state)` | Restores `request` from dict |
---
### `OrderSendResult`
> Result of `order_send`.
Key fields: `retcode`, `deal`, `order`, `volume`, `price`, `bid`, `ask`,
`request` (`TradeRequest`), `comment`, `request_id`.
---
### `TradePosition`
> Open position information.
Key fields: `ticket`, `type` (`PositionType`), `symbol`, `volume`, `price_open`,
`price_current`, `sl`, `tp`, `profit`, `swap`, `magic`, `comment`.
---
### `TradeDeal`
> Completed deal record.
Key fields: `ticket`, `type` (`DealType`), `entry` (`DealEntry`), `symbol`, `volume`,
`price`, `profit`, `swap`, `commission`, `magic`, `comment`, `position_id`, `order`.