SquareOff existing order at MARKET


From GUI we have option to select an MIS order and simple exit. it will execute MARKET order.

There seems to be no way to do that using api.

I noted that exit_order is only for BO/CO orders and there is no other api which reference existing order_id to execute command.

when i tried to execute a counter MARKET BUY order for exactly same quantity/scrip for already opened position, order got rejected a margin insufficient. This kind of check is not done when we exit from GUI.

Why api checks for margin when its counter order to close position?
How can we emualte GUI exit option using api?

  • sujith
    sujith edited September 2019
    Hi @npchoubey,
    Kite web and mobile does the same. It places the same quantity market order with the same product. You must have missed the product type which results in system perceiving you are going to short with the new order.
  • npchoubey
    thanks for response
    this is how coded to squareoff short position . anything else I need to add here?

    kite.place_order(variety="regular", tradingsymbol=buy_ce,
    quantity=buy_ce_q, exchange="NFO",
    order_type="MARKET", transaction_type="BUY",
  • sujith
    Is this option instrument or future instrument?
  • sujith
    Are you trying to close short position?
  • npchoubey
    npchoubey edited September 2019
    yes, trying to close short position

  • sujith
    Can you try today and post the order id today? This looks fine. We need more details to look into this.
  • npchoubey
    is it ok, if i give earlier order id ?
  • sujith
    Order history is wiped off everyday. So, we require a current day order id.
  • hitman1980
    There may be 2 reasons ..

    Either u have already placed the limit buy order for tht option and it was pending in order history ..

    Second .. zerodha was not allowing to square off the options at market yesterday and today .. They were asking me to set the limit order for tht .. So tht may be the issue ..
  • Amit Ghosh
    I have solved it using -

    Read all open orders.
    Cancel all of them. (Target the BO,CO,OCO exceptions here).

    Read all the current open positions.
    Shoot reverse positions.

    I call it powerkill lol. Its apt as I mostly use in BankNIFTY.
  • sujith
    We don't allow market orders for Stock options. You will have to place a limit order at LTP. This has been the RMS policy for a very long time.
Sign In or Register to comment.