Sample python code to place_gtt order

srikanthg
I want to make use of kite.place_gtt function to create stoploss. I could not understand the documentation. Please give me a sample program. Thanks in advance.
  • NarayanRao
    this is from Nov and still no reply.. Couldnt find this even in other forums
  • rakeshr
    ORDER= [
    {
    "exchange":"NFO",
    "tradingsymbol": "NIFTY20OCTFUT",
    "transaction_type": kite.TRANSACTION_TYPE_SELL,
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "NRML",
    "price": 11450
    },
    {
    "exchange":"NFO",
    "tradingsymbol": "NIFTY20OCTFUT",
    "transaction_type": kite.TRANSACTION_TYPE_SELL,
    "quantity": 1,
    "order_type": "LIMIT",
    "product": "NRML",
    "price": 12000
    }]
    trigger_id = kite.place_gtt(trigger_type=kite.GTT_TYPE_OCO, tradingsymbol='NIFTY20OCTFUT', exchange='NFO', trigger_values=[11450,12000], last_price=11894,orders=ORDER)
    You can refer above sample example.
  • ronstrader
    Shouldn't the first order type be 'STOPLOSS' (SL)?
  • SRIJAN
    @ronstrader the first order is sl. This gtt is for selling. Means after you buy it,to squareoff. So ,the first order is sl. And second one is target. When one of the two is triggered,the other one is cancelled.
  • doomingbulls
    Hi @rakeshr
    Here is my code for gtt oco order

    def placeGTT(symbol,quantity,sl_price, target, ltp,buy_sell):


    t_type=kite.TRANSACTION_TYPE_SELL

    if buy_sell == "buy":
    t_type=kite.TRANSACTION_TYPE_BUY

    elif buy_sell == "sell":
    t_type=kite.TRANSACTION_TYPE_SELL

    order_dict = [{"transaction_type": t_type, "quantity": quantity,
    'order_type': kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_MIS , "price": sl_price},
    {"transaction_type": t_type, "quantity": quantity,
    'order_type': kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_MIS , "price": target}
    ]
    kite.place_gtt(kite.GTT_TYPE_OCO, symbol, kite.EXCHANGE_NSE, [sl_price, target], ltp, order_dict)



    The problem is when gtt for target is triggering it showing error that insufficiennt holding and you are taking a CNC order but as you can see in the code I am placing MIS order for both Stoploss and target. Please help it is urgent.
  • sujith
    MIS for equity is not allowed for GTTs. You can only use CNC product.
Sign In or Register to comment.