It seems very poor support from zerodha. I am trying this since 2 months and not able to solve it. No one connecting directly and not supporting quickly on post also.
We don't provide any support or solution for writing strategies. There are documentation and examples for all the APIs and the client libraries. You can refer to the same.
@sujith Not asking for writing strategies. Need to have correct information to close position using gtt order api. As far as I checked all forum answers, it says we need to add opposite order. When I add it, and it triggers, it says insufficient fund. why it would required to have fund as my buy position for NFO is already there.
Neither I am not able to find on doc. Can you share doc link where it specifies that exiting option buy, we need to do this?
Are you using the same product type as the existing position? Can you private message the order id for which you have this issue, it is better if you have logs of current day. The order history gets erased after BOD.
It opens order or Zerodha and at limit price, it executes. Now I need to close/exit this position with GTT order by setting Stop Loss and Take Profit. I have used below code for that:
This is also creating GTT order but at execution time, it says insufficient fund. I am closing/exiting position with inverse order as sell of my existing buy with type as MIS for normal option buy order. Let me what should be used to close/exit position to close/exit my existing position with OCO GTT.
As @sujith mentioned you need to use same product type as used to create the position i.e here NRML. Make sure, the quantity is matching as per the open quantity.
def on_order_update(self, ws, data)
# Handle order updates
# TODO: Here we need to add code to place the order
in this section i want to get the order id of each BUY order placed and place a SELL two leg gtt order with stoploss -27% and target 12%
It seems very poor support from zerodha. I am trying this since 2 months and not able to solve it. No one connecting directly and not supporting quickly on post also.
Neither I am not able to find on doc. Can you share doc link where it specifies that exiting option buy, we need to do this?
I tried Normal and MIS order both. Screenshot is attached for MIS get order.
As per doc: https://kite.trade/docs/connect/v3/orders/
MIS : Margin Intraday Squareoff for futures and options ?
kite.place_order(
variety=kite.VARIETY_REGULAR,
exchange=kite.EXCHANGE_NFO,
tradingsymbol=trading_symbol,
transaction_type=kite.TRANSACTION_TYPE_BUY,
quantity=quantity,
product=kite.PRODUCT_NRML,
order_type=kite.ORDER_TYPE_LIMIT,
price=price,
tag=f""
)
It opens order or Zerodha and at limit price, it executes.
Now I need to close/exit this position with GTT order by setting Stop Loss and Take Profit.
I have used below code for that:
order_dict = [{"transaction_type": kite.TRANSACTION_TYPE_SELL, "quantity": quantity,
'order_type': kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_MIS,
"price": loss},
{"transaction_type": kite.TRANSACTION_TYPE_SELL, "quantity": quantity,
'order_type': kite.ORDER_TYPE_LIMIT, "product": kite.PRODUCT_MIS,
"price": target}]
kite.place_gtt(kite.GTT_TYPE_OCO, trading_symbol, kite.EXCHANGE_NFO,
[loss, target],
ltp, order_dict)
This is also creating GTT order but at execution time, it says insufficient fund.
I am closing/exiting position with inverse order as sell of my existing buy with type as MIS for normal option buy order.
Let me what should be used to close/exit position to close/exit my existing position with OCO GTT.
NRML
. Make sure, thequantity
is matching as per the open quantity.