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
344 stars 228 forks source link

Market Data Subscription: command does not reach MT4 Server, Order does #9

Closed aquaandi closed 5 years ago

aquaandi commented 5 years ago

I'm on Windows 10, connecting via _zmq = DWX_ZeroMQ_Connector(_verbose=True) _zmq._DWX_MTX_SUBSCRIBEMARKETDATA(_symbol='EURUSD')

then waiting via a timer in a thread for print(_zmq._Market_Data_DB) to update, but I get no data.

In the class and method DWX_ZeroMQ_Connector def _DWX_MTX_SUBSCRIBEMARKETDATA(self, _symbol, _string_delimiter=';'):

this code never gets called when I subscribe to market data: self._MarketData_Thread = Thread(target=self._DWX_ZMQ_Poll_Data, args=(_string_delimiter)) self._MarketData_Thread.start()

Also the MT4 server only receives messages (in void InterpretZmqMessage(...)) when I order (which it executes fine), but not when I subscribe to market data, or request all open trades.

I installed a couple different versions and libraries I thought were related, but weren't. So maybe it's .dlls?

hartungalex24 commented 5 years ago

I have the same problem.

I see MT4 server is publishing in experts terminal. But I am left with an empty dictionary on the python side. Also the: self._MarketData_Thread = Thread(target=self._DWX_ZMQ_Poll_Data, args=(_string_delimiter)) self._MarketData_Thread.start()

is not getting called.

integracore2 commented 5 years ago

I'm on Windows 10, connecting via _zmq = DWX_ZeroMQ_Connector(_verbose=True) _zmq._DWX_MTX_SUBSCRIBEMARKETDATA(_symbol='EURUSD')

then waiting via a timer in a thread for print(_zmq._Market_Data_DB) to update, but I get no data.

In the class and method DWX_ZeroMQ_Connector def _DWX_MTX_SUBSCRIBEMARKETDATA(self, _symbol, _string_delimiter=';'):

this code never gets called when I subscribe to market data: self._MarketData_Thread = Thread(target=self._DWX_ZMQ_Poll_Data, args=(_string_delimiter)) self._MarketData_Thread.start()

Also the MT4 server only receives messages (in void InterpretZmqMessage(...)) when I order (which it executes fine), but not when I subscribe to market data, or request all open trades.

I installed a couple different versions and libraries I thought were related, but weren't. So maybe it's .dlls?

Hi @aquaandi ,

1) Could you confirm that the EA is configured to publish market data? -> Publish_MarketData = True in Inputs?

2) As shown in the code you've pasted, the function _DWX_MTX_SUBSCRIBEMARKETDATA only calls the Thread creation code, if self._MarketData_Thread is None at the present time.

This thread is already initialized by the init() function when you create an instance of DWX_ZeroMQ_Connector, so you don't have to create it again, nor will the code.

3) The instructions exactly as detailed in README.md should get your environment working, therefore please only install the libraries stated in the README.

We recommend that users install the Anaconda distribution that ships with everything you need to simply download the Python script and get up and running.

4) Could you also kindly run the following test and report back with results?

Test - While the EA is deployed on the chart and you see "Sending.. to PUB port" messages in your Experts tab, execute the following code:

_zmq = DWX_ZeroMQ_Connector(_verbose=True)
_zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD')

Then, open a command prompt in Windows 10, and type:

netstat -ano | grep 327

This should capture all output where ports 32768, 32769 and 32770 are shown. Please copy and paste that output here so we can debug further, thanks!

integracore2 commented 5 years ago

I have the same problem.

I see MT4 server is publishing in experts terminal. But I am left with an empty dictionary on the python side. Also the: self._MarketData_Thread = Thread(target=self._DWX_ZMQ_Poll_Data, args=(_string_delimiter)) self._MarketData_Thread.start()

is not getting called.

Hi @hartungalex24 ,

Please see https://github.com/darwinex/dwx-zeromq-connector/issues/9#issuecomment-492965260 as it relates to your query.

integracore2 commented 5 years ago

Also @aquaandi and @hartungalex24 ,

Thank you so much for your feedback here 😃

Every issue / bug / report helps us help you, and that helps everyone else who reads these too!

We are going to be recording a Video Tutorial soon on common issues and fixes that we've compiled from GitHub Issues - so stay tuned!

integracore2 commented 5 years ago

Further to the last message here, we've updated the MQL Expert Advisor to fix a small bug in the quote publishing functionality.

Kindly update your forks accordingly - thanks!

hartungalex24 commented 5 years ago

@integracore2 Thank you so much for your reply. I have pulled the new source code for MQL4 EA and have made the modifications to the setup and call of the constructor as you mentioned. Please see my netstat report below:

image

Still not receiving any data on the python side. Seems as though I am not subscribed to the publishing port of 32770

image

Running this script in Google Colab.

image

I re-ran the netstat report and for some reason it is no longer listening on the port. However, I am still publishing data from MT4 EA

image

aquaandi commented 5 years ago

Thank you for the reply, for me the updated MT4 EA works. I'm now getting live data in python. I did however also do a reboot, which might have loaded newer .dlls

I don't currently have grep installed, but can if that helps.

hartungalex24 commented 5 years ago

I got it working. After a restart on the machine and switching to PyCharm on an anaconda 3.7 ide I was able to get the ports properly setup and listening.

image

image

Thank you for all your help and for creating such an amazing tool!

unesssaeed commented 2 years ago

Thank you for the reply, for me the updated MT4 EA works. I'm now getting live data in python. I did however also do a reboot, which might have loaded newer .dlls

I don't currently have grep installed, but can if that helps.

hey dude I have the same problem may you share your solution?

unesssaeed commented 2 years ago

@hartungalex24 hi, may you share your solution cause my ports are on "stablished" yet