Files
aiomql/docs/core/meta_trader.md
T
Ichinga Samuel 027f9fd8de add docs
2023-10-11 09:49:06 +01:00

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:

  • 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:

  • 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:

  • 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 - The timeout for the connection in seconds.
  • portable bool - 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:

  • symbol str - Symbol name. Optional named parameter. If a symbol is specified, the ticket parameter is ignored.

  • 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.

Returns:

  • list[TradeOrder] - A list of active trade orders as TradeOrder objects