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

Connector works but can't subscribe marketdata. #128

Closed lorenzo522 closed 3 years ago

lorenzo522 commented 3 years ago

Hi, I'm testing your connector but I have a problem subscribing to market data. I downloaded the last version of your files and I installed it correctly to mql4 and anaconda. I have a trade opened and the connector tell me that trade is currently running, I'm able to close it by launching _DWX_MTX_CLOSE_ALLTRADES also. When I try to subscribe to market data dict_keys is always empty. No message from python or MetaTrader. Is there a way to activate log or something similar? I have no idea where the problem could be. thank you ps. I watched your troubleshooting Python,Zeromq & metatrader configuration video but with no luck pushpull

Experts python Diary

lorenzo522 commented 3 years ago

Ok, I found where the problem is. (I think) in the MT server, there isn't how to handle the history request command. I had to add a new case in InterpretZmqMessage function, I created a new case on switch(action) ` case 9: // history REQUEST

     zmq_ret = "{";

     DWX_GetHistory(compArray, zmq_ret);

     InformPullClient(pSocket, zmq_ret + "}");

     break;        `

I noticed that DWX_GetData had almost what I needed so I replaced:

zmq_ret = zmq_ret + "'_action': 'DATA'"; with zmq_ret = zmq_ret + "'_action': 'HIST',"; zmq_ret = zmq_ret + "'_symbol': '"+compArray[1]+"'"; And know it works