metatrader5
API Connector to MetaTrader 5 Terminal
What it is and what it does
MetaTrader 5 for Python is a connector that bridges Python code to the MetaTrader 5 Terminal, a multi-asset trading platform used primarily for Forex and stock market access. It lets you programmatically fetch historical price data (bars and ticks), query instrument metadata, and execute trading operations from Python, automating what would otherwise require manual interaction with the terminal's UI. The package handles platform launch, data synchronization with the broker's server, and data transfer automatically.
The package depends on numpy for data handling and runs on Python 3.6–3.14 on Windows only. It is actively maintained and carries no known security vulnerabilities. Installation requires both the Python package and a working MetaTrader 5 Terminal installation on your system; the package itself is a thin wrapper around the terminal's C API.
Use it for:
- Fetch historical OHLC bars and tick data for backtesting trading strategies in Python.
- Automate order placement and position management across multiple instruments via Python scripts.
- Analyze price data from hundreds of instruments using numpy and pandas without manual terminal interaction.
- Build algorithmic trading systems that react to real-time market data streamed from MetaTrader 5.
- Integrate MetaTrader 5 data into a larger Python analytics or machine-learning pipeline.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Connects Python to MetaTrader 5 Terminal to retrieve financial market data (bars, ticks, instrument details) and execute trading operations via the platform's API.
Yes, if you trade or analyze markets via MetaTrader 5 and want to automate data retrieval or trading logic in Python. The package is actively maintained, carries no security issues, and has a permissive license. The main constraint is that it requires Windows and a running MetaTrader 5 Terminal installation—if you lack either, it will not work.
Install
metatrader5 on PyPI
pip
pip install metatrader5uv
uv add metatrader5poetry
poetry add metatrader5Installing metatrader5
Before you install
Medium install friction: Windows-only wheels for Python 3.6–3.14. Requires MetaTrader 5 Terminal installed and running on the system; the package itself is actively maintained with a recent release.
License in practice
MIT license is permissive; you can use, modify, and distribute this package freely with minimal restrictions.
Quickstart
import metatrader5 as mt5
import numpy as np
mt5.initialize()
rates = mt5.copy_rates_from("EURUSD", mt5.TIMEFRAME_D1, 0, 10)
mt5.shutdown()
MetaTrader 5 Terminal must be installed and running on Windows; the package does not work on macOS or Linux.
Verify before relying
- Whether the package works with MetaTrader 5 Terminal versions other than the latest.
- Real-world latency and throughput limits for high-frequency data retrieval.
- Broker-specific limitations or compatibility issues beyond the platform itself.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (<4,>=3.6) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 13 days since the last release |
| First released | |
| Downloads | 184,423/month — #10,037 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: metatrader5-5.0.6090-cp310-cp310-win_amd64.whl; metatrader5-5.0.6090-cp311-cp311-win_amd64.whl; metatrader5-5.0.6090-cp312-cp312-win_amd64.whl; metatrader5-5.0.6090-cp313-cp313-win_amd64.whl; metatrader5-5.0.6090-cp314-cp314-win_amd64.whl; metatrader5-5.0.6090-cp36-cp36m-win_amd64.whl; metatrader5-5.0.6090-cp37-cp37m-win_amd64.whl; metatrader5-5.0.6090-cp38-cp38-win_amd64.whl; metatrader5-5.0.6090-cp39-cp39-win_amd64.whl
Keywords: metatrader, mt5, metaquotes, mql5, forex, currency, exchange
Tags
More Financial packages
statsmodels provides statistical models,…
permissive · top 1,000 on PyPI
yfinanceFetches financial and market data from Yahoo…
permissive · top 1,000 on PyPI
bokehBokeh is an interactive visualization library…
permissive · top 5,000 on PyPI
python-stdnumParses, validates, and reformats standard…
copyleft · top 5,000 on PyPI
panelPanel is a Python framework for building…
permissive · top 5,000 on PyPI
databentoOfficial Python client for accessing live and…
permissive · top 5,000 on PyPI
finvizfinanceScrapes financial data from FinViz website,…
permissive · top 15,000 on PyPI
tradingeconomicsProvides Python access to over 300,000 economic…
permissive · top 15,000 on PyPI
kiteconnectOfficial Python client for the Kite Connect…
permissive · top 15,000 on PyPI
tradingview-screenerQuery TradingView's screener API to retrieve…
permissive · top 15,000 on PyPI
openbb-tradingeconomicsIntegrates Trading Economics data into the…
agpl · top 15,000 on PyPI
tdxpyTdxPy provides a pure-Python interface to read…
permissive · top 15,000 on PyPI
tradingview-taRetrieves technical analysis indicators and…
permissive · top 15,000 on PyPI
ib-insyncProvides a Python async/sync interface to…
permissive · top 15,000 on PyPI
simplefixSimplefix provides a lightweight FIX (Financial…
permissive · top 15,000 on PyPI
mootdxReads market data from Tongdaxin (a Chinese…
permissive · top 15,000 on PyPI