darwinex / dwxconnect

Seamlessly link any Trading Strategy in ANY programming language to Darwinex liquidity via MetaTrader 4 or 5. DWX Connect is your very own, fully customizable Trading API!
BSD 3-Clause "New" or "Revised" License
158 stars 84 forks source link

how to handle orders message #25

Closed hazzan3li closed 1 year ago

hazzan3li commented 1 year ago

how to handle messages of INFO or OPEN ORDER or REMOVE ORDER that is printed to python, I want to build a react algorithm every time an order is placed or removed etc...

New order: {'magic': 0, 'symbol': 'EURUSD', 'lots': 0.01, 'type': 'buy', 'open_price': 0.99455, 'open_time': '2022.09.01 17:57:12', 'SL': 0.0, 'TP': 0.0, 'pnl': -0.09, 'commission': 0.0, 'swap': 0.0, 'comment': ''}

Order removed: Order removed: {'magic': 0, 'symbol': 'EURUSD', 'lots': 0.01, 'type': 'buy', 'open_price': 0.99455, 'open_time': '2022.09.01 17:57:12', 'SL': 0.0, 'TP': 0.0, 'pnl': -0.09, 'commission': 0.0, 'swap': 0.0, 'comment': ''}

elvinex commented 1 year ago

Hi, If you really wanted to use the messages, you would have to modify dwx_client.py where ever it prints order information.

However, it would be better to just use the on_order_event in our example tick processor. You can check if the length of self.dwx.open_orders changed or loop through it and check for order changes.