on_order_update update issue

ANL
ANL edited March 6 in Python client
Is it a good approach to put a small order update fetching code with dictionary lock logic inside the on_order_update function?
The kite team will not advise putting any logic code inside on_ticks because it will block the performance. so same advice for on_order_update?

on_order_update updates don't sync with internal order logic, so I put a separate thread for the new function and fetched data from the on_order_update, but again, sometimes it will perfectly sync with the order logic, but sometimes it will get stuck. I have made numerous attempts.

Any reason ? Order updates have any internal timeout issues or other problems.

While fetching the order updates, I got this error one time : Connection error: 1006 - connection was closed uncleanly (None)
WebSocket error. Code: 1006. Reason: connection was closed uncleanly (None)
Connection closed: 1006 - connection was closed uncleanly (None)
WebSocket connection closed: 1006 - connection was closed uncleanly (None)
  • ANL
    Furthermore, while placing the order, we get initially OPEN, then COMPLETE. That is a normal case as it shows the same order in Kite Web as well, but while fetching through on_order_updates, I get COMPLETE first, then OPEN.

    What is the reason? I have checked the detail logs as well.
  • sujith
    @ANL,
    You shouldn't block the on_order_update as well. You should fire routine in new thread and let that take care of the flow.
    You can know more about the on_order_update messages order here.
  • rakeshr
    The kite team will not advise putting any logic code inside on_ticks because it will block the performance. so same advice for on_order_update?
    Yes, it will block the flow. Callbacks in Python are called synchronously. So, make sure you transfer all such operations to the new thread.
    on_order_update updates don't sync with internal order logic
    Didn't get you? Were order updates not sent?
    while fetching through on_order_updates, I get COMPLETE first, then OPEN.
    Order update is an async call. This thread explains more.
  • ANL
    ANL edited March 7
    @rakeshr
    Furthermore, while placing the order, we get initially OPEN, then COMPLETE. That is a normal case as it shows the same order in Kite Web as well, but while fetching through on_order_updates, I get COMPLETE first, then OPEN.

    What is the reason? I have checked the detail logs as well.
    on_order_updates are out of order. It will not come out like first OPEN then COMPLETE Sometimes it will show COMPLETE update comes first then 'OPEN'

    For example, if I buy X stock at 100 with a limit order, it should show OPEN, but after it is executed, it shows 'COMPLETE'

    but sometimes I get the opposite: first get 'COMPLETE' then 'OPEN'

    How can this be resolved?
  • ANL
    You can close this thread. I developed the solution.
This discussion has been closed.