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

_get_response_ works intermittently #55

Closed eosfomogame closed 3 years ago

eosfomogame commented 4 years ago

A piece of my python code:

ordine = {'_action': 'OPEN',
         '_type': 1,
         '_symbol': 'EURUSD',
         '_price':0.0,
         '_SL': 100,                     # 10 pips
         '_TP': 100,                     # 10 pips
         '_comment': 'EURUSD_Trader',
         '_lots': 0.01,
         '_magic': 123456}

a = DWX_ZMQ_Execution(_zmq)
a._execute_(ordine, _verbose=False)
sleep(5)
print("---------------")
a._execute_(ordine, _verbose=False)
sleep(5)
print("---------------")
a._execute_(ordine, _verbose=False)
sleep(5)
print("---------------")
a._execute_(ordine, _verbose=False)

Output:

{'_action': 'EXECUTION', '_magic': 123456, '_ticket': 229172741, '_open_time': '2019.11.18 23:29:40', '_open_price': 1.10721, '_sl': 1.10821, '_tp': 1.10621}
---------------
break
---------------
{'_action': 'EXECUTION', '_magic': 123456, '_ticket': 229172743, '_open_time': '2019.11.18 23:29:51', '_open_price': 1.10722, '_sl': 1.10822, '_tp': 1.10622}
---------------
break

print("break") is added by me in while loop before the real break here https://github.com/darwinex/dwx-zeromq-connector/blob/master/v2.0.1/python/examples/template/modules/DWX_ZMQ_Execution.py

Mt4 executes all the orders, but get_response works intermittently, once yes and once not. What could be the problem?

EpicCodeVoyager commented 4 years ago

Yes, would like to add something to the same issue: I tried to capture the stdout of the response function, it always returns the value to stdout correctly. for eg. _zmq._DWX_MTX_NEW_TRADE_(_order) the about code works perfectly fine and it always returns the response almost real time.

However when tried to get order from template provided it's giving correct response alternatively. once none and once response is correct. the real issue here is to get the response from stdout and store it in the python variable. These zmq calls are non-blocking so most probably that's why I'm unable to capture stdout as well.

Tried to look into the mq4 code as well, it looks fine. I'm unable to figure out why this is happening. Probably need better understanding of how this whole thing connects and responds.

Can you please suggest any specific direction I should explore into?

@integracore2 @eosfomogame

EpicCodeVoyager commented 4 years ago

update:

from DWX_ZMQ_Execution import DWX_ZMQ_Execution
dze = DWX_ZMQ_Execution(_zmq)

while True:
    out = dze._execute_(order_dict, True, .5, 10)
    print("out is : " + str(out))
    sleep(2)

this code snippet worked after restarting the IDE. I'm not sure why. I'll be updating the progress and report consistency of output here.

elvinex commented 3 years ago

Hi, To clean up the issues, we decided to close issues with general questions that have been inactive for a long while.