-
Notifications
You must be signed in to change notification settings - Fork 0
/
connections.py
31 lines (27 loc) · 1.07 KB
/
connections.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import MetaTrader5 as mt5
from datetime import date
import pandas as pd
import matplotlib.pyplot as plt
import MetaTrader5 as mt5
# display data on the MetaTrader 5 package
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
# establish connection to the MetaTrader 5 terminal
if not mt5.initialize():
print("initialize() failed, error code =",mt5.last_error())
quit()
# now connect to another trading account specifying the password
account = 35146240
authorized=mt5.login(account, password="xt7lixru")
if authorized:
# display trading account data 'as is'
print(mt5.account_info())
""" # display trading account data in the form of a list
print("Show account_info()._asdict():")
account_info_dict = mt5.account_info()._asdict()
for prop in account_info_dict:
print(" {}={}".format(prop, account_info_dict[prop])) """
else:
print("failed to connect at account #{}, error code: {}".format(account, mt5.last_error()))
# shut down connection to the MetaTrader 5 terminal
#mt5.shutdown()