Ejemplo n.º 1
0
def get_symbol_total():
    """
    :return: int: number of symbols
    """
    num_symbols = mt5.symbols_total()
    if num_symbols > 0:
        print("Total symbols: ", num_symbols)
    else:
        print("Symbols not found.")
    return num_symbols
Ejemplo n.º 2
0
    def get_symbols(self):
        """
        Gets list of symbols open in MT5 market watch.
        :return: list of symbol names
        """
        # Iterate symbols and get those in market watch.
        symbols = MetaTrader5.symbols_get()
        selected_symbols = []
        for symbol in symbols:
            if symbol.visible:
                selected_symbols.append(symbol.name)

        # Log symbol counts
        total_symbols = MetaTrader5.symbols_total()
        num_selected_symbols = len(selected_symbols)
        self.__log.debug(
            f"{num_selected_symbols} of {total_symbols} available symbols in Market Watch."
        )

        return selected_symbols
Ejemplo n.º 3
0
#first_metatrader_program

import MetaTrader5 as mt5

mt5.initialize()

SymbolsTotal = mt5.symbols_total()

if SymbolsTotal > 0:
    print("Total de simbolos: ", SymbolsTotal)

else:
    print("Símbolos não encontrados")

mt5.shutdown()
Ejemplo n.º 4
0
import MetaTrader5 as mt5

# 显示有关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()

# 获取交易品种的数量
symbols = mt5.symbols_total()
if symbols > 0:
    print("Total symbols =", symbols)

# 断开与MetaTrader 5程序端的连接
mt5.shutdown()
Ejemplo n.º 5
0
# login to my account and print account info
account = 40902528
authorized = mt5.login(account, password="******")
if authorized:
    # 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()))

# get number of all financial instruments in the terminal
symbols_nr = mt5.symbols_total()
print(f'total symbols {symbols_nr}')

# get selected symbols current info
my_symbols_etf = [
    'IVE', 'VWRL', 'IVW', 'SWDA', 'IMEA', 'IJH', 'IWM', 'VLUE', 'SPY', 'ITOT',
    'ITB', 'IJR', 'XLK', 'QQQ', 'IXJ', 'XBI', 'IBB', 'UBIO', 'IAU', 'SLV',
    'XLRE', 'IEI', 'TLTUS', 'MSCI', 'SDIV', 'HDV', 'VYM', 'SPHD'
]
my_symbols_stocks = [
    'MSFT', 'ORCL', 'NVDA', 'INTC', 'GOOG', 'AMD', 'ZOOM', 'DELL', 'AAPL',
    'SYNA', 'DPZ', 'CROX', 'AMZN', 'BRKB', 'HSBA', 'BNP', 'DBK', 'BLK', 'BABA',
    'SPOT', 'PYPL', 'NFLX', 'STOR', 'SAFE', 'SP', 'RIO', 'GAZ', 'CVX', 'BP',
    'ROSN', 'D', 'ES', '7272.JP', 'BAYN', 'TSLA', 'ABT', 'UCB', 'MRNA', 'GILD',
    'BSX', 'REGN', 'VRTX', 'LUV', 'BCO', 'DAL'
]