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
341 stars 227 forks source link

Trouble with retrieving subscriptions (Order requests are working but not subscriptions) #122

Closed projectcarthage closed 3 years ago

projectcarthage commented 3 years ago

I have sent buy and sell commands both had worked flawlessly. The issue is with the _zmq._DWX_MTX_SUBSCRIBEMARKETDATA() command. All requests return empty dictionaries. Am I missing something? Missing Data

moneyrolling commented 3 years ago

Hi, i am having similar problems too, not sure what is going on, looks like the author not actively support this development?

projectcarthage commented 3 years ago

I got it working by adding the requests I needed to the mt4 side of the code. In the youtube video tutorials I think it was not stated but in the github it was.

On Mon, Mar 15, 2021, 21:53 moneyrolling @.***> wrote:

Hi, i am having similar problems too, not sure what is going on, looks like the author not actively support this development?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/darwinex/dwx-zeromq-connector/issues/122#issuecomment-799437393, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATCD22KBAVFTCPIQHWTQ2NTTDYGNFANCNFSM4YQ2KE5Q .

moneyrolling commented 3 years ago

hi thanks for the reply, will you mind send me the example mt4 codes you added, thanks

elvinex commented 3 years ago

Hi,

I know it can be a bit confusing. But _DWX_MTX_SUBSCRIBE_MARKETDATA_() only tells zeromq that we want to subscribe to incoming data from the socket connection. However, we still have to tell MT4 to send the data. Therefore, you need to call both functions. The second one takes a list of symbols and tells MT4 to publish data for these symbols. For example, if you want to subscribe to tick data from EURUSD and GBPUSD, use the following:

_zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD')
_zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('GBPUSD')
_zmq._DWX_MTX_SEND_TRACKPRICES_REQUEST_(['EURUSD', 'GBPUSD'])

Then the _zmq._Market_Data_DB variable should contain the tick data for EURUSD and GPBUSD.

TshepoMK commented 3 years ago

Followed steps exactly as thread above and now I am getting another error. Is my internet slow or something?

Capture2

elvinex commented 3 years ago

The socket connection is local, so it should not depend on the internet (except the MT4 connection to the broker). In my experience a timeout can happen if you for example restart the MT4 EA multiple times and there is a problem in resetting the socket connection.

I would try restart everything (MT4 and maybe also the PC). Then first start the MT4 EA and afterwards try again from python.

TshepoMK commented 3 years ago

The socket connection is local, so it should not depend on the internet (except the MT4 connection to the broker). In my experience a timeout can happen if you for example restart the MT4 EA multiple times and there is a problem in resetting the socket connection.

I would try restart everything (MT4 and maybe also the PC). Then first start the MT4 EA and afterwards try again from python.

Thanks, that worked in resolving the time out error. Now I ma back to the first one where I get an empty dictionary for market data.

elvinex commented 3 years ago

So the MT4 EA is active with default settings and you executed both and afterwards have an empty dict? _zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD') _zmq._DWX_MTX_SEND_TRACKPRICES_REQUEST_(['EURUSD']) What is the response message from MT4? Also, what is the MT4 log showing?

TshepoMK commented 3 years ago

So the MT4 EA is active with default settings and you executed both and afterwards have an empty dict? _zmq._DWX_MTX_SUBSCRIBE_MARKETDATA_('EURUSD') _zmq._DWX_MTX_SEND_TRACKPRICES_REQUEST_(['EURUSD']) What is the response message from MT4? Also, what is the MT4 log showing?

Capture3

elvinex commented 3 years ago

The second function takes a list of symbols, so that you can set all symbols you want at the same time (or remove some by omitting them). It must be (['EURUSD']) not ('EURUSD').

TshepoMK commented 3 years ago

The second function takes a list of symbols, so that you can set all symbols you want at the same time (or remove some by omitting them). It must be (['EURUSD']) not ('EURUSD').

Thank you @elvinex . Tbh I was about to give up.

Capture4

elvinex commented 3 years ago

Great to hear that it is working. :)