How to place a option stop loss order along with the original buy order

sensexboy
Hi, apologies if its already been asked but i couldn't understand whats the best way to do this. I buy a option at limit price but then if the price decreases by 10% then it automatically sells the bought option ? I tried this but the below doesn't show up as the stop loss on the kite UI ?
kite.place_order(tradingsymbol=NIFTY22JUL16200CE,
exchange=kite.EXCHANGE_NFO,
transaction_type=TRANSACTION_TYPE_BUY,
quantity=quantity,
order_type=kite.ORDER_TYPE_LIMIT,
product=kite.PRODUCT_NRML,
variety=kite.VARIETY_REGULAR,
price = 0.1,
stoploss = 0.05)

Whats going wrong ?
  • SRIJAN
    SRIJAN edited July 15
    Please read the documentation properly.

    https://kite.trade/docs/connect/v3/orders/#regular-order-parameters

    ' price' parameter is the price to execute LIMIT orders at.

    So,your buy order will be executed as a separate order and not a stoploss order.

    And,squareoff and stoploss have been deprecated as this parameters were for Bracket Orders ,which have been discontinued.


    To place a stoploss order,you can place a separate stoploss order after taking position.

    If you want to place stoploss and target both at once,OCO GTT order is the best way.

    https://support.zerodha.com/category/trading-and-markets/kite-features/gtt/articles/how-can-i-use-the-gtt-feature
  • sensexboy
    Hi Srijan, sorry for not being clear in my earlier comment.
    I am able to place the order with the above paramters and also see the order in the order book. The minimum price that currently kite supports for my above example is 0.05 so the above works.

    Actually what I was asking was that why the stop loss field was not being reflected on the UI though when I add the same trade i have the option of putting a stop loss when i make the trade on the UI

    None the less, ur reply for placing a stoploss order/OCO GTT makes sense after taking position so that means i have to place the exit by virtue of these separate trades. Thanks

    So Also how does these separate exit orders know which position to exit given there might be multiple executed trades for the same option ?
  • SRIJAN
    SRIJAN edited July 15
    As I said,the stoploss field was for BO which has been discontinued. If you place a buy order with price at 0.1, it will be placed as a separate buy order.

    To place a stoploss order,you have to place a separate stoploss order with order_type as 'SL' with the 'price' as your stoploss price. Like ,if you buy an option at 100 ,your sl would be 90 ,and this is what you have to pass as 'price' in the order placement function.

    And you have to place a reverse transaction type order to square off a position.
    So,to exit buy positions,your transaction type should be 'SELL'.

    Also,even if you take multiple trades in the same strike ,all your trades will be grouped into one position.

    So,if you place an order to exit your position for 'x' quantity, 'x' quantity from your total quantity will be squared off.
  • sensexboy
    perfect, thanks a lot!
This discussion has been closed.