Best way to handle manual exits from zerodha dashboard/positions

nkotwar
nkotwar edited March 2022 in Python client
I placed NRML order using kiteconnect api (python client). I know that a market order must be placed with the same quantity and opposite transaction type in order to close the position using api.
But when I exit a position manually using zerodha's dashboard/position, I don't receive any feedback neither on my postback_url nor @ on_order_update(ws, data) in my ticker, about position being closed,
which is understandable, since I'm not placing exit order using api.

My query is, how will my script know that I've manually closed a position from Zerodha Dashboard/positions? Is there any way to get instant postback for exit orders placed via dashboard?

Surely there must be a better way than checking whether 'day_buy_quantity' and 'day_sell_quantity' in positions api are different, every few seconds.

@SRIJAN @rakeshr
Any hints are appreciated.
Tagged:
  • SRIJAN
    You will get a message on websocket about the trade . Use this as an event to fetch positions and check .
  • nkotwar
    You will get a message on websocket about the trade
    Can you elaborate this a little. What do you mean by 'message about the trade'?
    As on_message is a raw callback for data. Kite Connect already does all the processing and gives me back data on on_ticks callback.
    Are you referring to the data received on every tick with mode 'quote', and use 'buy quantity', 'sell quantity' in each tick to determine if I'm still in position?

    I'm confused between on_message and on_ticks
    - `on_message(ws, payload, is_binary)` -  Triggered when message is received from the server.
    - `payload` - Raw response from the server (either text or binary).
    - `is_binary` - Bool to check if response is binary type.
    what i understand is, if we receive binary payload, then it's a usual tick and if it's not binary, then if parsed_text_message's payload will have a 'type': 'order' then I should use this as an event to check my position. Is this correct?

    Also, do I need to assign callback with kws object like:
    kws = kiteTickerInstance(acc_token)
    .....
    kws.on_message= on_message
    @sujith
  • SRIJAN
    SRIJAN edited March 2022
    I was talking about on_order_update. Message through on_order_update. Yes ,you need to assign callbacks like :

    kws.on_order_update=on_order_update
  • nkotwar
    ah!
    Thanks, i hadn't assigned any callback to on_order_update.
    Should work now.
This discussion has been closed.