import MetaTrader5 as mt5
# MetaTrader 5 패키지에 데이터 표시
print("MetaTrader5 패키지 작성자: ",mt5.__author__)
print("MetaTrader5 패키지 버전: ",mt5.__version__)
# MetaTrader 5 터미널과의 연결 설정
if not mt5.initialize():
print("initialize() 실패, 오류 코드 =",mt5.last_error())
quit()
# MetaTrader 5 버전에서 데이터 표시
print(mt5.version())
# 비밀번호와 서버를 지정하지 않고 거래 계정에 연결합니다.
account=17221085
authorized=mt5.login(account) # 터미널 데이터베이스 비밀번호가 연결 데이터를 기억하도록 설정된 경우 적용됩니다.
if authorized:
print("다음 계정에 연결 #{}".format(account))
else:
print("계정 연결 실패 #{}, 오류 코드: {}".format(account, mt5.last_error()))
# 이제 비밀번호를 지정하는 다른 거래 계정에 연결합니다.
account=25115284
authorized=mt5.login(account, password="gqrtz0lbdm")
if authorized:
# 거래 계정 데이터를 "있는 그대로" 표시
print(mt5.account_info())
# 거래 계정 데이터를 목록 형식으로 표시
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("계정 연결 실패 #{}, 오류 코드: {}".format(account, mt5.last_error()))
# MetaTrader 5 터미널 연결 종료
mt5.shutdown()
Result:
MetaTrader5 패키지 작성자: MetaQuotes Software Corp.
MetaTrader5 패키지 버전: 5.0.29
[500, 2367, '23 Mar 2020']
계정 #17221085에 연결
계정 #25115284에 연결
AccountInfo(login=25115284, trade_mode=0, leverage=100, limit_orders=200, margin_so_mode=0, ...
계정 속성:
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=99588.33
credit=0.0
profit=-45.23
equity=99543.1
margin=54.37
margin_free=99488.73
margin_level=183084.6054809638
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=James Smith
server=MetaQuotes-Demo
currency=USD
company=MetaQuotes Software Corp.
|