Dwx Zeromq Connector
Wrapper library for algorithmic trading in Python 3, providing DMA/STP access to Darwinex liquidity via a ZeroMQ-enabled MetaTrader Bridge EA.
Install / Use
npx skills add darwinex/dwx-zeromq-connectorInstalls into whichever agent you are using.
README
Important Update (15 Feb 2022):
DWX ZeroMQ Connector will be soon be archived (available to use, but not actively maintained).
We encourage both new and existing users to please visit its successor DWX Connect, that alongside removing the ZeroMQ dependency, also brings with it native support for both MetaTrader 4 and 5 without any 3rd-party dependencies 🙌
Many thanks!
DWX ZeroMQ Connector { Python 3 to MetaTrader 4 }
Latest version: 2.0.1 (here)
Need help? Join the Darwinex Collective Slack for code updates, Q&A and more.
About Darwinex
Darwinex is a UK FCA-Regulated broker & technology provider, enabling traders to:
- Trade the markets on the best terms and competitive execution conditions
- Develop their trading skills and build verifiable, investable track records
- Provide regulatory cover to attract capital and charge a 20% performance fee on investor profits
Please take a moment to read our Risk Disclosure here
Click here to visit our Trader Hall of Fame * ranked by Performance Fees earned (over 2M EUR paid to date)
Click here to Open a Darwinex Trading Account
Table of Contents
- Introduction
- Installation
- Configuration
- Example Usage
- Video Tutorials
- Complete list of available functions
- License
Introduction
In this project, we present a technique employing ZeroMQ (an Open Source, Asynchronous Messaging Library and Concurrency Framework) for building a basic – but easily extensible – high performance bridge between external (non-MQL) programming languages and MetaTrader 4.
IMPORTANT NOTES - PLEASE READ:
-
Please note that we cannot provide support for Python or MQL as programming languages themselves. Therefore, if you are new to Python and MQL, incorporating the project into your specific algorithmic trading environment will require some additional work on your part (i.e. enough Python experience to integrate the Bridge into your environment -> it is assumed that users of the Bridge are self-sufficient in Python).
-
Any code provided and/or referenced in this repository is NOT meant to be used "as-is". Users must treat all code as educational content that requires modification / incorporation into existing works, as per their individual requirements.
-
We have drafted as detailed a set of steps as possible in our project README, but cannot cover all the dependencies as they are independent projects on their own that programmers need to account for / follow / keep up to speed with when considering using the DWX ZeroMQ Connector.
-
This project and all accompanying source code should be run standalone (i.g. via a Python or IPython console, or batch process).
-
Please DO NOT run this code in Jupyter or IPython Notebooks.
-
The project's dependencies require MS VC++ Libraries. Without these installed, you are likely to run into "Resource Timeout" errors. The DLLs in the dependency projects (mql-zmq, libzmq, libsodium) require that you have the latest Visual C++ runtime (2015) libraries already installed.
-
This project has not been tested on emulated environments (e.g. WINE, VMWare, etc).
-
This project is intended for use solely in Windows 10 environments, at the present time.
Reasons for writing this post:
- Lack of comprehensive, publicly available literature about this topic on the web.
- Traders have traditionally relied on Winsock/WinAPI based solutions that often require revision with both Microsoft™ and MetaQuotes™ updates.
- Alternatives to ZeroMQ include named pipes, and approaches where filesystem-dependent functionality forms the bridge between MetaTrader and external languages.
We lay the foundation for a distributed trading system that will:
- Consist of one or more trading strategies developed outside MetaTrader 4 (non-MQL),
- Use MetaTrader 4 for acquiring market data, trade execution and management,
- Support multiple non-MQL strategies interfacing with MetaTrader 4 simultaneously,
- Consider each trading strategy as an independent “Client”,
- Consider MetaTrader 4 as the “Server”, and medium to market,
- Permit both Server and Clients to communicate with each other on-demand.
Infographic: ZeroMQ-Enabled Distributed Trading Infrastructure (with MetaTrader 4)

