import MetaTrader5 as mt5
import pandas as pd
# MetaTrader 5パッケージについてのデータを表示する
print("MetaTrader5 package author: ",mt5.__author__)
print("MetaTrader5 package version: ",mt5.__version__)
print()
# MetaTrader 5ターミナルとの接続を確立する
if not mt5.initialize(login=25115284, server="MetaQuotes-Demo",password="4zatlbqx"):
print("initialize() failed, error code =",mt5.last_error())
quit()
# 気配値表示でEURCADの表示を有効にする試み
selected=mt5.symbol_select("EURCAD",True)
if not selected:
print("Failed to select EURCAD, error code =",mt5.last_error())
else:
symbol_info=mt5.symbol_info("EURCAD")
print(symbol_info)
print("EURCAD: currency_base =",symbol_info.currency_base," currency_profit =",symbol_info.currency_profit," currency_margin =",symbol_info.currency_margin)
print()
# ディクショナリの形で銘柄のプロパティを取得する
print("Show symbol_info()._asdict():")
symbol_info_dict = symbol_info._asdict()
for prop in symbol_info_dict:
print(" {}={}".format(prop, symbol_info_dict[prop]))
print()
# ディクショナリをDataFrameに変換して出力する
df=pd.DataFrame(list(symbol_info_dict.items()),columns=['property','value'])
print("symbol_info_dict() as dataframe:")
print(df)
# MetaTrader 5ターミナルへの接続をシャットダウンする
mt5.shutdown()
結果:
MetaTrader5 package author: MetaQuotes Software Corp.
MetaTrader5 package version: 5.0.29
SymbolInfo(custom=False, chart_mode=0, select=True, visible=True, session_deals=0, session_buy_orders=0, session_sell_orders=0, volume=0, volumehigh=0, ....
EURCAD: currency_base = EUR currency_profit = CAD currency_margin = EUR
Show symbol_info()._asdict():
custom=False
chart_mode=0
select=True
visible=True
session_deals=0
session_buy_orders=0
session_sell_orders=0
volume=0
volumehigh=0
volumelow=0
time=1585217595
digits=5
spread=39
spread_float=True
ticks_bookdepth=10
trade_calc_mode=0
trade_mode=4
start_time=0
expiration_time=0
trade_stops_level=0
trade_freeze_level=0
trade_exemode=1
swap_mode=1
swap_rollover3days=3
margin_hedged_use_leg=False
expiration_mode=7
filling_mode=1
order_mode=127
order_gtc_mode=0
option_mode=0
option_right=0
bid=1.55192
bidhigh=1.55842
bidlow=1.5419800000000001
ask=1.5523099999999999
askhigh=1.55915
asklow=1.5436299999999998
last=0.0
lasthigh=0.0
lastlow=0.0
volume_real=0.0
volumehigh_real=0.0
volumelow_real=0.0
option_strike=0.0
point=1e-05
trade_tick_value=0.7043642408362214
trade_tick_value_profit=0.7043642408362214
trade_tick_value_loss=0.7044535553770941
trade_tick_size=1e-05
trade_contract_size=100000.0
trade_accrued_interest=0.0
trade_face_value=0.0
trade_liquidity_rate=0.0
volume_min=0.01
volume_max=500.0
volume_step=0.01
volume_limit=0.0
swap_long=-1.1
swap_short=-0.9
margin_initial=0.0
margin_maintenance=0.0
session_volume=0.0
session_turnover=0.0
session_interest=0.0
session_buy_orders_volume=0.0
session_sell_orders_volume=0.0
session_open=0.0
session_close=0.0
session_aw=0.0
session_price_settlement=0.0
session_price_limit_min=0.0
session_price_limit_max=0.0
margin_hedged=100000.0
price_change=0.0
price_volatility=0.0
price_theoretical=0.0
price_greeks_delta=0.0
price_greeks_theta=0.0
price_greeks_gamma=0.0
price_greeks_vega=0.0
price_greeks_rho=0.0
price_greeks_omega=0.0
price_sensitivity=0.0
basis=
category=
currency_base=EUR
currency_profit=CAD
currency_margin=EUR
bank=
description=Euro vs Canadian Dollar
exchange=
formula=
isin=
name=EURCAD
page=http://www.google.com/finance?q=EURCAD
path=Forex\EURCAD
symbol_info_dict() as dataframe:
property value
0 custom False
1 chart_mode 0
2 select True
3 visible True
4 session_deals 0
.. ... ...
91 formula
92 isin
93 name EURCAD
94 page http://www.google.com/finance?q=EURCAD
95 path Forex\EURCAD
[96 rows x 2 columns]
|