- Installing Python and the MetaTrader5 package
- Overview of functions of the MetaTrader5 package for Python
- Connecting a Python script to the terminal and account
- Error checking: last_error
- Getting information about a trading account
- Getting information about the terminal
- Getting information about financial instruments
- Subscribing to order book changes
- Reading quotes
- Reading tick history
- Calculating margin requirements and evaluating profits
- Checking and sending a trade order
- Getting the number and list of active orders
- Getting the number and list of open positions
- Reading the history of orders and deals
Getting information about the terminal
The terminal_info function allows you to get the status and parameters of the connected MetaTrader 5 terminal.
namedtuple terminal_info()
On success, the function returns the information as a structure of named tuples (namedtuple), and in case of an error, it returns None.
In one call of this function, you can get all the information that is provided by TerminalInfoInteger, TerminalInfoDouble, and TerminalInfoDouble in MQL5, with all variants of supported properties. The names of the fields in the tuple correspond to the names of the enumeration elements without the "TERMINAL_" prefix, reduced to lowercase.
For example (see MQL5/Scripts/MQL5Book/Python/terminalinfo.py):
import MetaTrader5 as mt5
|
We should be something like the following.
[500, 3428, '14 Sep 2022'] TerminalInfo(community_account=True, community_connection=True, connected=True,.... Show terminal_info()._asdict(): community_account=True community_connection=True connected=True dlls_allowed=False trade_allowed=False tradeapi_disabled=False email_enabled=False ftp_enabled=False notifications_enabled=False mqid=False build=2366 maxbars=5000 codepage=1251 ping_last=77850 community_balance=707.10668201585 retransmission=0.0 company=MetaQuotes Software Corp. name=MetaTrader 5 language=Russian path=E:\ProgramFiles\MetaTrader 5 data_path=E:\ProgramFiles\MetaTrader 5 commondata_path=C:\Users\User\AppData\Roaming\MetaQuotes\Terminal\Common |