Why ZeroMQ?
- Enables programmers to connect any code to any other code, in a number of ways.
- Eliminates a MetaTrader user’s dependency on just MetaTrader-supported technology (features, indicators, language constructs, libraries, etc.)
- Traders can develop indicators and strategies in C/C#/C++, Python, R and Java (to name a few), and deploy to market via MetaTrader 4.
- Leverage machine learning toolkits in Python and R for complex data analysis and strategy development, while interfacing with MetaTrader 4 for trade execution and management.
- ZeroMQ can be used as a high-performance transport layer in sophisticated, distributed trading systems otherwise difficult to implement in MQL.
- Different strategy components can be built in different languages if required, and seamlessly talk to each other over TCP, in-process, inter-process or multicast protocols.
- Multiple communication patterns and disconnected operation.
Installation
This project requires the following:
- Python: (minimum v3.6)
- libzmq: (minimum v4.2.5)
- pyzmq: (minimum v17.1.2)
- libsodium (https://github.com/jedisct1/libsodium)
- mql4-lib (https://github.com/dingmaotu/mql4-lib)
- mql-zmq (https://github.com/dingmaotu/mql-zmq)
You may install Python-specific dependencies either via pip install -r ./v2.0.1/python/api/requirements.txt or via installing the latest Anaconda distribution (Python 3 variants).
For your convenience, files from the last three items above have been included in this repository with appropriate copyrights referenced within.
This project incorporates functionality authored by Ding Li (GitHub: https://github.com/dingmaotu), who has kindly licensed his work under the Apache 2.0 license.
We acknowledge copyright as per the terms of the license, the following repositories serving as mandatory dependencies for this project:
-
https://github.com/dingmaotu/mql-zmq
-
https://github.com/dingmaotu/mql4-lib
Thank you Ding for your amazing open source contribution to this space!
Sincerely,<br> The Darwinex Labs Team<br> www.darwinex.com
Steps:
- Download and unzip mql-zmq-master.zip (by GitHub author @dingmaotu)
- Copy the contents of mql-zmq-master/Include/Mql and mql-zmq-master/Include/Zmq into your MetaTrader installation's MQL4/Include directory as-is. Your MQL4/Include directory should now have two additional folders "Mql" and "Zmq".
- Copy libsodium.dll and libzmq.dll from mql-zmq-master/Library/MT4 to your MetaTrader installation's MQL4/Libraries directory.
- Download DWX_ZeroMQ_Server_vX.Y.Z_RCx.mq4 and place it inside your MetaTrader installation's MQL4/Experts directory.
- Finally, download v2.0.1 / python / api / DWX_ZeroMQ_Connector_v2_0_1_RC8.py.
Configuration
-
After completing the steps above, terminate and restart MetaTrader 4.
-
Open any new chart, e.g. EUR/USD M, then drag and drop DWX_ZeroMQ_Server_v2.0.1_RC8.
-
Switch to the EA's Inputs tab and customize values as necessary:

-
Note: The variable Publish_MarketData was removed in recent versions. There is no need to modify this variable or to manually change the Publish_Symbols array. Symbols will automatically be added when the
_DWX_MTX_SEND_TRACKPRICES_REQUEST_()function is called in python (see code example below).

Example Usage
Subscribe/Unsubscribe to/from EUR/USD bid/ask prices in real-time:
# subscribe to data:
_zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD')
# tell MT4 to publish data:
_zmq._DWX_MTX_SEND_TRACKPRICES_REQUEST_(['EURUSD'])
Output:
[KERNEL] Subscribed to EURUSD BID/ASK updates. See self._Market_Data_DB.
# BID/ASK prices are now being streamed into _zmq._Market_Data_DB.
_zmq._Market_Data_DB
Output:
{'EURUSD': {
'2019-01-08 13:46:49.157431': (1.14389, 1.14392),
'2019-01-08 13:46:50.673151': (1.14389, 1.14393),
'2019-01-08 13:46:51.010993': (1.14392, 1.14395),
'2019-01-08 13:46:51.100941': (1.14394, 1.14398),
'2019-01-08 13:46:51.205881': (1.14395, 1.14398),
'2019-01-08 13:46:52.283107': (1.14394, 1.14397),
'2019-01-08 13:46:52.377055': (1.14395, 1.14398),
'2019-01-08 13:46:52.777823': (1.14394, 1.14398),
'2019-01-08 13:46:52.870773': (1.14395, 1.14398),
'2019-01-08 13:46:52.985708': (1.14395, 1.14397),
'2019-01-08 13:46:53.080652': (1.14393, 1.14397),
'2019-01-08 13:46:53.196584': (1.14394, 1.14398),
'2019-01-08 13:46:53.294541': (1.14393, 1.14397)}}
_zmq
Related Skills
node-connect
385.5kDiagnose OpenClaw Android, iOS, or macOS node pairing, QR/setup code, route, auth, and connection failures.
python-debugpy
385.5kDebug Python with pdb, breakpoint(), post-mortem inspection, and debugpy remote attach.
skill-creator
385.5kCreate, edit, audit, tidy, validate, or restructure AgentSkills and SKILL.md files.
claude-opus-4-5-migration
140.6kMigrate prompts and code from Claude Sonnet 4.0, Sonnet 4.5, or Opus 4.1 to Opus 4.5
