mt5.symbols_get() in MetaTrader5 Python: list symbols, with an optional filter

Returns the terminal's symbols as a tuple of named tuples, all of them or only those that match a group filter such as "*USD*". None on failure.

Signature

mt5.symbols_get()
mt5.symbols_get(group="...")

What it does

With no argument, symbols_get() returns every symbol the terminal knows. Each item holds the same fields as symbol_info().

The group filter takes * as a wildcard, commas between patterns, and ! in front of a pattern to leave it out.

Parameters

ParameterWhat it is
groupOptional filter, for example "*USD*" or "*,!*JPY*". Put the patterns to include first and the ones to leave out after them.

What it returns

  • A tuple of symbol records. Read .name for the symbol name.
  • None on failure. Check mt5.last_error().

Example

import MetaTrader5 as mt5

if not mt5.initialize():
    raise SystemExit(mt5.last_error())

# Every symbol with USD in its name, except the ones with JPY
found = mt5.symbols_get(group="*USD*,!*JPY*")
if found is None:
    raise SystemExit(mt5.last_error())
for s in found[:10]:
    print(s.name, s.digits, s.spread)
mt5.shutdown()

Common mistakes

  • Brokers add suffixes such as EURUSD.r or EURUSDm. Look the real name up with a pattern instead of typing it.
  • Each record carries a price snapshot from the moment of the call. Do not reuse it as a live quote.
  • On a server with thousands of symbols the full list is large. Filter with group when you only need a few.

The same with Tickwire on Linux

The package needs a Windows terminal on the same machine. Tickwire runs the terminal for you and gives you a REST API, so the code below runs on Linux, macOS or a server.

Tickwire's symbols route returns every symbol name as a JSON array. Filter it in your own code, then read the details of the ones you need from the specification route.

import os, requests

API = "https://api.tickwire.io"
h = {"auth-token": os.environ["TW_KEY"]}      # your Tickwire key
base = f"{API}/users/current/accounts/{os.environ['TW_ACCOUNT']}"

names = requests.get(f"{base}/symbols", headers=h).json()
usd = [n for n in names if "USD" in n and "JPY" not in n]
print(usd[:10])

Related error codes

All MetaTrader5 Python functions

MT5 from Python, on any machine

One REST API for MT4 and MT5, with idempotent orders and an audit log. Read the MT5 Python API page or the quickstart.