This commit is contained in:
Ichinga Samuel
2024-01-18 02:26:27 +01:00
parent 4b5f267509
commit 63f22fc081
43 changed files with 387 additions and 545 deletions
+31 -31
View File
@@ -1,46 +1,36 @@
## <a id="account"></a> Account
- [Account](#Account)
- [__aenter__](#Account.__aenter__)
- [sign_in](#Account.sign_in)
- [refresh](#Account.refresh)
- [has_symbol](#Account.has_symbol)
- [symbols_get](#Account.symbols_get)
- [AccountInfo](#AccountInfo)
- [Account](#Account)
- [sign_in](#Account.sign_in)
- [has_symbol](#Account.has_symbol)
- [symbols_get](#Account.symbols_get)
-
<a id="Account"></a>
### Account
```python
class Account(AccountInfo)
```
Singleton class for managing a trading account. A subclass of [AccountInfo](#accountinfo).
Singleton class for managing a trading account. A subclass of [AccountInfo](#AccountInfo).
All AccountInfo attributes are available in this class.
### Attributes:
|Name|Type|Description|Default|
|---|---|---|---|
|**connected**|**bool**|Status of connection to MetaTrader 5 Terminal|False|
|symbols|set[SymbolInfo]|A set of available symbols for the financial market.|set()|
### Notes
Other Account properties are defined in the AccountInfo class.
### refresh
```python
async def refresh()
```
Refreshes the account instance with the latest data from the MetaTrader 5 terminal
### account_info
```python
@property
def account_info() -> dict
```
Get account login, server and password details. If the login attribute of the account instance returns
a falsy value, the config instance is used to get the account details.
#### Returns:
|Type|Description|
|---|---|
|**dict**|A dict of login, server and password details|
#### Note:
This method will only look for config details in the config instance if the login attribute of the account Instance returns a falsy value
### __aenter__
<a id="Account.__aenter__"></a>
#### __aenter__
```python
async def __aenter__() -> 'Account'
```
Async context manager for the Account class. Connects to a trading account and returns the account instance.
#### Returns:
|Type|Description|
|---|---|
@@ -50,7 +40,8 @@ Async context manager for the Account class. Connects to a trading account and r
|---|---|
|**LoginError**|If login fails|
### sign_in
<a id="Account.sign_in"></a>
#### sign_in
```python
async def sign_in() -> bool
```
@@ -60,7 +51,15 @@ Connect to a trading account.
|---|---|
|**bool**|True if login was successful else False|
### has_symbol
<a id="Account.refresh"></a>
#### refresh
```python
async def refresh()
```
Refreshes the account instance with the latest data from the MetaTrader 5 terminal
<a id="Account.has_symbol"></a>
#### has_symbol
```python
def has_symbol(symbol: str | Type[SymbolInfo])
```
@@ -74,7 +73,8 @@ Checks to see if a symbol is available for a trading account
|---|---|
|**bool**|True if symbol is available else False|
### symbols_get
<a id="Account.symbols_get"></a>
#### symbols_get
```python
async def symbols_get() -> set[SymbolInfo]
```
+25 -9
View File
@@ -1,6 +1,6 @@
* [MetaTrader](#MetaTrader)
* [\_\_aenter\_\_](#__aenter__)
* [\_\_aexit\_\_](#aexit)
* [\_\_aenter\_\_](#MetaTrader.__aenter__)
* [\_\_aexit\_\_](#MetaTrader.__aexit__)
* [login](#MetaTrader.login)
* [initialize](#MetaTrader.initialize)
* [shutdown](#MetaTrader.shutdown)
@@ -35,14 +35,25 @@
* [history\_deals\_get](#MetaTrader.history_deals_get)
## <a id="MetaTrader"></a> MetaTrader
<a id="MetaTrader"></a>
### MetaTrader
```python
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, '')|
### <a id="MetaTrader.__aenter__"></a> \_\_aenter\_\_
#### 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>
#### \_\_aenter\_\_
```python
async def __aenter__() -> 'MetaTrader'
```
@@ -54,13 +65,15 @@ Initializes the connection to the MetaTrader terminal.
|---|---|
|**MetaTrader**|An instance of the MetaTrader class|
#### <a id="MetaTrader.__aexit__"></a> \_\_aexit\_\_
<a id="MetaTrader.__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> login
<a id="MetaTrader.login"></a>
#### login
```python
async def login(login: int,
password: str,
@@ -80,7 +93,8 @@ Connects to the MetaTrader terminal using the specified login, password and serv
|---|---|
|**bool**|True if successful, False otherwise.|
#### <a id="MetaTrader.initialize"></a> initialize
<a id="MetaTrader.initialize"></a>
#### initialize
```python
async def initialize(path: str = "",
login: int = 0,
@@ -104,13 +118,15 @@ Initializes the connection to the MetaTrader terminal. All parameters are option
|---|---|
|**bool**|True if successful, False otherwise.|
#### <a id="MetaTrader.shutdown"></a> shutdown
<a id="MetaTrader.shutdown"></a>
#### shutdown
```python
async def shutdown() -> None
```
Closes the connection to the MetaTrader terminal.
#### <a id="MetaTrader.version"></a> version
<a id="MetaTrader.version"></a>
#### version
```python
async def version() -> tuple[int, int, str] | None
```