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

Open Trades is incorrect #119

Closed nguyen-t-nhan closed 2 years ago

nguyen-t-nhan commented 3 years ago

When I try to get all open trades using the ._DWX_MTX_GET_ALL_OPEN_TRADES_() method I either receive nothing or a dictionary with no trades even though I know there should be some.

When I initialize the class I get this following which seems fine

[INIT] Ready to send commands to METATRADER (PUSH): 32768
[INIT] Listening for responses from METATRADER (PULL): 32769
[INIT] Listening for market data from METATRADER (SUB): 32770

When I start a new trade with _zmq._DWX_MTX_NEW_TRADE_(_zmq._generate_default_order_dict()) I get the response

{'_action': 'EXECUTION', '_magic': 123456, '_ticket': 848830983, '_open_time': '1612144860', '_open_price': 1.21231, '_response': 'ERROR_SETTING_SL_TP', '_response_value': 'unknown error'}

This trade shows up, but when I try to get all trades, it is empty.

elvinex commented 3 years ago

Hi, '_response': 'ERROR_SETTING_SL_TP' indicates that there was an error in setting the TP/SL. _generate_default_order_dict() uses: _symbol: EURUSD _SL: 500 _TP: 500

A possible issue could be if the symbol is not available (for example if there is a suffix in MT4). I also remember that the old version was inconsistent with regards to how it handled the SL/TP. The new version should always use points. Therefore, I would advice to download the newest version and try again.