Files

39 lines
1.1 KiB
Markdown
Raw Permalink Normal View History

2026-02-21 07:43:33 +01:00
# positions
2024-02-12 21:09:28 +01:00
2026-02-21 07:43:33 +01:00
`aiomql.lib.positions` — Open position management.
2024-11-10 12:25:50 +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 `Positions` class provides methods for retrieving, counting, and closing open positions
in the MetaTrader 5 terminal.
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
Inherits from [`_Base`](../core/base.md).
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
## Classes
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
### `Positions`
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
> Manages open positions in MetaTrader 5.
2024-11-30 23:10:31 +01:00
2026-02-21 07:43:33 +01:00
#### Retrieval
2024-11-30 23:10:31 +01:00
2026-02-21 07:43:33 +01:00
| Method | Returns | Description |
|--------|---------|-------------|
| `positions_get(symbol, group, ticket)` | `tuple[TradePosition, …] \| None` | Get positions matching criteria |
| `positions_total()` | `int` | Total number of open positions |
| `get_by_ticket(ticket)` | `TradePosition \| None` | Get a position by ticket |
| `get_by_symbol(symbol)` | `tuple[TradePosition, …] \| None` | Get positions for a symbol |
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
#### Closing
2023-10-11 09:49:06 +01:00
2026-02-21 07:43:33 +01:00
| Method | Returns | Description |
|--------|---------|-------------|
| `close(*, ticket, symbol, volume, price, order_type)` | `OrderSendResult` | Close a position |
| `close_all()` | `None` | Close all open positions |
2024-11-10 12:25:50 +01:00
2026-02-21 07:43:33 +01:00
#### Counting
2024-05-05 00:08:57 +01:00
2026-02-21 07:43:33 +01:00
| Method | Returns | Description |
|--------|---------|-------------|
| `get_total_positions()` | `int` | Number of open positions |