Hi, I'm into option trading and i'm able to place orders but unable to set target price for the orders as we can in app.
my place_order code is - order_id = kite.place_order(tradingsymbol=order.derivative_name,\ price=dltp[d_quote]['last_price'],variety=kite.VARIETY_REGULAR,\ exchange=kite.EXCHANGE_NFO,transaction_type=kite.TRANSACTION_TYPE_BUY,\ quantity=quantity,squareoff=squareoff,order_type=kite.ORDER_TYPE_MARKET,\ product=kite.PRODUCT_NRML)
See I'm calculating squareoff and adding it there but nothing happen in orders i place, it's placing normal orders without any target price then i need to manually go and add a sell order for the same.
If this can be achieved by gtt orders can u please share example code of gtt order like one i shared above please don't share documentation link the documentation is not good and without any example.
for gtt -> buy price is 100, target price is 100.25 and no stop loss
please share the place_gtt example for above condition if the squareoff thing can't be achieved by the place_order.
And placing 2 order that is buy and sell is not an option, i need the option that is shared in that image and present in the app.
The feature you want is not in the api for now. You have to buy the option and then place a sell order. Or you can just automate it to place a sell order with your required target as soon as your buy order is completed. And the squareoff,trailing stoploss fields are not applicable now,they were only for bo which are invalid now.
okay, i did that sell thing as soon as the buy order is placed with the squareoff price but what happening is it's not taking it from my holdings its trying to sell from my account and says insufficient funds. Example - I bought nifty 17400 ce of 50 qty at 205 and added a sell as soon as the buy completed for price 205.25 but the order gets rejected saying insufficient funds instead of taking my holdings into account.
So after buy order i'm placing sell order with a squareoff but it's not selling the option i bought, instead it's selling from my fund which will not be their as i have purchased from it. So my sell order is getting cancel.
Is there a way to sell the option(derivative of NIFTY) that i've bought, any way anything like i need to add order id or something?
Look at the time of your orders. The sell order was placed at 33:13, before the buy order was completed at 33:32. That's why it gave margin not sufficient error. If you are placing limit orders,then you have to modify your code to check if the order has been completed,and then only place sell order. Or,you can place market orders if you want.
Here what i tried -
order_id = kite.place_order(tradingsymbol=order.derivative_name,\
price=lastprice,variety=kite.VARIETY_REGULAR,\
exchange=kite.EXCHANGE_NFO,transaction_type=kite.TRANSACTION_TYPE_BUY,\
quantity=quantity,order_type=kite.ORDER_TYPE_LIMIT,\
product=kite.PRODUCT_NRML)
sleep(1)
order_id_s = kite.place_order(tradingsymbol=order.derivative_name,\
price=squareoff,variety=kite.VARIETY_REGULAR,\
exchange=kite.EXCHANGE_NFO,transaction_type=kite.TRANSACTION_TYPE_SELL,\
quantity=quantity,order_type=kite.ORDER_TYPE_LIMIT,\
product=kite.PRODUCT_NRML)
So after buy order i'm placing sell order with a squareoff but it's not selling the option i bought, instead it's selling from my fund which will not be their as i have purchased from it. So my sell order is getting cancel.
Is there a way to sell the option(derivative of NIFTY) that i've bought, any way anything like i need to add order id or something?