GTT order place example

mamoni000
Hi, lets say I am trying to buy a banknifty option script above 400 whose current value is 350, so I am using SL order to buy once trigger price touches 400. Code for that is:
order_id = kite.place_order(tradingsymbol='BANKNIFTY22OCT41300PE', variety='regular', exchange='NFO', transaction_type='BUY',
quantity=25, order_type='SL', trigger_price=400, price=400, product='MIS')

Now once once I place the order it will be pending(as it is an SL order) and it will be complete once price goes above 400, once order is complete then I want to place GTT order, one for stoploss say @360 and one for target say @440.
Please provide me an example how I can write the code for it.
  • mamoni000
    mamoni000 edited October 2022
    placing gtt is fine, how to know from the status that my SL order is completed i.e. it is executed, I want the code for that, once my SL order is executed then only I want to place gtt
  • sujith
    sujith edited October 2022
    You will have to listen to order updates via Websockets API and use that as an event to fetch orderbook and in the orderbook response you will get the latest status of your SL order, if it is COMPLETED then it means your order is filled completely.
  • mamoni000
    thanks for the info, I will try that
  • mamoni000
    mamoni000 edited October 2022
    One more question, in webUI for OCO-GTT, I can see both trigger price and price(actual buy/sell price once trigger price executed), can you please tell me which one is buy/sell price in below example for API:

    order_oco = [{
    "exchange":"NSE",
    "tradingsymbol": "SBIN",
    "transaction_type": kite.TRANSACTION_TYPE_SELL,
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "CNC",
    "price": 470
    },{
    "exchange":"NSE",
    "tradingsymbol": "SBIN",
    "transaction_type": kite.TRANSACTION_TYPE_SELL,
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "CNC",
    "price": 480
    }]
    gtt_oco = kite.place_gtt(trigger_type=kite.GTT_TYPE_OCO, tradingsymbol="SBIN", exchange="NSE", trigger_values=[470,480], last_price=473, orders=order_oco)

    Here I can understand trigger values are trigger_values=[470,480], but after trigger price executed what is the actual sell price? is it denoted with "price": 470 and "price": 480 inside order_oco ?
    actually I want to keep 1 or 2 rs buffer so want to know which field to change
  • sujith
    You need to check based on last price, to decide which one is target and stop-loss.
  • mamoni000
    No, I think I am not able to explain it properly,
    In above example in OCO-GTT for SL trigger price should be 470 but once trigger of 470 touches I want to sell the script @468 that is 2 points of buffer I want to put, in webUI there is option to put trigger price as well as price.
  • rakeshr
    You need to use price field in the order array.
  • mamoni000
    thanks @rakeshr , I will try
This discussion has been closed.