import MetaTrader5 as mt5
import pandas as pd
# 显示有关MetaTrader 5程序包的数据
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# 显示有关MetaTrader 5程序包的数据
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# 建立与MetaTrader 5程序端的连接
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
# 显示有关MetaTrader 5版本的数据
print(mt5.version())
# 显示有关程序端设置和状态的信息
terminal_info=mt5.terminal_info()
if terminal_info!=None:
# display the terminal data 'as is'
print(terminal_info)
# display data in the form of a list
print("Show terminal_info()._asdict():")
terminal_info_dict = mt5.terminal_info()._asdict()
for prop in terminal_info_dict:
print(" {}={}".format(prop, terminal_info_dict[prop]))
print()
# 将词典转换为DataFrame和print
df=pd.DataFrame(list(terminal_info_dict.items()),columns=['property','value'])
print("terminal_info() as dataframe:")
print(df)
# 断开与MetaTrader 5程序端的连接
mt5.shutdown()
结果:
MetaTrader5程序包作者:MetaQuotes Software Corp.
MetaTrader5程序包版本:5.0.29
[500, 2366, '20 Mar 2020']
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\Rosh\AppData\Roaming\MetaQuotes\Terminal\Common
terminal_info() as dataframe:
property value
0 community_account True
1 community_connection True
2 connected True
3 dlls_allowed False
4 trade_allowed False
5 tradeapi_disabled False
6 email_enabled False
7 ftp_enabled False
8 notifications_enabled False
9 mqid False
10 build 2367
11 maxbars 5000
12 codepage 1251
13 ping_last 80953
14 community_balance 707.107
15 retransmission 0.063593
16 company MetaQuotes Software Corp.
17 name MetaTrader 5
18 language Russian
|