4.1 KiB
Table of Contents
aiomql.core.meta_trader
MetaTrader Objects
class MetaTrader(metaclass=BaseMeta)
__aenter__
async def __aenter__() -> 'MetaTrader'
Async context manager entry point. Initializes the connection to the MetaTrader terminal.
Returns:
MetaTrader- An instance of the MetaTrader class.
__aexit__
async def __aexit__(exc_type, exc_val, exc_tb)
Async context manager exit point. Closes the connection to the MetaTrader terminal.
login
async def login(login: int,
password: str,
server: str,
timeout: int = 60000) -> bool
Connects to the MetaTrader terminal using the specified login, password and server.
Arguments:
loginint - The trading account number.passwordstr - The trading account password.serverstr - The trading server name.timeoutint - The timeout for the connection in seconds.
Returns:
bool- True if successful, False otherwise.
initialize
async def initialize(path: str = "",
login: int = 0,
password: str = "",
server: str = "",
timeout: int | None = None,
portable=False) -> bool
Initializes the connection to the MetaTrader terminal. All parameters are optional.
Arguments:
pathstr - The path to the MetaTrader terminal executable.loginint - The trading account number.passwordstr - The trading account password.serverstr - The trading server name.timeoutint - The timeout for the connection in seconds.portablebool - If True, the terminal will be launched in portable mode.
Returns:
bool- True if successful, False otherwise.
shutdown
async def shutdown() -> None
Closes the connection to the MetaTrader terminal.
Returns:
None- None
version
async def version() -> tuple[int, int, str] | None
account_info
async def account_info() -> AccountInfo | None
orders_get
async def orders_get(group: str = "",
ticket: int = 0,
symbol: str = "") -> tuple[TradeOrder] | None
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
Arguments:
-
symbolstr - Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored. -
groupstr - 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. -
ticketint - Order ticket (ORDER_TICKET). Optional named parameter.
Returns:
list[TradeOrder]- A list of active trade orders as TradeOrder objects