Skip to main content

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

  1. Install Wine.

  2. Install this package on Linux Python:

    pip install mt5linux
    
  3. 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)

  1. Open MetaTrader5 on Windows/Wine.

  2. Start the server:

    wine mt5server.exe [-p/--port <port>]
    

    The default port is 18812. View all options with:

    wine mt5server.exe --help
    
  3. 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

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)

Source distribution for mt5linux 1.1.1
File Size Uploaded
mt5linux-1.1.1.tar.gz 39.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for mt5linux 1.1.1
File Interpreter ABI Platform
mt5linux-1.1.1-py3-none-any.whl Python 3 none any Details

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

Release history Release notifications | RSS feed

This release

1.1.1 This release

2 release files

1.1.0

2 release files

1.0.11

2 release files

1.0.10

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.6

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.0

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

1 release file

0.1.7

1 release file

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page