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

How to enable data I/O with _DWX_MTX_SEND_MARKETDATA_REQUEST_ ? #43

Open Jim2002 opened 4 years ago

Jim2002 commented 4 years ago

Hi there, first of all, thanks for the great project, secondly I'm not sure if I am the only one having this issue or not but when I called _zmq._DWX_MTX_SEND_MARKETDATA_REQUEST_() , noting is return to the ipython console, but for some reason I cannot request the market data. . In mt4 however this is printed in the Experts tab 2019.09.23 22:54:53.640 DWX_ZeroMQ_Server_v2.0.1_RC8 EURUSD,M1: DATA;EURUSD;1;2019.01.04 17:00:00;2019.09.23 22:52:00 . I can open orders, close orders......etc . Subscribing only works if I change Publish_MarketData in the EA from false to true Please help. Cheers

Python version: 3.7.2 zmq version: 18.1.0 dwx-zeromq-connector version: 2.0.1 windows: 10

integracore2 commented 4 years ago

Hi @Jim2002 ,

Thank you for your kind feedback, glad to hear you're finding the project useful!

Yes, that's correct - the Server EA needs to be publishing market data before a client application can request it.

Data will not be returned if the EA input parameter Publish_MarketData == False.

To enable market data publication, this needs to be set to True in order for your application to subscribe to the data.

For further details and troubleshooting assistance, please watch the following video where we've outlined this and a few other common questions to help your user experience: https://www.youtube.com/watch?v=7aAsFZ_r5zU

Hope this proves useful!

Jim2002 commented 4 years ago

@integracore2 Publish_MarketData has been set to True however _zmq._DWX_MTX_SEND_MARKETDATA_REQUEST_() still didn't return anything.

integracore2 commented 4 years ago

Hi @Jim2002 ,

Could you please provide some sample function calls here to show how you're using the method?

Also, could you confirm that you can see MetaTrader publishing the data in your Experts tab in MetaTrader?

integracore2 commented 4 years ago

p.s. Please do make sure to watch this video as it may well have the solution to any debugging you're currently conducting: https://www.youtube.com/watch?v=7aAsFZ_r5zU

We do these tutorials to assist users given the limited support resources we have at the present time - thank you for your understanding :)

Jim2002 commented 4 years ago

@integracore2 Thanks for the reply, I have already watched the video.

I'm trying to request bar data using Python from mt4, I noticed the _DWX_MTX_SEND_MARKETDATA_REQUEST_() method where I can request Close price from one time to another so I decided to try the method but it turns out it doesn't return anything. I haven't write any function calls using this method yet, just want to make sure this method works.

The Experts tab is publishing 2019.09.23 23:42:18.876 DWX_ZeroMQ_Server_v2.0.1_RC8 EURUSD,M1: Sending EURUSD 1.098420;1.098460 to PUB Socket

Jim2002 commented 4 years ago

I found out when I start from more recent timestamp, the method works. eg: _zmq._DWX_MTX_SEND_MARKETDATA_REQUEST_(_start='2019.09.23 12:00:00',_timeframe=1) , this will return data length of 108 values, if I change the start time from 2019.09.23 12:00:00 to 2019.09.23 11:00:00 , the method no longer works.

chand2020 commented 4 years ago

Hey Jim2002,

      I am having same issue. Attached screenshot for your reference. Could you please let me know what am I doing wrong..

Thank you. Doc1.pdf

WildZes commented 4 years ago

My regards.

Also am appreciated for your ZeroMQ-connector. But still, having the same problem. Didn't found answer in video posted above. Please help, if it possible.

Hopefully, Pavel. _DWX_MTX_SEND_MARKETDATAREQUEST issue.docx

WildZes commented 4 years ago

My regards.

Also am appreciated for your ZeroMQ-connector. But still, having the same problem. Didn't found answer in video posted above. Please help, if it possible.

Hopefully, Pavel. _DWX_MTX_SEND_MARKETDATAREQUEST issue.docx

Don't know if it'll help to other fellows, but in my case worked subsequent command: _zmq._DWX_MTX_SEND_MARKETDATAREQUEST(_sybmol='EURUSD', _timeframe=30, _start="2020.2.26", _end="2020.2.29 10:00:00")

So, in my case, problem was with date entering. When I used '2020.2.29', or "D'2020.2.29'" format, it didn't work properly. Think, that it will work properly now.

Thanks again to Darwinex Team!

stefa22-cell commented 4 years ago

Hey, The _start and _end values in _DWX_MTX_SEND_MARKETDATAREQUEST are actually reversed (_start has to be newest bar I want to import and _end has to be the oldest. See https://docs.mql4.com/series/copyclose). I noticed there is a limit of 126 bars which could be imported. Does anyone know where this limit come from? I didn't find it in DWX_ZeroMQ_Server_v2.0.1_RC8.mq4. Alternatively, I noticed the _validresponse methods considers a response valid if it's either a dict or a dataframe, do you know if it's possible to construct a reply from DWX_ZeroMQ_Server_v2.0.1_RC8.mq4 which would be interpreted as dataframe in the connector?

A big thanks to Darwinex team!

BeeSee20Eye35 commented 4 years ago

Hi Many thanks for this project. It filled a long term need!

I have setup the bridge and can subscribe and unsubscribe to data, etc. However, I cannot retrieve data from DWX_MTX_SEND_MARKETDATA_REQUEST. I have watched all the video more than once but cannot work out what is wrong.

Before I describe the issue further, can I confirm that the data should be found in the _thread_data_output attribute? Assuming that this attribute is where I should find the data retrieved then I do have a problem. I have been able to use debug mode to follow the request into the mq4 script and can see the request arrive and trigger the copyclose call. The array then has several thousand prices and times. However, it seems to fail to send the zmq_ret message back to through the socket. Any ideas would be gratefully received.

System details : Windows 7 Professional with Service Pack 1 Intel(R) Core(TM) i7-7920HQ CPU @ 3.10GHz MetaTrader 4, Version 4, Build 1264 (11 May 2020) MetaEditor : Version 5.00 build 2375 (1 Mar 2020)

Many thanks

stefa22-cell commented 4 years ago

Hi,

It seems the zmq_ret has a length limit. It should work if you request a small number of times (i.e. below 100). I guess the easiest temporary solution would be to divide the huge block of thousand of prices in smaller blocks and ask them in series.

BeeSee20Eye35 commented 4 years ago

Hi Thanks very much for the suggestion. I've started testing it out and I am getting some data back so that is a huge improvement. Much appreciated. I assume from following the code that the length limit is on the data passed through the socket. I wonder if there are any plans for changing this in future. For now, as you say, I will adapt the python code to break any request into 100 bar calls. I will also add mq4 functionality to request the High, Low, Open prices and Volumes as well as the Close prices, unless someone has already done that?

Once again, thank you very much for the help.