on_message callback not updating the order status sometimes

Rekha
Order postbacks are not updated sometimes and status keep showing 'OPEN' despite the order already executed. Because of this problem, new orders are not getting placed as per my logic which requires last order to be COMPLETE before new order can be placed.

This is the on_message callback:
    def on_message(ws, payload, is_binary):
global my_order_messages
if not is_binary:
parsed_msg = json.loads(payload)
if parsed_msg['type'] == 'order':
if parsed_msg['data']['status'] in ['OPEN', 'COMPLETE', 'CANCELLED', 'REJECTED']:
order_id = parsed_msg['data']['order_id']
my_order_messages[order_id] = parsed_msg['data']
I found text messages in postbacks are not as reliable as they are claimed or am I missing something?
  • sujith
    Postbacks are only sent to third party apps if order is initiated from the that app. If not then it won't be sent. However, websocket updates are sent for every order.
    An order can be in OPEN status, even if it is partially filled. That is how it works. I would suggest use Kite web or app to know these kind of behaviors before writing strategies.
  • rediffpankaj_libra
    rediffpankaj_libra edited October 11
    >>However, websocket updates are sent for every order.
    @sujith , you mean we should be receiving all order status updates in function "on_ticks" or any other callback function?
  • sujith
    You need to set callback on_order_update. You can check out pykiteconnect documentation here for ticker.
  • rediffpankaj_libra
    Thanks Sujith. What is the other feature that postback provides over "on_order_update"?
  • sujith
    Both have same data but on_order_update will be exclusively for end user because websocket connection is owned by the user but postbacks is more suitable for the platforms that offer service to clients. Postback can be used by individual users also but order has to be placed from the same Kite Connect app.
  • rediffpankaj_libra
    Understood. Thanks for the info Sujith.
This discussion has been closed.