This commit is contained in:
Ichinga Samuel
2024-02-12 21:09:28 +01:00
parent 3f53df8375
commit b01e58ee08
68 changed files with 2986 additions and 6869 deletions
+70 -124
View File
@@ -1,163 +1,109 @@
# Table of Contents
# Base Class
* [aiomql.core.base](#aiomql.core.base)
* [Base](#aiomql.core.base.Base)
* [set\_attributes](#aiomql.core.base.Base.set_attributes)
* [annotations](#aiomql.core.base.Base.annotations)
* [get\_dict](#aiomql.core.base.Base.get_dict)
* [class\_vars](#aiomql.core.base.Base.class_vars)
* [dict](#aiomql.core.base.Base.dict)
* [Meta](#aiomql.core.base.Base.Meta)
<a id="aiomql.core.base"></a>
# aiomql.core.base
<a id="aiomql.core.base.Base"></a>
## Base Objects
## Table of Contents
- [Base](#base)
- [set\_attributes](#base.set_attributes)
- [annotations](#base.annotations)
- [get\_dict](#base.get_dict)
- [class\_vars](#base.class_vars)
- [dict](#base.dict)
<a id="base"></a>
### Base
```python
class Base()
class Base
```
A base class for all data model classes in the aiomql package.
This class provides a set of common methods and attributes for all data model classes.
For the data model classes attributes are annotated on the class body and are set as object attributes when the
class is instantiated.
A base class for all data model classes in the aiomql package. This class provides a set of common methods
and attributes for all data model classes.
**Arguments**:
#### Class Attributes
| Name | Type | Description | Default |
|----------|--------------|-------------------------------------|---------|
| `mt5` | `MetaTrader` | An instance of the MetaTrader class | |
| `config` | `Config` | An instance of the Config class | |
- `**kwargs` - Object attributes and values as keyword arguments. Only added if they are annotated on the class body.
Class Attributes:
- `mt5` _MetaTrader_ - An instance of the MetaTrader class
- `config` _Config_ - An instance of the Config class
- `Meta` _Type[Meta]_ - The Meta class for configuration of the data model class
<a id="aiomql.core.base.Base.set_attributes"></a>
#### set\_attributes
<a id="base.__init__"></a>
### __init__
```python
def __init__(**kwargs)
```
#### Parameters:
| Name | Type | Description |
|----------|-------|---------------------------------------------------|
| `kwargs` | `Any` | Object attributes and values as keyword arguments |
<a id="base.set_attributes"></a>
### set_attributes
```python
def set_attributes(**kwargs)
```
Set keyword arguments as object attributes. Only sets attributes that have been annotated on the class body.
#### Parameters
| Name | Type | Description |
|----------|-------|---------------------------------------------------|
| `kwargs` | `Any` | Object attributes and values as keyword arguments |
Set keyword arguments as object attributes
#### Raises
| Exception | Description |
|------------------|-----------------------------------------------------------------------------------|
| `AttributeError` | When assigning an attribute that does not belong to the class or any parent class |
**Arguments**:
- `**kwargs` - Object attributes and values as keyword arguments
**Raises**:
- `AttributeError` - When assigning an attribute that does not belong to the class or any parent class
**Notes**:
Only sets attributes that have been annotated on the class body.
<a id="aiomql.core.base.Base.annotations"></a>
#### annotations
#### Notes
Only sets attributes that have been annotated on the class body.
<a id="base.annotations"></a>
### annotations
```python
@property
@cache
def annotations() -> dict
```
Class annotations from all ancestor classes and the current class.
#### Returns
| Type | Description |
|--------|-----------------------------------|
| `dict` | A dictionary of class annotations |
**Returns**:
- `dict` - A dictionary of class annotations
<a id="aiomql.core.base.Base.get_dict"></a>
<a id="base.get_dict"></a>
#### get\_dict
```python
def get_dict(exclude: set = None, include: set = None) -> dict
```
Returns class attributes as a dict, with the ability to filter
#### Parameters
| Name | Type | Description |
|-----------|-------|------------------------------------|
| `exclude` | `set` | A set of attributes to be excluded |
| `include` | `set` | Specific attributes to be returned |
#### Returns
| Type | Description |
|--------|--------------------------------------------|
| `dict` | A dictionary of specified class attributes |
**Arguments**:
- `exclude` - A set of attributes to be excluded
- `include` - Specific attributes to be returned
**Returns**:
- `dict` - A dictionary of specified class attributes
**Notes**:
You can only set either of include or exclude. If you set both, include will take precedence
<a id="aiomql.core.base.Base.class_vars"></a>
#### class\_vars
#### Notes
You can only set either of include or exclude. If you set both, include will take precedence
<a id="base.class_vars"></a>
### class\_vars
```python
@property
@cache
def class_vars()
```
Annotated class attributes
#### Returns
| Type | Description |
|--------|-------------------------------------------------------------------------------------------|
| `dict` | A dictionary of available class attributes in all ancestor classes and the current class. |
**Returns**:
- `dict` - A dictionary of available class attributes in all ancestor classes and the current class.
<a id="aiomql.core.base.Base.dict"></a>
#### dict
<a id="base.dict"></a>
### dict
```python
@property
def dict() -> dict
```
All instance and class attributes as a dictionary, except those excluded in the Meta class.
**Returns**:
- `dict` - A dictionary of instance and class attributes
<a id="aiomql.core.base.Base.Meta"></a>
## Meta Objects
```python
class Meta()
```
A class for defining class attributes to be excluded or included in the dict property
**Attributes**:
- `exclude` _set_ - A set of attributes to be excluded
- `include` _set_ - Specific attributes to be returned. Include supercedes exclude.
<a id="aiomql.core.base.Base.Meta.filter"></a>
#### filter
```python
@classmethod
@property
def filter(cls) -> set
```
Combine the exclude and include attributes to return a set of attributes to be excluded.
**Returns**:
- `set` - A set of attributes to be excluded
#### Returns
| Type | Description |
|--------|-----------------------------------------------|
| `dict` | A dictionary of instance and class attributes |
+60 -47
View File
@@ -1,59 +1,72 @@
# Table of Contents
# Config
* [aiomql.core.config](#aiomql.core.config)
* [Config](#aiomql.core.config.Config)
* [account\_info](#aiomql.core.config.Config.account_info)
<a id="aiomql.core.config"></a>
# aiomql.core.config
<a id="aiomql.core.config.Config"></a>
## Config Objects
## Table of Contents
- [Config](#config.Config)
- [account\_info](#config.account_info)
- [load\_config](#config.load_config)
- [create\_records\_dir](#config.create_records_dir)
<a id="config.Config"></a>
```python
class Config()
class Config
```
A class for handling configuration settings for the aiomql package. A single instance of this class is created and used
per bot instance.
### Class Attributes
| Name | Type | Description | Default |
|------------------|--------------|-----------------------------------------------------|-----------------------------------------------------|
| `record\_trades` | `bool` | Whether to keep record of trades or not. | True |
| `filename` | `str` | Name of the config file | aiomql.json |
| `records\_dir` | `str\| Path` | Path to the directory where trade records are saved | Should be relative to the project root |
| `login` | `str` | Trading account number | |
| `password` | `str` | Trading account password | |
| `server` | `str` | Broker server | |
| `path` | `str\|Path` | Path to terminal file | Absolute |
| `timeout` | `int` | Timeout for terminal connection | |
| `config_dir` | `str` | Directory where the config file is located | Optional. Should be relative to the root directory |
| `state` | `dict` | A global state object | |
| `task_queue` | `Queue` | A global queue for handling tasks | |
| `bot` | `Bot` | The bot instance | Added to the config object after bot initialization |
| `root_dir` | `str` | Root directory of the project | |
A class for handling configuration settings for the aiomql package.
**Arguments**:
- `**kwargs` - Configuration settings as keyword arguments.
Variables set this way supersede those set in the config file.
**Attributes**:
- `record_trades` _bool_ - Whether to keep record of trades or not.
- `filename` _str_ - Name of the config file
- `records_dir` _str_ - Path to the directory where trade records are saved
- `win_percentage` _float_ - Percentage of achieved target profit in a trade to be considered a win
- `login` _int_ - Trading account number
- `password` _str_ - Trading account password
- `server` _str_ - Broker server
- `path` _str_ - Path to terminal file
- `timeout` _int_ - Timeout for terminal connection
**Notes**:
By default, the config class looks for a file named aiomql.json.
You can change this by passing the filename keyword argument to the constructor.
By passing reload=True to the load_config method, you can reload and search again for the config file.
<a id="aiomql.core.config.Config.account_info"></a>
#### account\_info
#### Notes
By default, the config class looks for a file named aiomql.json.
You can change this by passing the filename keyword argument to the constructor.
By passing reload=True to the load_config method, you can reload and search again for the config file.
<a id="config.account_info"></a>
### account\_info
```python
def account_info() -> dict['login', 'password', 'server']
```
Returns Account login details as found in the config object if available
#### Returns
| Type | Description |
|--------|-------------------------------------------------------|
| `dict` | A dictionary with login, password, and server details |
**Returns**:
- `dict` - A dictionary of login details
<a id="config.load_config"></a>
### load\_config
```python
def load_config(self, *, file: str = None, reload: bool = True, filename: str = None, config_dir: str = '')
```
Load configuration settings from a file.
#### Parameters
| Name | Type | Description |
|--------------|--------|-------------------------------------------------------------------------------------------------------------|
| `file` | `str` | The file to load the configuration settings from. If not provided, the default file is used. |
| `reload` | `bool` | Whether to reload the configuration settings or not. |
| `filename` | `str` | The name of the file to load the configuration settings from. If not provided, the default filename is used |
| `config_dir` | `str` | The directory where the configuration file is located. Default is the root directory |
<a id="config.create_records_dir"></a>
### create_records_dir
```python
def create_records_dir(self, *, records_dir: str | Path = 'records'):
```
Create a directory for saving trade records.
#### Parameters
| Name | Type | Description |
|----------------|-------------|-------------------------------------------------------------------|
| `records\_dir` | `str\|Path` | The directory where trade records are saved. Default is 'records' |
+403 -561
View File
File diff suppressed because it is too large Load Diff
+23 -12
View File
@@ -1,19 +1,30 @@
# Table of Contents
# Errors
* [aiomql.core.errors](#aiomql.core.errors)
* [Error](#aiomql.core.errors.Error)
<a id="aiomql.core.errors"></a>
# aiomql.core.errors
<a id="aiomql.core.errors.Error"></a>
## Error Objects
## Tabel of contents
- [Error](#errors.Error)
- [is_connection_error](#errors.is_connection_error)
<a id="errors.Error"></a>
## Error
```python
class Error()
```
Error class for handling errors from MetaTrader 5.
#### Attributes
| Name | Type | Description |
|----------------|--------|----------------------------------------------|
| `code` | `int` | Error code |
| `description` | `str` | Error description |
| `descriptions` | `dict` | A dictionary of error codes and descriptions |
<a id="errors.is_connection_error"></a>
## is_connection_error
```python
def is_connection_error(self) -> bool
```
Check if error is a connection error.
#### Returns
| Type | Description |
|--------|------------------------------------------------------|
| `bool` | True if error is a connection error, False otherwise |
+16 -33
View File
@@ -1,54 +1,37 @@
# Table of Contents
* [aiomql.core.exceptions](#aiomql.core.exceptions)
* [LoginError](#aiomql.core.exceptions.LoginError)
* [VolumeError](#aiomql.core.exceptions.VolumeError)
* [SymbolError](#aiomql.core.exceptions.SymbolError)
* [OrderError](#aiomql.core.exceptions.OrderError)
<a id="aiomql.core.exceptions"></a>
# aiomql.core.exceptions
# Exceptions
Exceptions for the aiomql package.
<a id="aiomql.core.exceptions.LoginError"></a>
## LoginError Objects
## Table of Contents
- [LoginError](#exceptions.LoginError)
- [VolumeError](#exceptions.VolumeError)
- [SymbolError](#exceptions.SymbolError)
- [OrderError](#exceptions.OrderError)
<a id="exceptions.LoginError"></a>
### LoginError
```python
class LoginError(Exception)
```
Raised when an error occurs when logging in.
<a id="aiomql.core.exceptions.VolumeError"></a>
## VolumeError Objects
<a id="exceptions.VolumeError"></a>
### VolumeError
```python
class VolumeError(Exception)
```
Raised when a volume is not valid or out of range for a symbol.
<a id="aiomql.core.exceptions.SymbolError"></a>
## SymbolError Objects
<a id="exceptions.SymbolError"></a>
### SymbolError
```python
class SymbolError(Exception)
```
Raised when a symbol is not provided where required or not available in the Market Watch.
<a id="aiomql.core.exceptions.OrderError"></a>
## OrderError Objects
<a id="exceptions.OrderError"></a>
### OrderError
```python
class OrderError(Exception)
```
Raised when an error occurs when working with the order class.
Raised when an error occurs when working with the order class.
+349 -348
View File
@@ -1,40 +1,43 @@
* [MetaTrader](#MetaTrader)
* [\_\_aenter\_\_](#MetaTrader.__aenter__)
* [\_\_aexit\_\_](#MetaTrader.__aexit__)
* [login](#MetaTrader.login)
* [initialize](#MetaTrader.initialize)
* [shutdown](#MetaTrader.shutdown)
* [version](#MetaTrader.version)
* [account\_info](#MetaTrader.account_info)
* [terminal\_info](#MetaTrader.terminal_info)
* [last\_error](#MetaTrader.last_error)
* [symbols\_total](#MetaTrader.symbols_total)
* [symbols\_get](#MetaTrader.symbols_get)
* [symbol\_info](#MetaTrader.symbol_info)
* [symbol\_info\_tick](#MetaTrader.symbol_info_tick)
* [symbol\_select](#MetaTrader.symbol_select)
* [market\_book\_add](#MetaTrader.market_book_add)
* [market\_book\_get](#MetaTrader.market_book_get)
* [market\_book\_release](#MetaTrader.market_book_release)
* [copy\_rates\_from](#MetaTrader.copy_rates_from)
* [copy\_rates\_from\_pos](#MetaTrader.copy_rates_from_pos)
* [copy\_rates\_range](#MetaTrader.copy_rates_range)
* [copy\_ticks\_from](#MetaTrader.copy_ticks_from)
* [copy\_ticks\_range](#MetaTrader.copy_ticks_range)
* [orders\_total](#MetaTrader.orders_total)
* [orders\_get](#MetaTrader.orders_get)
* [order\_calc\_margin](#MetaTrader.order_calc_margin)
* [order\_calc\_profit](#MetaTrader.order_calc_profit)
* [order\_check](#MetaTrader.order_check)
* [order\_send](#MetaTrader.order_send)
* [positions\_total](#MetaTrader.positions_total)
* [positions\_get](#MetaTrader.positions_get)
* [history\_orders\_total](#MetaTrader.history_orders_total)
* [history\_orders\_get](#MetaTrader.history_orders_get)
* [history\_deals\_total](#MetaTrader.history_deals_total)
* [history\_deals\_get](#MetaTrader.history_deals_get)
# MetaTrader
The MetaTrader Class provides an asynchronous wrapper around the MetaTrader5 API.
## Table of Contents
- [MetaTrader](#MetaTrader)
- [\_\_aenter\_\_](#__aenter__)
- [\_\_aexit\_\_](#__aexit__)
- [login](#login)
- [initialize](#initialize)
- [shutdown](#shutdown)
- [version](#version)
- [account\_info](#account_info)
- [terminal\_info](#terminal_info)
- [last\_error](#last_error)
- [symbols\_total](#symbols_total)
- [symbols\_get](#symbols_get)
- [symbol\_info](#symbol_info)
- [symbol\_info\_tick](#symbol_info_tick)
- [symbol\_select](#symbol_select)
- [market\_book\_add](#market_book_add)
- [market\_book\_get](#market_book_get)
- [market\_book\_release](#market_book_release)
- [copy\_rates\_from](#copy_rates_from)
- [copy\_rates\_from\_pos](#copy_rates_from_pos)
- [copy\_rates\_range](#copy_rates_range)
- [copy\_ticks\_from](#copy_ticks_from)
- [copy\_ticks\_range](#copy_ticks_range)
- [orders\_total](#orders_total)
- [orders\_get](#orders_get)
- [order\_calc\_margin](#order_calc_margin)
- [order\_calc\_profit](#order_calc_profit)
- [order\_check](#order_check)
- [order\_send](#order_send)
- [positions\_total](#positions_total)
- [positions\_get](#positions_get)
- [history\_orders\_total](#history_orders_total)
- [history\_orders\_get](#history_orders_get)
- [history\_deals\_total](#history_deals_total)
- [history\_deals\_get](#history_deals_get)
<a id="MetaTrader"></a>
### MetaTrader
```python
@@ -42,17 +45,16 @@ class MetaTrader(metaclass=BaseMeta)
```
The MetaTrader class is a wrapper around the MetaTrader terminal.
It provides methods for connecting to the MetaTrader terminal and retrieving data from it.
#### Attributes:
|Name|Type|Description|Default|
|---|---|---|---|
|error|Error|The last error encountered by the MetaTrader terminal.|Error(0, '')|
#### Attributes
| Name | Type | Description | Default |
|-------|-------|--------------------------------------------------------|------------------------|
| error | Error | The last error encountered by the MetaTrader terminal. | Error(1, 'Successful') |
#### Notes:
#### Notes
All the attributes, enums and constants of the MetaTrader5 class are also available here. Although, they are more easily
accessible and used via the various enums and models defined in the module.
<a id="MetaTrader.__aenter__"></a>
<a id="__aenter__"></a>
#### \_\_aenter\_\_
```python
async def __aenter__() -> 'MetaTrader'
@@ -60,19 +62,19 @@ async def __aenter__() -> 'MetaTrader'
Async context manager entry point.
Initializes the connection to the MetaTrader terminal.
#### Returns:
|Type|Description|
|---|---|
|**MetaTrader**|An instance of the MetaTrader class|
#### Returns
| Type | Description |
|--------------|-------------------------------------|
| `MetaTrader` | An instance of the MetaTrader class |
<a id="MetaTrader.__aexit__"></a>
<a id="__aexit__"></a>
#### \_\_aexit\_\_
```python
async def __aexit__(exc_type, exc_val, exc_tb)
```
Async context manager exit point. Closes the connection to the MetaTrader terminal.
<a id="MetaTrader.login"></a>
<a id="login"></a>
#### login
```python
async def login(login: int,
@@ -81,19 +83,19 @@ async def login(login: int,
timeout: int = 60000) -> bool
```
Connects to the MetaTrader terminal using the specified login, password and server.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**login**|**int**|The trading account number.|
|**password**|**str**|The trading account password.|
|**server**|**str**|The trading server name.|
|**timeout**|**int**|The timeout for the connection in seconds.|
#### Parameters
| Name | Type | Description |
|------------|-------|--------------------------------------------|
| `login` | `int` | The trading account number. |
| `password` | `str` | The trading account password. |
| `server` | `str` | The trading server name. |
| `timeout` | `int` | The timeout for the connection in seconds. |
#### Returns:
|Type|Description|
|---|---|
|**bool**|True if successful, False otherwise.|
| Type | Description |
|--------|--------------------------------------|
| `bool` | True if successful, False otherwise. |
<a id="MetaTrader.initialize"></a>
<a id="initialize"></a>
#### initialize
```python
async def initialize(path: str = "",
@@ -104,191 +106,191 @@ async def initialize(path: str = "",
portable=False) -> bool
```
Initializes the connection to the MetaTrader terminal. All parameters are optional.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**path**|**str**|The path to the MetaTrader terminal executable.|
|**login**|**int**|The trading account number.|
|**password**|**str**|The trading account password.|
|**server**|**str**|The trading server name.|
|**timeout**|**int** or **None**|The timeout for the connection in seconds.|
|**portable**|**bool**|If True, the terminal will be launched in portable mode.|
#### Returns:
|Type|Description|
|---|---|
|**bool**|True if successful, False otherwise.|
#### Parameters
| Name | Type | Description |
|------------|-----------------|----------------------------------------------------------|
| `path` | `str` | The path to the MetaTrader terminal executable. |
| `login` | `int` | The trading account number. |
| `password` | `str` | The trading account password. |
| `server` | `str` | The trading server name. |
| `timeout` | `int` or `None` | The timeout for the connection in seconds. |
| `portable` | `bool` | If True, the terminal will be launched in portable mode. |
#### Returns
| Type | Description |
|--------|--------------------------------------|
| `bool` | True if successful, False otherwise. |
<a id="MetaTrader.shutdown"></a>
<a id="shutdown"></a>
#### shutdown
```python
async def shutdown() -> None
```
Closes the connection to the MetaTrader terminal.
<a id="MetaTrader.version"></a>
<a id="version"></a>
#### version
```python
async def version() -> tuple[int, int, str] | None
```
Returns the version of the MetaTrader terminal.
#### Returns:
|Type| Description |
|---|-----------------------------------------------------------------------------------------------------|
|**tuple[int, int, str]**| A tuple of the MetaTrader terminal version. **Terminal Version**, **Build**, **Build Release Date** |
#### Returns
| Type | Description |
|------------------------|-----------------------------------------------------------------------------------------------|
| `tuple[int, int, str]` | A tuple of the MetaTrader terminal version. `Terminal Version`, `Build`, `Build Release Date` |
<a id="MetaTrader.account_info"></a>
<a id="account_info"></a>
#### account\_info
```python
async def account_info() -> AccountInfo | None
```
Returns the account information for the connected account.
#### Returns:
|Type|Description|
|---|---|
|**AccountInfo**|An instance of the AccountInfo class|
#### Returns
| Type | Description |
|---------------|--------------------------------------|
| `AccountInfo` | An instance of the AccountInfo class |
<a id="MetaTrader.terminal_info"></a>
<a id="terminal_info"></a>
#### terminal\_info
```python
async def terminal_info() -> TerminalInfo | None
```
Returns the terminal information for the connected terminal.
#### Returns:
|Type| Description |
|---|------------------------------------------------|
|**TerminalInfo**| An instance of the TerminalInfo class. A tuple |
#### Returns
| Type | Description |
|----------------|------------------------------------------------|
| `TerminalInfo` | An instance of the TerminalInfo class. A tuple |
<a id="MetaTrader.last_error"></a>
<a id="last_error"></a>
#### last\_error
```python
async def last_error() -> tuple[int, str]
```
Returns the last error code and description.
#### Returns:
|Type|Description|
|---|---|
|**tuple[int, str]**|A tuple of the last error code and description.|
#### Returns
| Type | Description |
|-------------------|-------------------------------------------------|
| `tuple[int, str]` | A tuple of the last error code and description. |
<a id="MetaTrader.symbols_total"></a>
<a id="symbols_total"></a>
#### symbols\_total
```python
async def symbols_total() -> int
```
Returns the total number of symbols.
#### Returns:
|Type|Description|
|---|---|
|**int**|The total number of symbols.|
#### Returns
| Type | Description |
|-------|------------------------------|
| `int` | The total number of symbols. |
<a id="MetaTrader.symbols_get"></a>
<a id="symbols_get"></a>
#### symbols\_get
```python
async def symbols_get(group: str = "") -> tuple[SymbolInfo] | None
```
Returns the symbol information for all symbols or for a specified group.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**group**|**str**|The group name. Optional named parameter. If the group is specified, the function returns only symbols meeting a specified criteria for a symbol name.|
#### Returns:
|Type|Description|
|---|---|
|**tuple[SymbolInfo]**|A tuple of SymbolInfo objects.|
#### Parameters
| Name | Type | Description |
|---------|-------|--------------------------------------------------------------------------------------------------------------------------------------------------------|
| `group` | `str` | The group name. Optional named parameter. If the group is specified, the function returns only symbols meeting a specified criteria for a symbol name. |
#### Returns
| Type | Description |
|---------------------|--------------------------------|
| `tuple[SymbolInfo]` | A tuple of SymbolInfo objects. |
<a id="MetaTrader.symbol_info"></a>
<a id="symbol_info"></a>
#### symbol\_info
```python
async def symbol_info(symbol: str) -> SymbolInfo | None
```
Returns the symbol information for the specified symbol.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
#### Parameters
| Name | Type | Description |
|----------|-------|------------------|
| `symbol` | `str` | The symbol name. |
#### Returns:
|Type|Description|
|---|---|
|**SymbolInfo**|An instance of the SymbolInfo class.|
| Type | Description |
|--------------|--------------------------------------|
| `SymbolInfo` | An instance of the SymbolInfo class. |
<a id="MetaTrader.symbol_info_tick"></a>
<a id="symbol_info_tick"></a>
#### symbol\_info\_tick
```python
async def symbol_info_tick(symbol: str) -> Tick | None
```
Returns the latest tick for the specified symbol.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
#### Returns:
|Type|Description|
|---|---|
|**Tick**|An instance of the Tick class.|
#### Parameters
| Name | Type | Description |
|----------|-------|------------------|
| `symbol` | `str` | The symbol name. |
#### Returns
| Type | Description |
|--------|--------------------------------|
| `Tick` | An instance of the Tick class. |
<a id="MetaTrader.symbol_select"></a>
<a id="symbol_select"></a>
#### symbol\_select
```python
async def symbol_select(symbol: str, enable: bool) -> bool
```
Selects or unselects the specified symbol in the Market Watch window.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**enable**|**bool**|If True, the symbol will be selected. If False, the symbol will be unselected.|
#### Returns:
|Type|Description|
|---|---|
|**bool**|True if successful, False otherwise.|
#### Parameters
| Name | Type | Description |
|----------|--------|--------------------------------------------------------------------------------|
| `symbol` | `str` | The symbol name. |
| `enable` | `bool` | If True, the symbol will be selected. If False, the symbol will be unselected. |
#### Returns
| Type | Description |
|--------|--------------------------------------|
| `bool` | True if successful, False otherwise. |
<a id="MetaTrader.market_book_add"></a>
<a id="market_book_add"></a>
#### market\_book\_add
```python
async def market_book_add(symbol: str) -> bool
```
Adds the specified symbol to the market book.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
#### Returns:
|Type|Description|
|---|---|
|**bool**|True if successful, False otherwise.|
#### Parameters
| Name | Type | Description |
|----------|-------|------------------|
| `symbol` | `str` | The symbol name. |
#### Returns
| Type | Description |
|--------|--------------------------------------|
| `bool` | True if successful, False otherwise. |
<a id="MetaTrader.market_book_get"></a>
<a id="market_book_get"></a>
#### market\_book\_get
```python
async def market_book_get(symbol: str) -> tuple[BookInfo] | None
```
Returns the market depth for the specified symbol.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
#### Returns:
|Type|Description|
|---|---|
|**tuple[BookInfo]**|A tuple of BookInfo objects.|
#### Parameters
| Name | Type | Description |
|----------|-------|------------------|
| `symbol` | `str` | The symbol name. |
#### Returns
| Type | Description |
|-------------------|------------------------------|
| `tuple[BookInfo]` | A tuple of BookInfo objects. |
<a id="MetaTrader.market_book_release"></a>
<a id="market_book_release"></a>
#### market\_book\_release
```python
async def market_book_release(symbol: str) -> bool
```
Removes the specified symbol from the market book.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
#### Returns:
|Type|Description|
|---|---|
|**bool**|True if successful, False otherwise.|
#### Parameters
| Name | Type | Description |
|----------|-------|------------------|
| `symbol` | `str` | The symbol name. |
#### Returns
| Type | Description |
|--------|--------------------------------------|
| `bool` | True if successful, False otherwise. |
<a id="MetaTrader.copy_rates_from"></a>
<a id="copy_rates_from"></a>
#### copy\_rates\_from
```python
@@ -301,19 +303,19 @@ async def copy_rates_from(symbol: str,
count: int) -> numpy.ndarray | None
```
Returns the OHLCV rates for the specified symbol and timeframe starting from the specified date.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**timeframe**|**TimeFrame**|The timeframe.|
|**date_from**|**datetime** or **int**|The date to start from.|
|**count**|**int**|The number of rates to return.|
#### Returns:
|Type|Description|
|---|---|
|**numpy.ndarray**|A numpy array of OHLCV rates.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|--------------------------------|
| `symbol` | `str` | The symbol name. |
| `timeframe` | `TimeFrame` | The timeframe. |
| `date_from` | `datetime` or `int` | The date to start from. |
| `count` | `int` | The number of rates to return. |
#### Returns
| Type | Description |
|-----------------|-------------------------------|
| `numpy.ndarray` | A numpy array of OHLCV rates. |
<a id="MetaTrader.copy_rates_from_pos"></a>
<a id="copy_rates_from_pos"></a>
#### copy\_rates\_from\_pos
```python
async def copy_rates_from_pos(symbol: str,
@@ -322,19 +324,19 @@ async def copy_rates_from_pos(symbol: str,
count: int) -> numpy.ndarray | None
```
Returns the OHLCV rates for the specified symbol and timeframe starting from the specified position.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**timeframe**|**TimeFrame**|The timeframe.|
|**start_pos**|**int**|The position to start from.|
|**count**|**int**|The number of rates to return.|
#### Returns:
|Type|Description|
|---|---|
|**numpy.ndarray**|A numpy array of OHLCV rates.|
#### Parameters
| Name | Type | Description |
|-------------|-------------|--------------------------------|
| `symbol` | `str` | The symbol name. |
| `timeframe` | `TimeFrame` | The timeframe. |
| `start_pos` | `int` | The position to start from. |
| `count` | `int` | The number of rates to return. |
#### Returns
| Type | Description |
|-----------------|-------------------------------|
| `numpy.ndarray` | A numpy array of OHLCV rates. |
<a id="MetaTrader.copy_rates_range"></a>
<a id="copy_rates_range"></a>
#### copy\_rates\_range
```python
async def copy_rates_range(symbol: str,
@@ -343,19 +345,19 @@ async def copy_rates_range(symbol: str,
date_to: datetime | int) -> numpy.ndarray | None
```
Returns the OHLCV rates for the specified symbol and timeframe between the specified dates.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**timeframe**|**TimeFrame**|The timeframe.|
|**date_from**|**datetime** or **int**|The start date.|
|**date_to**|**datetime** or **int**|The end date.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|------------------|
| `symbol` | `str` | The symbol name. |
| `timeframe` | `TimeFrame` | The timeframe. |
| `date_from` | `datetime` or `int` | The start date. |
| `date_to` | `datetime` or `int` | The end date. |
#### Returns:
|Type|Description|
|---|---|
|**numpy.ndarray**|A numpy array of OHLCV rates.|
| Type | Description |
|-----------------|-------------------------------|
| `numpy.ndarray` | A numpy array of OHLCV rates. |
<a id="MetaTrader.copy_ticks_from"></a>
<a id="copy_ticks_from"></a>
#### copy\_ticks\_from
```python
async def copy_ticks_from(symbol: str,
@@ -364,19 +366,19 @@ async def copy_ticks_from(symbol: str,
flags: CopyTicks) -> tuple[Tick] | None
```
Returns the ticks for the specified symbol starting from the specified date.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**date_from**|**datetime** or **int**|The date to start from.|
|**count**|**int**|The number of ticks to return.|
|**flags**|**CopyTicks**|The CopyTicks flags.|
#### Returns:
|Type|Description|
|---|---|
|**tuple[Tick]**|A tuple of Tick objects.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|--------------------------------|
| `symbol` | `str` | The symbol name. |
| `date_from` | `datetime` or `int` | The date to start from. |
| `count` | `int` | The number of ticks to return. |
| `flags` | `CopyTicks` | The CopyTicks flags. |
#### Returns
| Type | Description |
|---------------|--------------------------|
| `tuple[Tick]` | A tuple of Tick objects. |
<a id="MetaTrader.copy_ticks_range"></a>
<a id="copy_ticks_range"></a>
#### copy\_ticks\_range
```python
async def copy_ticks_range(symbol: str,
@@ -385,30 +387,30 @@ async def copy_ticks_range(symbol: str,
flags: CopyTicks) -> tuple[Tick] | None
```
Returns the ticks for the specified symbol between the specified dates.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**symbol**|**str**|The symbol name.|
|**date_from**|**datetime** or **int**|The start date.|
|**date_to**|**datetime** or **int**|The end date.|
|**flags**|**CopyTicks**|The CopyTicks flags.|
#### Returns:
|Type|Description|
|---|---|
|**tuple[Tick]**|A tuple of Tick objects.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|----------------------|
| `symbol` | `str` | The symbol name. |
| `date_from` | `datetime` or `int` | The start date. |
| `date_to` | `datetime` or `int` | The end date. |
| `flags` | `CopyTicks` | The CopyTicks flags. |
#### Returns
| Type | Description |
|---------------|--------------------------|
| `tuple[Tick]` | A tuple of Tick objects. |
<a id="MetaTrader.orders_total"></a>
<a id="orders_total"></a>
#### orders\_total
```python
async def orders_total() -> int
```
Returns the total number of active orders.
#### Returns:
|Type|Description|
|---|---|
|**int**|The total number of active orders.|
#### Returns
| Type | Description |
|-------|------------------------------------|
| `int` | The total number of active orders. |
<a id="MetaTrader.orders_get"></a>
<a id="orders_get"></a>
#### orders\_get
```python
async def orders_get(group: str = "",
@@ -417,22 +419,22 @@ async def orders_get(group: str = "",
```
Get active orders with the ability to filter by symbol or ticket. There are three call options.
Call without parameters. Return active orders on all symbols
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**group**|**str**|The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only active orders meeting a specified criteria for a symbol name.|
|**ticket**|**int**|Order ticket (ORDER_TICKET). Optional named parameter.|
|**symbol**|**str**|Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored.|
#### Returns:
| Type | Description |
|-----------------------|------------------------------------------------------|
| **tuple[TradeOrder]** | A tuple of active trade orders as TradeOrder objects |
#### Returns:
|Type|Description|
|---|---|
|**tuple[TradeOrder]**|A tuple of active trade orders as TradeOrder objects|
#### Parameters
| Name | Type | Description |
|----------|-------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `group` | `str` | The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only active orders meeting a specified criteria for a symbol name. |
| `ticket` | `int` | Order ticket (ORDER_TICKET). Optional named parameter. |
| `symbol` | `str` | Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored. |
#### Returns
| Type | Description |
|---------------------|------------------------------------------------------|
| `tuple[TradeOrder]` | A tuple of active trade orders as TradeOrder objects |
#### Returns
| Type | Description |
|---------------------|------------------------------------------------------|
| `tuple[TradeOrder]` | A tuple of active trade orders as TradeOrder objects |
<a id="MetaTrader.order_calc_margin"></a>
<a id="order_calc_margin"></a>
#### order\_calc\_margin
```python
async def order_calc_margin(action: OrderType,
@@ -441,19 +443,19 @@ async def order_calc_margin(action: OrderType,
price: float) -> float | None
```
Calculates the margin required to open a trade.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**action**|**OrderType**|The order type.|
|**symbol**|**str**|The symbol name.|
|**volume**|**float**|The order volume.|
|**price**|**float**|The order price.|
#### Returns:
|Type|Description|
|---|---|
|**float**|The margin required to open a trade.|
#### Parameters
| Name | Type | Description |
|----------|-------------|-------------------|
| `action` | `OrderType` | The order type. |
| `symbol` | `str` | The symbol name. |
| `volume` | `float` | The order volume. |
| `price` | `float` | The order price. |
#### Returns
| Type | Description |
|---------|--------------------------------------|
| `float` | The margin required to open a trade. |
<a id="MetaTrader.order_calc_profit"></a>
<a id="order_calc_profit"></a>
#### order\_calc\_profit
```python
async def order_calc_profit(action: OrderType,
@@ -463,62 +465,62 @@ async def order_calc_profit(action: OrderType,
price_close: float) -> float | None
```
Calculates the profit for a closed trade.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**action**|**OrderType**|The order type.|
|**symbol**|**str**|The symbol name.|
|**volume**|**float**|The order volume.|
|**price_open**|**float**|The order open price.|
|**price_close**|**float**|The order close price.|
#### Returns:
|Type|Description|
|---|---|
|**float**|The profit for a closed trade.|
#### Parameters
| Name | Type | Description |
|---------------|-------------|------------------------|
| `action` | `OrderType` | The order type. |
| `symbol` | `str` | The symbol name. |
| `volume` | `float` | The order volume. |
| `price_open` | `float` | The order open price. |
| `price_close` | `float` | The order close price. |
#### Returns
| Type | Description |
|---------|--------------------------------|
| `float` | The profit for a closed trade. |
<a id="MetaTrader.order_check"></a>
<a id="order_check"></a>
#### order\_check
```python
async def order_check(request: dict) -> OrderCheckResult
```
Checks the specified order for validity.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**request**|**dict**|The order request.|
#### Returns:
|Type|Description|
|---|---|
|**OrderCheckResult**|An instance of the OrderCheckResult class.|
#### Parameters
| Name | Type | Description |
|-----------|--------|--------------------|
| `request` | `dict` | The order request. |
#### Returns
| Type | Description |
|--------------------|--------------------------------------------|
| `OrderCheckResult` | An instance of the OrderCheckResult class. |
<a id="MetaTrader.order_send"></a>
<a id="order_send"></a>
#### order\_send
```python
async def order_send(request: dict) -> OrderSendResult
```
Sends the specified order request to the MetaTrader terminal.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**request**|**dict**|The order request.|
#### Returns:
|Type|Description|
|---|---|
|**OrderSendResult**|An instance of the OrderSendResult class.|
#### Parameters
| Name | Type | Description |
|-----------|--------|--------------------|
| `request` | `dict` | The order request. |
#### Returns
| Type | Description |
|-------------------|-------------------------------------------|
| `OrderSendResult` | An instance of the OrderSendResult class. |
<a id="MetaTrader.positions_total"></a>
<a id="positions_total"></a>
#### positions\_total
```python
async def positions_total() -> int
```
Returns the total number of open positions.
#### Returns:
|Type|Description|
|---|---|
|**int**|The total number of open positions.|
#### Returns
| Type | Description |
|-------|-------------------------------------|
| `int` | The total number of open positions. |
<a id="MetaTrader.positions_get"></a>
<a id="positions_get"></a>
#### positions\_get
```python
async def positions_get(group: str = "",
@@ -527,36 +529,36 @@ async def positions_get(group: str = "",
```
Returns the open positions with the ability to filter by symbol or ticket. There are three call options.
Call without parameters. Return open positions on all symbols
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**group**|**str**|The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only open positions meeting a specified criteria for a symbol name.|
|**ticket**|**int**|Position ticket (POSITION_TICKET). Optional named parameter.|
|**symbol**|**str**|Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored.|
#### Returns:
| Type | Description |
|----------------------------|---------------------------------------------------------|
| **tuple[TradePosition]** | A tuple of open trade positions as TradePosition objects |
#### Parameters
| Name | Type | Description |
|----------|-------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `group` | `str` | The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only open positions meeting a specified criteria for a symbol name. |
| `ticket` | `int` | Position ticket (POSITION_TICKET). Optional named parameter. |
| `symbol` | `str` | Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored. |
#### Returns
| Type | Description |
|------------------------|----------------------------------------------------------|
| `tuple[TradePosition]` | A tuple of open trade positions as TradePosition objects |
<a id="MetaTrader.history_orders_total"></a>
<a id="history_orders_total"></a>
#### history\_orders\_total
```python
async def history_orders_total(date_from: datetime | int,
date_to: datetime | int) -> int
```
Returns the total number of closed orders for the specified period.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**date_from**|**datetime** or **int**|The start date.|
|**date_to**|**datetime** or **int**|The end date.|
#### Returns:
|Type|Description|
|---|---|
|**int**|The total number of closed orders for the specified period.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|-----------------|
| `date_from` | `datetime` or `int` | The start date. |
| `date_to` | `datetime` or `int` | The end date. |
#### Returns
| Type | Description |
|-------|-------------------------------------------------------------|
| `int` | The total number of closed orders for the specified period. |
<a id="MetaTrader.history_orders_get"></a>
<a id="history_orders_get"></a>
#### history\_orders\_get
```python
async def history_orders_get(date_from: datetime | int = None,
@@ -567,38 +569,37 @@ async def history_orders_get(date_from: datetime | int = None,
```
Returns the closed orders for the specified period with the ability to filter by symbol or ticket. There are three call options.
Call without parameters. Return closed orders on all symbols
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**date_from**|**datetime** or **int**|The start date. Optional named parameter.|
|**date_to**|**datetime** or **int**|The end date. Optional named parameter.|
|**group**|**str**|The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only closed orders meeting a specified criteria for a symbol name.|
|**ticket**|**int**|Order ticket (ORDER_TICKET). Optional named parameter.|
|**position**|**int**|Position ticket (POSITION_TICKET). Optional named parameter.|
#### Returns:
| Type | Description |
|----------------------------|---------------------------------------------------------|
| **tuple[TradeOrder]** | A tuple of closed trade orders as TradeOrder objects |
#### Parameters
| Name | Type | Description |
|-------------|---------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `date_from` | `datetime` or `int` | The start date. Optional named parameter. |
| `date_to` | `datetime` or `int` | The end date. Optional named parameter. |
| `group` | `str` | The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only closed orders meeting a specified criteria for a symbol name. |
| `ticket` | `int` | Order ticket (ORDER_TICKET). Optional named parameter. |
| `position` | `int` | Position ticket (POSITION_TICKET). Optional named parameter. |
#### Returns
| Type | Description |
|---------------------|------------------------------------------------------|
| `tuple[TradeOrder]` | A tuple of closed trade orders as TradeOrder objects |
<a id="MetaTrader.history_deals_total"></a>
<a id="history_deals_total"></a>
#### history\_deals\_total
```python
async def history_deals_total(date_from: datetime | int,
date_to: datetime | int) -> int
```
Returns the total number of closed deals for the specified period.
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**date_from**|**datetime** or **int**|The start date.|
|**date_to**|**datetime** or **int**|The end date.|
#### Returns:
|Type|Description|
|---|---|
|**int**|The total number of closed deals for the specified period.|
#### Parameters
| Name | Type | Description |
|-------------|---------------------|-----------------|
| `date_from` | `datetime` or `int` | The start date. |
| `date_to` | `datetime` or `int` | The end date. |
#### Returns
| Type | Description |
|-------|------------------------------------------------------------|
| `int` | The total number of closed deals for the specified period. |
<a id="MetaTrader.history_deals_get"></a>
<a id="history_deals_get"></a>
#### history\_deals\_get
```python
async def history_deals_get(date_from: datetime | int = None,
@@ -609,15 +610,15 @@ async def history_deals_get(date_from: datetime | int = None,
```
Returns the closed deals for the specified period with the ability to filter by symbol or ticket. There are three call options.
Call without parameters. Return closed deals on all symbols
#### Parameters:
|Name|Type|Description|
|---|---|---|
|**date_from**|**datetime** or **int**|The start date. Optional named parameter.|
|**date_to**|**datetime** or **int**|The end date. Optional named parameter.|
|**group**|**str**|The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only closed deals meeting a specified criteria for a symbol name.|
|**ticket**|**int**|Order ticket (ORDER_TICKET). Optional named parameter.|
|**position**|**int**|Position ticket (POSITION_TICKET). Optional named parameter.|
#### Returns:
| Type | Description |
|----------------------------|---------------------------------------------------------|
| **tuple[TradeDeal]** | A tuple of closed trade deals as TradeDeal objects |
#### Parameters
| Name | Type | Description |
|-------------|---------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `date_from` | `datetime` or `int` | The start date. Optional named parameter. |
| `date_to` | `datetime` or `int` | The end date. Optional named parameter. |
| `group` | `str` | The filter for arranging a group of necessary symbols. Optional named parameter. If the group is specified, the function returns only closed deals meeting a specified criteria for a symbol name. |
| `ticket` | `int` | Order ticket (ORDER_TICKET). Optional named parameter. |
| `position` | `int` | Position ticket (POSITION_TICKET). Optional named parameter. |
#### Returns
| Type | Description |
|--------------------|----------------------------------------------------|
| `tuple[TradeDeal]` | A tuple of closed trade deals as TradeDeal objects |
View File
+321 -352
View File
@@ -1,405 +1,374 @@
# Table of Contents
# Models
This module contains the models used in the aiomql package. These models are used to represent the data returned from the MetaTrader 5 terminal.
They are all subclasses of the `Base` class.
* [aiomql.core.models](#aiomql.core.models)
* [AccountInfo](#aiomql.core.models.AccountInfo)
* [TerminalInfo](#aiomql.core.models.TerminalInfo)
* [SymbolInfo](#aiomql.core.models.SymbolInfo)
* [BookInfo](#aiomql.core.models.BookInfo)
* [TradeOrder](#aiomql.core.models.TradeOrder)
* [TradeRequest](#aiomql.core.models.TradeRequest)
* [OrderCheckResult](#aiomql.core.models.OrderCheckResult)
* [OrderSendResult](#aiomql.core.models.OrderSendResult)
* [TradePosition](#aiomql.core.models.TradePosition)
* [TradeDeal](#aiomql.core.models.TradeDeal)
<a id="aiomql.core.models"></a>
# aiomql.core.models
<a id="aiomql.core.models.AccountInfo"></a>
## AccountInfo Objects
## Table of Contents
- [AccountInfo](#AccountInfo)
- [TerminalInfo](#TerminalInfo)
- [SymbolInfo](#SymbolInfo)
- [BookInfo](#BookInfo)
- [TradeOrder](#TradeOrder)
- [TradeRequest](#TradeRequest)
- [OrderCheckResult](#OrderCheckResult)
- [OrderSendResult](#OrderSendResult)
- [TradePosition](#TradePosition)
- [TradeDeal](#TradeDeal)
<a id="AccountInfo"></a>
## AccountInfo
```python
class AccountInfo(Base)
```
Account Information Class.
#### Attributes
| Name | Type | Description | Default |
|----------------------|--------------------|------------------------------------------|---------|
| `login` | `int` | Account number | |
| `password` | `str` | Account password | |
| `server` | `str` | Trade server name | |
| `trade_mode` | AccountTradeMode | Trade mode | |
| `balance` | `float` | Account balance | |
| `leverage` | `float` | Account leverage | |
| `profit` | `float` | Account profit | |
| `point` | `float` | Point size | |
| `amount` | `float` | Account amount | 0 |
| `equity` | `float` | Account equity | |
| `credit` | `float` | Account credit | |
| `margin` | `float` | Account margin | |
| `margin_level` | `float` | Margin level | |
| `margin_free` | `float` | Free margin | |
| `margin_mode` | AccountMarginMode | Margin calculation mode | |
| `margin_so_mode` | AccountStopoutMode | Stop out mode | |
| `margin_so_call` | `float` | Margin call level | |
| `margin_so_so` | `float` | Stop out level | |
| `margin_initial` | `float` | Initial margin | |
| `margin_maintenance` | `float` | Maintenance margin | |
| `fifo_close` | `bool` | FIFO close flag | |
| `limit_orders` | `float` | Limit orders | |
| `currency` | `str` | Account currency | "USD" |
| `trade_allowed` | `bool` | Trade allowed flag | True |
| `trade_expert` | `bool` | Trade expert flag | True |
| `currency_digits` | `int` | Number of digits after the decimal point | |
| `assets` | `float` | Assets | |
| `liabilities` | `float` | Liabilities | |
| `commission_blocked` | `float` | Blocked commission | |
| `name` | `str` | Account name | |
| `company` | `str` | Company name | |
**Attributes**:
- `login` - int
- `password` - str
- `server` - str
- `trade_mode` - AccountTradeMode
- `balance` - float
- `leverage` - float
- `profit` - float
- `point` - float
- `amount` - float = 0
- `equity` - float
- `credit` - float
- `margin` - float
- `margin_level` - float
- `margin_free` - float
- `margin_mode` - AccountMarginMode
- `margin_so_mode` - AccountStopoutMode
- `margin_so_call` - float
- `margin_so_so` - float
- `margin_initial` - float
- `margin_maintenance` - float
- `fifo_close` - bool
- `limit_orders` - float
- `currency` - str = "USD"
- `trade_allowed` - bool = True
- `trade_expert` - bool = True
- `currency_digits` - int
- `assets` - float
- `liabilities` - float
- `commission_blocked` - float
- `name` - str
- `company` - str
<a id="aiomql.core.models.TerminalInfo"></a>
## TerminalInfo Objects
<a id="TerminalInfo"></a>
## TerminalInfo
```python
class TerminalInfo(Base)
```
Terminal information class. Holds information about the terminal.
**Attributes**:
- `community_account` - bool
- `community_connection` - bool
- `connected` - bool
- `dlls_allowed` - bool
- `trade_allowed` - bool
- `tradeapi_disabled` - bool
- `email_enabled` - bool
- `ftp_enabled` - bool
- `notifications_enabled` - bool
- `mqid` - bool
- `build` - int
- `maxbars` - int
- `codepage` - int
- `ping_last` - int
- `community_balance` - float
- `retransmission` - float
- `company` - str
- `name` - str
- `language` - str
- `path` - str
- `data_path` - str
- `commondata_path` - str
<a id="aiomql.core.models.SymbolInfo"></a>
## SymbolInfo Objects
#### Attributes
| Name | Type | Description | Default |
|-------------------------|---------|----------------------------|---------|
| `community_account` | `bool` | Community account flag | |
| `community_connection` | `bool` | Community connection flag | |
| `connected` | `bool` | Connection flag | |
| `dlls_allowed` | `bool` | DLLs allowed flag | |
| `trade_allowed` | `bool` | Trade allowed flag | |
| `tradeapi_disabled` | `bool` | Trade API disabled flag | |
| `email_enabled` | `bool` | Email enabled flag | |
| `ftp_enabled` | `bool` | FTP enabled flag | |
| `notifications_enabled` | `bool` | Notifications enabled flag | |
| `mqid` | `bool` | MQID | |
| `build` | `int` | Build number | |
| `maxbars` | `int` | Maximum number of bars | |
| `codepage` | `int` | Code page | |
| `ping_last` | `int` | Last ping | |
| `community_balance` | `float` | Community balance | |
| `retransmission` | `float` | Retransmission | |
| `company` | `str` | Company name | |
| `name` | `str` | Terminal name | |
| `language` | `str` | Language | |
| `path` | `str` | Terminal path | |
| `data_path` | `str` | Data path | |
| `commondata_path` | `str` | Common data path | |
<a id="SymbolInfo"></a>
## SymbolInfo
```python
class SymbolInfo(Base)
```
Symbol Information Class. Symbols are financial instruments available for trading in the MetaTrader 5 terminal.
#### Attributes
| Name | Type | Description | Default |
|------------------------------|------------------------|----------------------------|---------|
| `name` | `str` | Symbol name | |
| `custom` | `bool` | Custom symbol flag | |
| `chart_mode` | `SymbolChartMode` | Chart mode | |
| `select` | `bool` | Symbol selection flag | |
| `visible` | `bool` | Symbol visibility flag | |
| `session_deals` | `int` | Session deals | |
| `session_buy_orders` | `int` | Session buy orders | |
| `session_sell_orders` | `int` | Session sell orders | |
| `volume` | `float` | Volume | |
| `volumehigh` | `float` | Volume high | |
| `volumelow` | `float` | Volume low | |
| `time` | `int` | Time | |
| `digits` | `int` | Digits | |
| `spread` | `float` | Spread | |
| `spread_float` | `bool` | Spread float flag | |
| `ticks_bookdepth` | `int` | Ticks book depth | |
| `trade_calc_mode` | `SymbolCalcMode` | Trade calculation mode | |
| `trade_mode` | `SymbolTradeMode` | Trade mode | |
| `start_time` | `int` | Start time | |
| `expiration_time` | `int` | Expiration time | |
| `trade_stops_level` | `int` | Trade stops level | |
| `trade_freeze_level` | `int` | Trade freeze level | |
| `trade_exemode` | `SymbolTradeExecution` | Trade execution mode | |
| `swap_mode` | `SymbolSwapMode` | Swap mode | |
| `swap_rollover3days` | `DayOfWeek` | Swap rollover 3 days | |
| `margin_hedged_use_leg` | `bool` | Margin hedged use leg flag | |
| `expiration_mode` | `int` | Expiration mode | |
| `filling_mode` | `int` | Filling mode | |
| `order_mode` | `int` | Order mode | |
| `order_gtc_mode` | `SymbolOrderGTCMode` | Order GTC mode | |
| `option_mode` | `SymbolOptionMode` | Option mode | |
| `option_right` | `SymbolOptionRight` | Option right | |
| `bid` | `float` | Bid | |
| `bidhigh` | `float` | Bid high | |
| `bidlow` | `float` | Bid low | |
| `ask` | `float` | Ask | |
| `askhigh` | `float` | Ask high | |
| `asklow` | `float` | Ask low | |
| `last` | `float` | Last | |
| `lasthigh` | `float` | Last high | |
| `lastlow` | `float` | Last low | |
| `volume_real` | `float` | Volume real | |
| `volumehigh_real` | `float` | Volume high real | |
| `volumelow_real` | `float` | Volume low real | |
| `option_strike` | `float` | Option strike | |
| `point` | `float` | Point | |
| `trade_tick_value` | `float` | Trade tick value | |
| `trade_tick_value_profit` | `float` | Trade tick value profit | |
| `trade_tick_value_loss` | `float` | Trade tick value loss | |
| `trade_tick_size` | `float` | Trade tick size | |
| `trade_contract_size` | `float` | Trade contract size | |
| `trade_accrued_interest` | `float` | Trade accrued interest | |
| `trade_face_value` | `float` | Trade face value | |
| `trade_liquidity_rate` | `float` | Trade liquidity rate | |
| `volume_min` | `float` | Volume min | |
| `volume_max` | `float` | Volume max | |
| `volume_step` | `float` | Volume step | |
| `volume_limit` | `float` | Volume limit | |
| `swap_long` | `float` | Swap long | |
| `swap_short` | `float` | Swap short | |
| `margin_initial` | `float` | Initial margin | |
| `margin_maintenance` | `float` | Maintenance margin | |
| `session_volume` | `float` | Session volume | |
| `session_turnover` | `float` | Session turnover | |
| `session_interest` | `float` | Session interest | |
| `session_buy_orders_volume` | `float` | Session buy orders volume | |
| `session_sell_orders_volume` | `float` | Session sell orders volume | |
| `session_open` | `float` | Session open | |
| `session_close` | `float` | Session close | |
| `session_aw` | `float` | Session AW | |
| `session_price_settlement` | `float` | Session price settlement | |
| `session_price_limit_min` | `float` | Session price limit min | |
| `session_price_limit_max` | `float` | Session price limit max | |
| `margin_hedged` | `float` | Margin hedged | |
| `price_change` | `float` | Price change | |
| `price_volatility` | `float` | Price volatility | |
| `price_theoretical` | `float` | Price theoretical | |
| `price_greeks_delta` | `float` | Price greeks delta | |
| `price_greeks_theta` | `float` | Price greeks theta | |
| `price_greeks_gamma` | `float` | Price greeks gamma | |
| `price_greeks_vega` | `float` | Price greeks vega | |
| `price_greeks_rho` | `float` | Price greeks rho | |
| `price_greeks_omega` | `float` | Price greeks omega | |
| `price_sensitivity` | `float` | Price sensitivity | |
| `basis` | `str` | Basis | |
| `category` | `str` | Category | |
| `currency_base` | `str` | Base currency | |
| `currency_profit` | `str` | Profit currency | |
| `currency_margin` | `Any` | Margin currency | |
| `bank` | `str` | Bank | |
| `description` | `str` | Description | |
| `exchange` | `str` | Exchange | |
| `formula` | `Any` | Formula | |
| `isin` | `Any` | ISIN | |
| `name` | `str` | Name | |
| `page` | `str` | Page | |
| `path` | `str` | Path | |
**Attributes**:
- `name` - str
- `custom` - bool
- `chart_mode` - SymbolChartMode
- `select` - bool
- `visible` - bool
- `session_deals` - int
- `session_buy_orders` - int
- `session_sell_orders` - int
- `volume` - float
- `volumehigh` - float
- `volumelow` - float
- `time` - int
- `digits` - int
- `spread` - float
- `spread_float` - bool
- `ticks_bookdepth` - int
- `trade_calc_mode` - SymbolCalcMode
- `trade_mode` - SymbolTradeMode
- `start_time` - int
- `expiration_time` - int
- `trade_stops_level` - int
- `trade_freeze_level` - int
- `trade_exemode` - SymbolTradeExecution
- `swap_mode` - SymbolSwapMode
- `swap_rollover3days` - DayOfWeek
- `margin_hedged_use_leg` - bool
- `expiration_mode` - int
- `filling_mode` - int
- `order_mode` - int
- `order_gtc_mode` - SymbolOrderGTCMode
- `option_mode` - SymbolOptionMode
- `option_right` - SymbolOptionRight
- `bid` - float
- `bidhigh` - float
- `bidlow` - float
- `ask` - float
- `askhigh` - float
- `asklow` - float
- `last` - float
- `lasthigh` - float
- `lastlow` - float
- `volume_real` - float
- `volumehigh_real` - float
- `volumelow_real` - float
- `option_strike` - float
- `point` - float
- `trade_tick_value` - float
- `trade_tick_value_profit` - float
- `trade_tick_value_loss` - float
- `trade_tick_size` - float
- `trade_contract_size` - float
- `trade_accrued_interest` - float
- `trade_face_value` - float
- `trade_liquidity_rate` - float
- `volume_min` - float
- `volume_max` - float
- `volume_step` - float
- `volume_limit` - float
- `swap_long` - float
- `swap_short` - float
- `margin_initial` - float
- `margin_maintenance` - float
- `session_volume` - float
- `session_turnover` - float
- `session_interest` - float
- `session_buy_orders_volume` - float
- `session_sell_orders_volume` - float
- `session_open` - float
- `session_close` - float
- `session_aw` - float
- `session_price_settlement` - float
- `session_price_limit_min` - float
- `session_price_limit_max` - float
- `margin_hedged` - float
- `price_change` - float
- `price_volatility` - float
- `price_theoretical` - float
- `price_greeks_delta` - float
- `price_greeks_theta` - float
- `price_greeks_gamma` - float
- `price_greeks_vega` - float
- `price_greeks_rho` - float
- `price_greeks_omega` - float
- `price_sensitivity` - float
- `basis` - str
- `category` - str
- `currency_base` - str
- `currency_profit` - str
- `currency_margin` - Any
- `bank` - str
- `description` - str
- `exchange` - str
- `formula` - Any
- `isin` - Any
- `name` - str
- `page` - str
- `path` - str
<a id="aiomql.core.models.BookInfo"></a>
## BookInfo Objects
<a id="BookInfo"></a>
## BookInfo
```python
class BookInfo(Base)
```
Book Information Class.
#### Attributes
| Name | Type | Description | Default |
|--------------|------------|-------------|---------|
| `symbol` | `str` | Symbol | |
| `type` | `BookType` | Type | |
| `price` | `float` | Price | |
| `volume` | `float` | Volume | |
| `volume_dbl` | `float` | Volume dbl | |
**Attributes**:
- `type` - BookType
- `price` - float
- `volume` - float
- `volume_dbl` - float
<a id="aiomql.core.models.TradeOrder"></a>
## TradeOrder Objects
<a id="TradeOrder"></a>
## TradeOrder
```python
class TradeOrder(Base)
```
Trade Order Class.
#### Attributes
| Name | Type | Description | Default |
|-------------------|----------------|-----------------|---------|
| `ticket` | `int` | Ticket | |
| `time_setup` | `int` | Time setup | |
| `time_setup_msc` | `int` | Time setup msc | |
| `time_expiration` | `int` | Time expiration | |
| `time_done` | `int` | Time done | |
| `time_done_msc` | `int` | Time done msc | |
| `type` | `OrderType` | Type | |
| `type_time` | `OrderTime` | Type time | |
| `type_filling` | `OrderFilling` | Type filling | |
| `state` | `int` | State | |
| `magic` | `int` | Magic | |
| `position_id` | `int` | Position id | |
| `position_by_id` | `int` | Position by id | |
| `reason` | `OrderReason` | Reason | |
| `volume_current` | `float` | Volume current | |
| `volume_initial` | `float` | Volume initial | |
| `price_open` | `float` | Price open | |
| `sl` | `float` | SL | |
| `tp` | `float` | TP | |
| `price_current` | `float` | Price current | |
| `price_stoplimit` | `float` | Price stoplimit | |
| `symbol` | `str` | Symbol | |
| `comment` | `str` | Comment | |
| `external_id` | `str` | External id | |
**Attributes**:
- `ticket` - int
- `time_setup` - int
- `time_setup_msc` - int
- `time_expiration` - int
- `time_done` - int
- `time_done_msc` - int
- `type` - OrderType
- `type_time` - OrderTime
- `type_filling` - OrderFilling
- `state` - int
- `magic` - int
- `position_id` - int
- `position_by_id` - int
- `reason` - OrderReason
- `volume_current` - float
- `volume_initial` - float
- `price_open` - float
- `sl` - float
- `tp` - float
- `price_current` - float
- `price_stoplimit` - float
- `symbol` - str
- `comment` - str
- `external_id` - str
<a id="aiomql.core.models.TradeRequest"></a>
## TradeRequest Objects
<a id="TradeRequest"></a>
## TradeRequest
```python
class TradeRequest(Base)
```
Trade Request Class.
#### Attributes
| Name | Type | Description | Default |
|----------------|--------------|--------------|---------|
| `action` | TradeAction | Action | |
| `type` | OrderType | Type | |
| `order` | `int` | Order | |
| `symbol` | `str` | Symbol | |
| `volume` | `float` | Volume | |
| `sl` | `float` | SL | |
| `tp` | `float` | TP | |
| `price` | `float` | Price | |
| `deviation` | `float` | Deviation | |
| `stop_limit` | `float` | Stop limit | |
| `type_time` | OrderTime | Type time | |
| `type_filling` | OrderFilling | Type filling | |
| `expiration` | `int` | Expiration | |
| `position` | `int` | Position | |
| `position_by` | `int` | Position by | |
| `comment` | `str` | Comment | |
| `magic` | `int` | Magic | |
| `deviation` | `int` | Deviation | |
**Attributes**:
- `action` - TradeAction
- `type` - OrderType
- `order` - int
- `symbol` - str
- `volume` - float
- `sl` - float
- `tp` - float
- `price` - float
- `deviation` - float
- `stop_limit` - float
- `type_time` - OrderTime
- `type_filling` - OrderFilling
- `expiration` - int
- `position` - int
- `position_by` - int
- `comment` - str
- `magic` - int
- `deviation` - int
- `comment` - str
<a id="aiomql.core.models.OrderCheckResult"></a>
## OrderCheckResult Objects
<a id="OrderCheckResult"></a>
## OrderCheckResult
```python
class OrderCheckResult(Base)
```
Order Check Result
#### Attributes
| Name | Type | Description | Default |
|----------------|----------------|--------------|---------|
| `retcode` | `int` | Retcode | |
| `balance` | `float` | Balance | |
| `equity` | `float` | Equity | |
| `profit` | `float` | Profit | |
| `margin` | `float` | Margin | |
| `margin_free` | `float` | Margin free | |
| `margin_level` | `float` | Margin level | |
| `comment` | `str` | Comment | |
| `request` | `TradeRequest` | Request | |
**Attributes**:
- `retcode` - int
- `balance` - float
- `equity` - float
- `profit` - float
- `margin` - float
- `margin_free` - float
- `margin_level` - float
- `comment` - str
- `request` - TradeRequest
<a id="aiomql.core.models.OrderSendResult"></a>
## OrderSendResult Objects
<a id="OrderSendResult"></a>
## OrderSendResult
```python
class OrderSendResult(Base)
```
Order Send Result
**Attributes**:
- `retcode` - int
- `deal` - int
- `order` - int
- `volume` - float
- `price` - float
- `bid` - float
- `ask` - float
- `comment` - str
- `request` - TradeRequest
- `request_id` - int
- `retcode_external` - int
- `profit` - float
<a id="aiomql.core.models.TradePosition"></a>
## TradePosition Objects
#### Attributes
| Name | Type | Description | Default |
|--------------------|----------------|------------------|---------|
| `retcode` | `int` | Retcode | |
| `deal` | `int` | Deal | |
| `order` | `int` | Order | |
| `volume` | `float` | Volume | |
| `price` | `float` | Price | |
| `bid` | `float` | Bid | |
| `ask` | `float` | Ask | |
| `comment` | `str` | Comment | |
| `request` | `TradeRequest` | Request | |
| `request_id` | `int` | Request id | |
| `retcode_external` | `int` | Retcode external | |
| `profit` | `float` | Profit | |
<a id="TradePosition"></a>
## TradePosition
```python
class TradePosition(Base)
```
Trade Position
#### Attributes
| Name | Type | Description | Default |
|-------------------|------------------|-----------------|---------|
| `ticket` | `int` | Ticket | |
| `time` | `int` | Time | |
| `time_msc` | `int` | Time msc | |
| `time_update` | `int` | Time update | |
| `time_update_msc` | `int` | Time update msc | |
| `type` | `OrderType` | Type | |
| `magic` | `float` | Magic | |
| `identifier` | `int` | Identifier | |
| `reason` | `PositionReason` | Reason | |
| `volume` | `float` | Volume | |
| `price_open` | `float` | Price open | |
| `sl` | `float` | SL | |
| `tp` | `float` | TP | |
| `price_current` | `float` | Price current | |
| `swap` | `float` | Swap | |
| `profit` | `float` | Profit | |
| `symbol` | `str` | Symbol | |
| `comment` | `str` | Comment | |
| `external_id` | `str` | External id | |
**Attributes**:
- `ticket` - int
- `time` - int
- `time_msc` - int
- `time_update` - int
- `time_update_msc` - int
- `type` - OrderType
- `magic` - float
- `identifier` - int
- `reason` - PositionReason
- `volume` - float
- `price_open` - float
- `sl` - float
- `tp` - float
- `price_current` - float
- `swap` - float
- `profit` - float
- `symbol` - str
- `comment` - str
- `external_id` - str
<a id="aiomql.core.models.TradeDeal"></a>
## TradeDeal Objects
<a id="TradeDeal"></a>
## TradeDeal
```python
class TradeDeal(Base)
```
Trade Deal
**Attributes**:
- `ticket` - int
- `order` - int
- `time` - int
- `time_msc` - int
- `type` - DealType
- `entry` - DealEntry
- `magic` - int
- `position_id` - int
- `reason` - DealReason
- `volume` - float
- `price` - float
- `commission` - float
- `swap` - float
- `profit` - float
- `fee` - float
- `sl` - float
- `tp` - float
- `symbol` - str
- `comment` - str
- `external_id` - str
#### Attributes
| Name | Type | Description | Default |
|---------------|--------------|-------------|---------|
| `ticket` | `int` | Ticket | |
| `order` | `int` | Order | |
| `time` | `int` | Time | |
| `time_msc` | `int` | Time msc | |
| `type` | `DealType` | Type | |
| `entry` | `DealEntry` | Entry | |
| `magic` | `int` | Magic | |
| `position_id` | `int` | Position id | |
| `reason` | `DealReason` | Reason | |
| `volume` | `float` | Volume | |
| `price` | `float` | Price | |
| `commission` | `float` | Commission | |
| `swap` | `float` | Swap | |
| `profit` | `float` | Profit | |
| `fee` | `float` | Fee | |
| `sl` | `float` | SL | |
| `tp` | `float` | TP | |
| `symbol` | `str` | Symbol | |
| `comment` | `str` | Comment | |
| `external_id` | `str` | External id | |