on_order_update callbacks for orderid not in sequence

anandmuralidhar
Hi,

The callbacks in websockets are not coming in sequence and I'm regularly receiving COMPLETE and OPEN callbacks before UPDATE callbacks. This messed up my algo since I was updating the latest orderid status in redis. My code assumed that orderid was yet to COMPLETE and kept waiting for ever till I manually fixed it. Now I cannot use callbacks and am forced to make a network call and check positions or order history for current status.
Please document such drawbacks of the API so that people can take it into account while designing their systems.

Here's an example where I received callbacks for a orderID in the sequence COMPLETE->OPEN->UPDATE:
{'account_id': 'xx',
'unfilled_quantity': 0,
..
'order_id': '210607002557637',
'exchange_order_id': '1000000015031293',
'parent_order_id': None,
'status': 'COMPLETE',
..
'order_timestamp': '2021-06-07 11:25:02',
'exchange_update_timestamp': '2021-06-07 11:25:02',
'exchange_timestamp': '2021-06-07 11:25:02',
'variety': 'regular',
'exchange': 'NFO',
'tradingsymbol': 'NIFTY2161015700PE',
'instrument_token': 12236290,
'order_type': 'MARKET',
'transaction_type': 'BUY',
'validity': 'DAY',
'product': 'NRML',
'quantity': 375,
'disclosed_quantity': 0,
'price': 0,
'trigger_price': 0,
'average_price': 69.43,
'filled_quantity': 375,
'pending_quantity': 0,
'cancelled_quantity': 0,
'market_protection': 0,
'meta': {},
'tag': None,
'guid': '32499XFDjRiKXV1wvY'},
{...
'order_id': '210607002557637',
'exchange_order_id': '1000000015031293',
'parent_order_id': None,
'status': 'OPEN',
'order_timestamp': '2021-06-07 11:25:02',
'exchange_update_timestamp': '2021-06-07 11:25:02',
'exchange_timestamp': '2021-06-07 11:25:02',
...
'filled_quantity': 0,
'pending_quantity': 375,
...},
{
...
'order_id': '210607002557637',
'exchange_order_id': '1000000015031293',
'parent_order_id': None,
'status': 'UPDATE',
'status_message': None,
'status_message_raw': None,
'order_timestamp': '2021-06-07 11:25:02',
'exchange_update_timestamp': '2021-06-07 11:25:02',
'exchange_timestamp': '2021-06-07 11:25:02',
...
'filled_quantity': 150,
'pending_quantity': 225,
...
}
,

best,
Anand
Tagged:
  • rakeshr
    You can go through this thread.
  • anandmuralidhar
    anandmuralidhar edited June 2021
    Thanks @rakeshr for pointing out the appropriate thread. Since this is a major issue for anyone using this callback, I'm surprised that it was not explicitly highlighted in the documentation.
    I feel that you should have a better mechanism of mentioning all these issues in the documentation so that we don't have to discover them during live trades.
    Please close this thread.
  • rakeshr
    These are already added under the FAQs section.
This discussion has been closed.