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

how to 100% get the situation of open orders #112

Closed ZixiSu closed 2 years ago

ZixiSu commented 3 years ago

There is a function in DWX_ZeroMQ_Connector_v2_0_1_RC8.py

    # GET OPEN TRADES
    def _DWX_MTX_GET_ALL_OPEN_TRADES_(self):

        try:
            self.temp_order_dict['_action'] = 'GET_OPEN_TRADES'

            # Execute
            self._DWX_MTX_SEND_COMMAND_(**self.temp_order_dict)

        except KeyError:
            pass

How can I 100% sure that I can get open orders, as sometimes I do have open orders but the return is Nonetype

elvinex commented 3 years ago

Hi, The return value of this function should always be None since the function only sends the command and does not return anything. If you want to act on data coming from MT4 after a request, the best way is probably to define an own pull data handler. The handler would have an own onPullData function where you can parse any incoming data. It should then be passed to the DWX_ZeroMQ_Connector through the _pulldata_handlers variable.

Here is an example which just prints the data in the onPullData function.