dwxconnect
dwxconnect copied to clipboard
how to handle orders message
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': ''}
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.