pymt5 Documentation

pymt5 is an asynchronous Python client for the MetaTrader 5 Web Terminal. It connects over a reverse-engineered, encrypted WebSocket binary protocol and provides account queries, market data, streaming callbacks, and trading helpers.

The PyPI distribution is named mt5-web-client; the Python import is pymt5. Python 3.11 or newer is required.

Warning

This is an unofficial, experimental client. It is not affiliated with or endorsed by MetaQuotes. Protocol behavior varies by broker, server build, symbol, and market session. Start with an authorized demo account, validate every required workflow, and never treat a request timeout as proof that a trade was not executed.

Choose your path

I want to…

Start here

Then read

Install and make a first read-only connection

Installation and Quick Start

Configuration

Retrieve bars or stream ticks and order-book updates

Market Data

Push Notifications

Use trading helpers on an authorized demo account

Trading

Security and Operational Safety and Reliability

Handle disconnects, timeouts, and server rejections

Reliability

Troubleshooting

Look up a method, command, or compatibility helper

API Reference

Protocol Reference and Official Python API Compatibility

Run tests or improve the documentation

Development Guide

Changelog

Quick installation

python -m pip install mt5-web-client

A first connection should load account and symbol data without placing an order. See Quick Start for a complete environment-based example.

Capabilities and boundaries

  • Async WebSocket lifecycle, bootstrap key exchange, login, heartbeat, and optional automatic reconnection.

  • Account, position, order, deal, symbol, historical-bar, tick, and order-book APIs.

  • Raw and typed push callbacks, local caches, optional metrics, and structured logging.

  • High-level trading helpers plus a lower-level trade_request() API.

  • MetaTrader5-style compatibility helpers where the Web Terminal exposes an equivalent; local or cached helpers are identified as such.

  • Explicit compatibility controls for tick prices, historical bar layouts, and trade request profiles. Observed support for one build is not a guarantee for another server.

Documentation map

User guides