darwinex / 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.
https://blog.darwinex.com/zeromq-interface-python-r-metatrader4/
BSD 3-Clause "New" or "Revised" License
342 stars 227 forks source link

Zeromq-connector timeout issue, unable to resolve #86

Closed ghost closed 3 years ago

ghost commented 4 years ago

Hi,

I followed all the steps of the installation, setup and troubleshooting for the ZeroMq bridge between python and Metatrader 4 but I was unsuccessful at resolving the “Resource timeout… please try again.”. Python is not communicating with Metatrader and for some reason I still get this Resource timeout… please try again issue. I followed any troubleshooting steps and read all treads I could find. I uninstalled Visual C++ 2017 and installed the 2015 version instead and restarted several times but I was unsuccessful. I also verified all Metatrader 4 settings like automated trading enables and DLL imports. Can anyone help troubleshoot the issue and resolve it. Thank you in advance for any input provided!

ghost commented 3 years ago

Hi,

I am having similar issues. I have all the dependencies in MT4 and Python, all of the Visual C++ file dependency, correct configuration on MT4 with regards to import settings et cetera and the smiley face checked. Following the tutorial is fine when I run it in the IPython kernel, but when I run it as a program file it has the resource timeout error. Already checked the other issues with regards to verbosity but no to avail. Any help would be great! @integracore2

ghost commented 3 years ago

Hi,

played around with it and found the issue, if you run it as a program it terminates before receiving the results - so I am sure there is a better way to do this but a fix would be to request and sleep for a while before retrieving data from _thread_dataouput. Also would love a great suggestion on a clean way to introduce this time buffer that isn't so offensive to software engineering...

ghost commented 3 years ago

Haven't had the time to read properly on zeromq bindings and asynchronous functions in Python which I am assuming you need for the above problem. A fill-in solution is just to employ busy waiting in a loop until the is data to retrieve in the thread. That being said I will find a better solution in the future and post if I find one...any other help would be much appreciated!

integracore2 commented 3 years ago

@elvinex - could you kindly address the issues raised in this thread please? Many thanks!

integracore2 commented 3 years ago

Hi @quant-diaries @ganevniko - thank you for your interest and raising these queries, much appreciated!

Could you please confirm the following:

1) Broker Terminal you're using (the dwx-zeromq-connector was built for Darwinex clients, and has hence only ever been tested on Darwinex MetaTrader terminals)

2) If you're running via script or IPython/Jupyter Notebook? -> dwx-zeromq-connector relies on multi-threading and was not developed for use in Notebooks.

@elvinex - Kindly debug when you can and patch as necessary - thanks!

elvinex commented 3 years ago

Hi, to be honest I don't have a better idea than just sleeping until the data is received. We don't know when MT4 will send data and we also don't know how many messages to expect (tick data could come any time). The available examples also use sleep to keep the main thread running: https://github.com/darwinex/dwx-zeromq-connector/blob/master/v2.0.1/python/examples/template/strategies/prices_subscriptions.py https://github.com/darwinex/dwx-zeromq-connector/blob/master/v2.0.1/python/examples/template/strategies/coin_flip_traders_v1.0.py

ghost commented 3 years ago

Thank you for the updates @integracore2 and @elvinex . Had my college examinations so I could not get back to you promptly, apologies for the late reply.

I am indeed using the Darwinex MT4 terminal, and was running the script via terminal (non-interactive shell). I see there is currently an experimental code with regards to listening to the socket, but the sleep version is fine for now. Thank you for looking into the matter!