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

[SOLVED] Connecting from Python to MT4 server using ZeroMQ (Solution: initialize with _verbose=True) #2

Closed LungstaTheProgrammer closed 5 years ago

LungstaTheProgrammer commented 5 years ago

@Darwinex OK I will reply here and on youtube. I used the version of dwx_zermq_connector that you sent me and it didn't help. There are no logs on the MetaTrader side, everything is working as demonstrated in the github page. But there is no connection from the python side:

Python 3.6.7 |Anaconda, Inc.| (default, Dec 10 2018, 20:35:02) [MSC v.1915 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information.

from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector() File "", line 1 from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector() ^ SyntaxError: invalid syntax from DWX_ZeroMQ_Connector_v2_0_1_RC8 import DWX_ZeroMQ_Connector _zmq = DWX_ZeroMQ_Connector() [INIT] Ready to send commands to METATRADER (PUSH): 32768 [INIT] Listening for responses from METATRADER (PULL): 32769 _zmq._generate_default_order_dict() {'_action': 'OPEN', '_type': 0, '_symbol': 'EURUSD', '_price': 0.0, '_SL': 500, '_TP': 500, '_comment': 'DWX_Python_to_MT', '_lots': 0.01, '_magic': 123456, '_ticket': 0} _zmq._DWX_MTX_GET_ALL_OPENTRADES() print(_zmq._DWX_MTX_GET_ALL_OPENTRADES()) None

_zmq._DWX_MTX_GET_ALL_OPENTRADES()

As you can see it fails to check open positions. And I have a trade open, besides its supposed to return the json you received when you had no open positions. I did on spyder too and the result is no different. Thanks for your help.

integracore2 commented 5 years ago

Hi @LungstaTheProgrammer ,

To see JSON output on the console, you need to initialize _verbose to True when creating an instance of DWX_ZeroMQ_Connector.

Could you confirm you've set _verbose=True and are still unable to see JSON output?

LungstaTheProgrammer commented 5 years ago

It works!!!!!!!!! Thank you so much!!!!!!! That was all I needed to do

integracore2 commented 5 years ago

@LungstaTheProgrammer - No worries, you're always welcome :)