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

Multiple clients #124

Closed T-o-b closed 2 years ago

T-o-b commented 3 years ago

Hello,

thank you for the great module. I managed to get it working so that I can open orders and get information of open orders. The response is also sent by the MQL-EA. I have a problem getting the response in the variable "_thread_data_output". The issue is that I do open multiple objects of the class "ZeroMQ_Connector" (_zqm). When executing the example down below with an open order I can see when verbose=true that python gets the response by MQL-EA but becuase some threads are open it seems not to get it in the variable. So the first execution is ok and when executing the second time the error occurs.

import sys sys.path.append('.') import time

import _pickle as pickle import os

import DWX_ZeroMQ_Connector_v2_0_1_RC8 as ZeroMQ_Connector

_zmq = ZeroMQ_Connector.DWX_ZeroMQ_Connector(_ClientID='dwx-zeromq')

_zmq._DWX_MTX_GET_ALL_OPENTRADES() time.sleep(0.1) print(id(_zmq)) print(_zmq._getresponse())

The output in the console looks as followed: grafik

What one can see above is that there are two different object-id's (1179306034824 from the print of object in verbose=true in the ZeroMQ_Connector-File and 1179341171848 of the _zmq-object [print(id(_zmq))] from the sample above. So it seems that thread/object 1179306034824 gets the response from EA and prints it and empties the queue. When the current object (1179306034824) wants to write the response in the variable the queue is empty. Is there any way to deal with that issue.

Thank you in advance and kind regards Tobias

elvinex commented 3 years ago

Hi, sorry, I can't replicate this issue. It works for me if I use a similar code. I am also not sure how your output is generated. What do you mean with "print of object in verbose=true"? I don't see any object ID printed in the original file even with _verbose=True: https://github.com/darwinex/dwx-zeromq-connector/blob/master/v2.0.1/python/api/DWX_ZeroMQ_Connector_v2_0_1_RC8.py