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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mt5linux-1.1.1.tar.gz (39.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mt5linux-1.1.1-py3-none-any.whl (40.9 kB view details)

Uploaded Python 3

File details

Details for the file mt5linux-1.1.1.tar.gz.

File metadata

  • Download URL: mt5linux-1.1.1.tar.gz
  • Upload date:
  • Size: 39.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mt5linux-1.1.1.tar.gz
Algorithm Hash digest
SHA256 5bf77cb9cc103be73d61e26a50b5abac994887e1dd0f5aa002f717987cf637ce
MD5 e3b8ad158e3f6e2089f2d0e2e0e994c6
BLAKE2b-256 a505747be6fab3f6d6f67d0f5887fef174745cb603a8f8089b0fffc77a6da510

See more details on using hashes here.

File details

Details for the file mt5linux-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: mt5linux-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 40.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.14.6

File hashes

Hashes for mt5linux-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0165d82dfa64ab6decee017bd9fd335040d758cb339cbaa77421b700d8a035d3
MD5 500fdb1ffeb0de8bf25cc4b5d3de4d40
BLAKE2b-256 8ed1d1fee2705eefcb31425cb9fa24b36ce90ca9417c34ca50751ae15c24f54d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page