Files
aiomql/docs/lib/history.md
T

54 lines
1.7 KiB
Markdown
Raw Normal View History

2026-02-21 07:43:33 +01:00
# history
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
`aiomql.lib.history` — Historical deals and orders retrieval.
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
The `History` class retrieves completed trade deals and orders from the MetaTrader 5 terminal
for a specified date range. Results are cached for efficient filtering and querying.
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
Inherits from [`_Base`](../core/base.md).
2024-11-10 12:25:50 +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
### `History`
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
> Retrieves and caches historical deals and orders.
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
| Attribute | Type | Description |
|-----------|------|-------------|
| `deals` | `tuple[TradeDeal, ...]` | Cached deals |
| `orders` | `tuple[TradeOrder, ...]` | Cached orders |
| `total_deals` | `int` | Total deal count in range |
| `total_orders` | `int` | Total order count in range |
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
#### Initialization
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
| Method | Description |
|--------|-------------|
| `init(date_from, date_to)` | Fetches deals and orders for the date range |
| `get_deals(date_from, date_to)` | Fetches deals only |
| `get_orders(date_from, date_to)` | Fetches orders only |
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
#### Filtering Deals
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
| Method | Description |
|--------|-------------|
| `filter_deals_by_symbol(symbol)` | Filter deals by symbol name |
| `filter_deals_by_ticket(ticket)` | Filter deals by ticket number |
| `filter_deals_by_position(position)` | Filter deals by position ID |
| `get_deals_by_position(position)` | Get all deals for a position |
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
#### Filtering Orders
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
| Method | Description |
|--------|-------------|
| `filter_orders_by_symbol(symbol)` | Filter orders by symbol name |
| `filter_orders_by_ticket(ticket)` | Filter orders by ticket number |
| `filter_orders_by_position(position)` | Filter orders by position ID |
| `get_orders_by_position(position)` | Get all orders for a position |
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
## Synchronous API
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
A synchronous variant is available in `aiomql.lib.sync.history`.