MetaTrader 5 for Linux
A package that uses Wine, RPyC, and mt5server.exe (a standalone binary with all dependencies) to run MetaTrader5 on Linux.
For an explanation of who should use mt5linux and why, see Motivation and Use Cases.
Installation
-
Install Wine.
-
Install this package on Linux Python:
pip install mt5linux
-
Download the latest mt5server.exe release binary.
Docker
Alternatively, you can run this library using Docker, see the Docker docs.
Usage
Option 1: Library-Managed Containers (Recommended for Docker)
The library can automatically start and stop Docker containers for you:
from mt5linux import MetaTrader5
mt5 = MetaTrader5(
host="localhost",
mt5_login=12345678,
mt5_password="your_password",
mt5_server="Broker-Server",
engine="auto", # 'auto', 'docker', or 'udocker'
image_tag="latest", # Docker image tag
ui_port=8080, # noVNC http port (auto-selected if None)
ui_host="localhost", # noVNC host for the UI URL
ui_password=None, # noVNC password
vnc_port=5901, # VNC port
)
mt5.initialize()
mt5.terminal_info()
mt5.shutdown()
# Container is automatically stopped when mt5 is deleted
Option 2: Manual Docker
Run Docker manually with docker compose up -d, then connect:
from mt5linux import MetaTrader5
mt5 = MetaTrader5(host="localhost", port=18812)
mt5.initialize()
mt5.terminal_info()
mt5.shutdown()
Option 3: Standalone Server (Linux with Wine)
-
Open MetaTrader5 on Windows/Wine.
-
Start the server:
wine mt5server.exe [-p/--port <port>]
The default port is
18812. View all options with:wine mt5server.exe --help
-
Connect from Linux Python:
from mt5linux import MetaTrader5 mt5 = MetaTrader5() mt5.initialize(server=<server_ip>, login=<login_id>, password=<password>) # Or simply: mt5.initialize() to auto-search for the server mt5.terminal_info() mt5.shutdown()
Accessing Container Properties
When using library-managed containers, access the container manager via the container property:
mt5 = MetaTrader5(mt5_login=12345678, mt5_password="password")
print(mt5.container.name) # Container name
print(mt5.container.status()) # 'running', 'exited', etc.
print(mt5.container.ui_port) # noVNC port
print(mt5.container.is_running()) # True/False
mt5.container.stop() # Stop container
mt5.container.start() # Start container (if using controlled containers)
mt5.container.remove() # Remove container
For full API documentation, see the official MetaTrader5 Python integration.
Thanks
- hpdeandrade for many improvements and insights about docker.
- ananta-dev for project motivation.
Metadata
Release files for mt5linux 1.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mt5linux-1.1.1.tar.gz | 39.0 kB | Without provenance | Details for mt5linux-1.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mt5linux-1.1.1-py3-none-any.whl | Python 3 | none | any | Details for mt5linux-1.1.1-py3-none-any.whl |
Total release size: 79.9 kB
Release files / mt5linux-1.1.1.tar.gz
| Download URL | mt5linux-1.1.1.tar.gz |
|---|---|
| Size | 39.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5bf77cb9cc103be73d61e26a50b5abac994887e1dd0f5aa002f717987cf637ce
|
|
BLAKE2b-256 checksum How to use checksums |
a505747be6fab3f6d6f67d0f5887fef174745cb603a8f8089b0fffc77a6da510
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Release files / mt5linux-1.1.1-py3-none-any.whl
| Download URL | mt5linux-1.1.1-py3-none-any.whl |
|---|---|
| Size | 40.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0165d82dfa64ab6decee017bd9fd335040d758cb339cbaa77421b700d8a035d3
|
|
BLAKE2b-256 checksum How to use checksums |
8ed1d1fee2705eefcb31425cb9fa24b36ce90ca9417c34ca50751ae15c24f54d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.6
|
Security for mt5linux 1.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.