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

Save output to a Python variable instead of printing on screen #23

Closed quantnlp closed 5 years ago

quantnlp commented 5 years ago

Hi,

I was trying to record all open trades called by trades = _zmq._DWX_MTX_GET_ALL_OPEN_TRADES_()

However, the variable "trades" is a NoneType. Is there any way that I can store the output from the connector to a Python variable so that I can write it to csv, instead of printing on screen?

Thanks, Frank

integracore2 commented 5 years ago

Hi @quantnlp ,

Thank you for your query.

If you review the code, you'll notice that any of the DWX functions in the script store outputs in a variable called self._thread_data_output, i.e. a call to the function does not "return" anything.

To access the output after a call to the functions, you can either directly access self._thread_data_output, or use the getter/setter functions self._getresponse() and self._setresponse() depending on your particular usecase.

Hope this helps!