MT5_LinuxOHLCV
MT5_LinuxOHLCV is a small Linux-side wrapper around mt5linux that fetches OHLCV data from a running MetaTrader 5 terminal exposed through the bridge.
Install
pip install MT5_LinuxOHLCV
For local development from this workspace:
pip install .
Requirements
- A running MetaTrader 5 terminal started under Wine or another Windows-compatible environment.
- The
mt5linuxbridge running and reachable from Linux on the address and port you pass into the client. - Symbols available in the terminal before requesting data.
Start MetaTrader 5
Launch the MetaTrader 5 terminal through Wine:
WINEPREFIX=~/.mt5 wine "$HOME/.mt5/drive_c/Program Files/MetaTrader 5/terminal64.exe" &
Keep the terminal running in the background before starting the Python client.
Install Windows-side Python packages
The Wine Python environment must have both mt5linux and MetaTrader5 installed before the bridge can start:
WINE_PYTHON="$HOME/.mt5/drive_c/users/$USER/AppData/Local/Programs/Python/Python311/python.exe"
WINEPREFIX=~/.mt5 wine "$WINE_PYTHON" -m pip install mt5linux MetaTrader5
Start the mt5linux bridge
From the Wine-installed Windows Python, start the mt5linux server that listens for Linux-side clients:
WINE_PYTHON="$HOME/.mt5/drive_c/users/$USER/AppData/Local/Programs/Python/Python311/python.exe"
WINEPREFIX=~/.mt5 wine "$WINE_PYTHON" -m mt5linux
Usage
MT5_LinuxOHLCV holds the connection settings and keeps the bridge connection open, so you only pay
the connection warm-up once, no matter how many times you call fetch_ohlcv. Use it as a context
manager so the connection is always closed:
from MT5_LinuxOHLCV import MT5_LinuxOHLCV
with MT5_LinuxOHLCV(
terminal_path=r"C:\Program Files\MetaTrader 5\terminal64.exe",
bridge_host="127.0.0.1",
bridge_port=18812,
) as client:
df = client.fetch_ohlcv(["PETR4"], timeframes=["1m", "1d"])
print(df.tail())
# Reuses the same open connection.
df2 = client.fetch_ohlcv(["VALE3"], timeframes="1d")
print(df2.tail())
You can also manage the connection lifecycle manually:
client = MT5_LinuxOHLCV(bridge_host="127.0.0.1", bridge_port=18812)
client.connect()
try:
df = client.fetch_ohlcv(["PETR4"], timeframes="1d")
finally:
client.close()
The default bridge settings remain localhost:18812, so you only need to pass these when the server is elsewhere.
Testing
Tests stub out the mt5linux bridge, so they run without a MetaTrader terminal or the mt5linux
server:
pip install -e ".[test]"
pytest
License
GNU General Public License v3.0. See LICENSE for the full text.
Metadata
Release files for MT5-LinuxOHLCV 0.1.2
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 |
|---|---|---|---|---|
| mt5_linuxohlcv-0.1.2.tar.gz | 32.0 kB | Without provenance | Details for mt5_linuxohlcv-0.1.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mt5_linuxohlcv-0.1.2-py3-none-any.whl | Python 3 | none | any | Details for mt5_linuxohlcv-0.1.2-py3-none-any.whl |
Total release size: 61.5 kB
Release files / mt5_linuxohlcv-0.1.2.tar.gz
| Download URL | mt5_linuxohlcv-0.1.2.tar.gz |
|---|---|
| Size | 32.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e5ee16041a4190240e69dd28c9c927a2e0a7912f922d9d76cb75c68142d3c12
|
|
BLAKE2b-256 checksum How to use checksums |
15ae4926e9ee582d7b33aeaa69370feb97a965d4c85ef0ba857129b4a8e75b3f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Release files / mt5_linuxohlcv-0.1.2-py3-none-any.whl
| Download URL | mt5_linuxohlcv-0.1.2-py3-none-any.whl |
|---|---|
| Size | 29.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c84c4b4575a7a083d1fe33b75d19a1162966346531a67e2f364b62dd8ed0e698
|
|
BLAKE2b-256 checksum How to use checksums |
1e55962cdda83b53f1593dab0470f7b5d7227f7ef5493f879b092f837c9b89dd
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.6
|
Security for MT5-LinuxOHLCV 0.1.2
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.