on_order_update, order COMPLETE updates not being received

nkotwar
nkotwar edited March 2022 in Python client
Hello again @SRIJAN

kws = KiteTicker(api_key, access_token)
....
def on_order_update(ws, data):
logger.info(f"Ticker on_order_update data: {data}")
.....
kws.on_order_update = on_order_update
I am placing NRML order and buying 50 qty of some NIFTY CE.
I am getting order COMPLETE feedback on my postback_url
but i've never seen my on_order_update being hit, ever.
What could be the problem?

This would be a big hiccup when I close positions manually from Zerodha's Dashboard/Positions, I'll only know about them if on_order_update works as expected, since postback_url doesn't get hit if we don't place order from api as far as i know.
What could be the problem?

P.S. on_ticks etc are working fine

EDIT: just checked by manually closing a position, did not receive feedback on both postback_url and on_order_update
Tagged:
  • SRIJAN
    SRIJAN edited March 2022
    On_order_update is working fine for me. Idk why it isn't working for you. I just opened a position,closed it,got all updates instantaneously.
  • nkotwar
    I'm supposed to receive on_order_update when an order gets completed, right?
    regardless of how order was created.
  • SRIJAN
    Wait,did you connect to the websocket. kws.connect() ??
  • SRIJAN
    You receive update from websocket for every order status(OPEN,COMPLETE, CANCEL, REJECTED, UPDATE). Not just COMPLETE.
  • SRIJAN
    Also,you won't receive the first postback status of 'OPEN','COMPLETE','REJECTED' if order is placed from kite web/app interface. You will receive postback for subsequent order status.
    https://kite.trade/forum/discussion/comment/23960/#Comment_23960
  • nkotwar
    nkotwar edited March 2022
    Thanks for fast reply.
    Wait, did you connect to the websocket. kws.connect() ??
    Yes. I did. That's why I mentioned that ticks are working fine.
    Now I will..
    1. place order via api and exit via api
    2. place order via api and exit from web dashboard
    I'll see if on_order_update works, i restarted everything

  • nkotwar
    Hi @SRIJAN
    Everything seems to be working fine now, I had websocket connected in the morning with different id, forgot about that.

    Now
    If you can tell me a little about my following queries, that'd be great.
    1. best way to know if I have an open position for 'xyzabc' tradingsymbol
    2. if I exit a position partially (i.e. sell some part of quantity), how should I handle that
    About 2nd query, to my knowledge I'll still get order 'COMPLETE' status when partial exit order gets completed, so basically I should use on_order_update as an event to check if I have an open position for 'xyzabc' tradingsymbol, which is my 1st query

    If I should open another discussion for these, let me know, or you can refer me to another discussion if these have already been discussed somewhere.
  • SRIJAN
    SRIJAN edited March 2022
    1. https://kite.trade/docs/connect/v3/portfolio/#positions . Every position has a trading symbol key. Use if statements to check if the quantity fileld for any tradingsymbol is non-zero. An open position has non-zero quantity whereas closed positions have 0 as quantity.

    2. No,you won't get 'COMPLETE' for partial fill. If your order is partially filled,you will get 'UPDATE' status with the current filled quantity. Only after the order is fully filled ,you will get 'COMPLETE' status.

    On_order_update, postbacks should be used as events to fetch orderbook, positions etc. because sometimes they are asynchronous,so you might get confused,so it's always advised to use postback/on_order_update as events to fetch orderbook or positions to check the updated details of your orders/positions.
  • nkotwar
    Yes, that's what I've just implemented, Thanks SRIJAN.
Sign In or Register to comment.