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
346 stars 228 forks source link

Issues receiving MetaTrader responses when executing code from a script #134

Closed matkiller333 closed 2 years ago

matkiller333 commented 3 years ago

Hello everyone, So here is my problem, I am working on a web scraper to perform trades depending on information gathered on the internet. However, when I try executing requests inside a python script, such as _zmq.DWX_MTX_GET_ALL_OPEN_TRADES() I get no answers from the server and cannot retrieve any information under _zmq._Market_Data_DB or _zmq._History_DB.

Moreover, if I try to open an order with zmq.DWX_MTX_NEW_TRADE(order) I get the Resource timeout.. please try again. error. (MS VC++ is downloaded and up to date; verbose = True)

If using a python shell, however, I can pass orders that are received by MetaTrader4 and I am getting the expected output from other functions.

Therefore, this is leading me to believe that maybe there is a problem receiving responses from MetaTrader4 when using a script instead of a shell command. Any idea on how to fix this would be really appreciated. Thank you.

Running python 3.9 on Windows 10, Using MetaTrader4 and coding in PyCharm

TheSnowGuru commented 2 years ago

try pytrader :) works better

elvinex commented 2 years ago

Hi, If you execute a script the next command will be executed immediately, but MT4 needs a bit of time for the reply to arrive. Therefore, it works in a python shell. Try to add a sleep function to wait for a response.

Btw. we published the DWX Connect package which is probably better suited for most of the use cases.