mt5linux

raw JSON →
1.0.3 verified Fri May 01 auth: no python

A Python library that wraps the MetaTrader5 API using a server-client architecture, enabling MetaTrader5 operations (e.g., account info, market data, orders) on Linux systems where the official MetaTrader5 package cannot be installed. Version 1.0.3 is stable but lightly maintained; no major release cadence.

pip install mt5linux
error ConnectionRefusedError: [Errno 111] Connection refused
cause The mt5linux server is not running or not reachable at the specified host/port.
fix
Ensure the mt5linux server application is running on the Windows machine and that the firewall allows TCP port 5050 (or your custom port).
error AttributeError: module 'mt5linux' has no attribute 'Mt5Linux'
cause Incorrect import: you used `import mt5linux` instead of `from mt5linux import Mt5Linux`.
fix
Use the correct import: from mt5linux import Mt5Linux.
error TypeError: 'NoneType' object is not subscriptable
cause Some mt5linux methods (e.g., get_symbol_tick) return None on failure. Code assumes dict.
fix
Always check the return for None before accessing keys: tick = mt5.get_symbol_tick('EURUSD'); if tick is None: ...
gotcha mt5linux is a CLIENT library only. You MUST run the separate mt5linux server application (Windows-only) that has MetaTrader5 installed. The client (on Linux/Mac) simply send requests to that Windows server via TCP sockets.
fix Install and launch the mt5linux server on a Windows machine with MT5. Then connect from your Linux client.
gotcha Many mt5linux methods mimic MetaTrader5 API but with different naming (e.g., account_info instead of account_info()), and results are dictionaries, not namedtuples. Do not use MetaTrader5 documentation for exact function signatures.
fix Refer to the mt5linux README or source code for available client methods.
deprecated The library is not actively maintained. The last commit on GitHub was in 2022. Issues and pull requests may go unanswered.
fix Consider forking or using alternatives (e.g., MT5 via Wine + pywinauto or the official MetaTrader5 package if on Windows).

Connect to an existing mt5linux server and fetch account info.

from mt5linux import Mt5Linux

# Connect to already running mt5linux server (default host/port)
mt5 = Mt5Linux('localhost', 5050)

# Check connection
print('Connected:', mt5.connected)

# Get account info
account_info = mt5.account_info()
print('Account:', account_info)

# Get symbol tick (adjust symbol and server settings as needed)
# tick = mt5.get_symbol_tick('EURUSD')