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

_DWX_MTX_SUBSCRIBE_MARKETDATA_ not subscribing to new symbols #92

Closed PierrePivert closed 3 years ago

PierrePivert commented 3 years ago

Hi,

Using the files available in this repo as it is, it seems that the functionality to check the _PublishMarketData to True in MT4 has been disable. Also, the list _PublishSymbols is empty. Looking at the MQL code, I noticed that it is now possible to subscribe directly from the Python code (via the function DWX_SetSymbolList).

The function to subscribe to data from Python is _DWX_MTX_SUBSCRIBEMARKETDATA It works great for getting to the datafeed via the appropriate port, however the function is not calling DWX_SetSymbolList, and not subscribing to any new symbol.

I added the remote_send command to add the new symbol. It may be usefull to get a local variable of subscribed symbols in the DWX_ZeroMQ_Connector class, because from what I see, adding a new symbol override all previous ones.

"""
Function to subscribe to given Symbol's BID/ASK feed from MetaTrader
"""
def _DWX_MTX_SUBSCRIBE_MARKETDATA_(self, 
                                   _symbol='EURUSD', 
                                   string_delimiter=';'):

    # Send via PUSH Socket
    _msg = "{};{}".format('TRACK_PRICES', _symbol)
    self.remote_send(self._PUSH_SOCKET, _msg)

    # Subscribe to SYMBOL first.
    self._SUB_SOCKET.setsockopt_string(zmq.SUBSCRIBE, _symbol)

    print("[KERNEL] Subscribed to {} BID/ASK updates. See self._Market_Data_DB.".format(_symbol))
PierrePivert commented 3 years ago

No need to reinvent the wheel, there is the _DWX_MTX_SEND_TRACKPRICESREQUEST.