Files
Ichinga Samuel 4f0150a552 v3.23
2024-10-29 13:04:45 +01:00

3.1 KiB

Account

Table of Contents

Account

class Account(AccountInfo)

Singleton class for managing a trading account. A subclass of 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()

__init__

def __init__(self, *args, **kwargs)

Initializes the Account class. Inherits all attributes from the AccountInfo class.

aenter

async def __aenter__() -> 'Account'

Async context manager for the Account class. Connects to a trading account and returns the account instance.

Returns:

Type Description
Account An instance of the Account class

Raises:

Exception Description
LoginError If login fails

aexit

async def __aexit__(exc_type, exc_value, traceback)

Async context manager for the Account class. Disconnects from the trading account.

sign_in

async def sign_in() -> bool

Connect to a trading account.

Returns:

Type Description
bool True if login was successful else False

refresh

async def refresh()

Refreshes the account instance with the latest data from the MetaTrader 5 terminal

has_symbol

def has_symbol(symbol: str | Type[SymbolInfo])

Checks to see if a symbol is available for a trading account

Parameters:

Name Type Description
symbol str|SymbolInfo A symbol name or SymbolInfo instance

Returns:

Type Description
bool True if symbol is available else False

symbols_get

async def symbols_get() -> set[SymbolInfo]

Get all financial instruments from the MetaTrader 5 terminal available for the current account.

Returns:

Type Description
set[SymbolInfo] A set of SymbolInfo instances