获取交易账户信息
account_info 函数可获取当前交易账户的所有信息。
namedtuple account_info()
该函数以命名元组 (namedtuple) 的结构体返回信息。如果出现错误,则结果为 None。
使用此函数,你可以使用一个调用来获取在 MQL5 中由 AccountInfoInteger、 AccountInfoDouble 和 AccountInfoString 提供的所有信息,包括支持特性的所有变体。元组中字段的名称对应于没有 "ACCOUNT_" 前缀的枚举元素的名称,简化为小写。
本书中包含以下 MQL5/Scripts/MQL5Book/Python/accountinfo.py 脚本。
import MetaTrader5 as mt5
|
结果应该是这样的。
AccountInfo(login=25115284, trade_mode=0, leverage=100, limit_orders=200, margin_so_mode=0, ... Show account_info()._asdict(): login=25115284 trade_mode=0 leverage=100 limit_orders=200 margin_so_mode=0 trade_allowed=True trade_expert=True margin_mode=2 currency_digits=2 fifo_close=False balance=99511.4 credit=0.0 profit=41.82 equity=99553.22 margin=98.18 margin_free=99455.04 margin_level=101398.67590140559 margin_so_call=50.0 margin_so_so=30.0 margin_initial=0.0 margin_maintenance=0.0 assets=0.0 liabilities=0.0 commission_blocked=0.0 name=MetaQuotes Dev Demo server=MetaQuotes-Demo currency=USD company=MetaQuotes Software Corp. |