It looks like you're new here. If you want to get involved, click one of these buttons!
.Net API client
.Net / VBA / Excel (3rd party)
Algorithms and Strategies
Mobile and Desktop apps
Market data (WebSockets)
In this Discussion
squaring off existing position without any extra margin
Using algo, we opened a long position:
kite.place_order(exchange="NFO",tradingsymbol="BANKNIFTY21JANFUT",quantity = 75, transaction_type=BUY,order_type=self.kite.ORDER_TYPE_MARKET,validity=self.kite.VALIDITY_DAY,variety=self.kite.VARIETY_REGULAR,product=self.kite.PRODUCT_MIS)
And when our condition was met, we squared off using below:
kite.place_order(exchange="NFO",tradingsymbol="BANKNIFTY21JANFUT",quantity = 75, transaction_type=SELL,order_type=self.kite.ORDER_TYPE_MARKET,validity=self.kite.VALIDITY_DAY,tag=project_id,variety=self.kite.VARIETY_REGULAR,product=self.kite.PRODUCT_MIS)
But it booked a new trade and asked for further margin instead of closing the position we already had. Can you please let us know what we need to do to close off the position?
You need to check the quantity of the position before squaring off the position.
The above method seems fine, maybe the first order might have gotten rejected or you might have placed a sell order twice. You can check your orderbook on the kite for more details.
It was in the order book already (not rejected) and it still asked for 'further margin'.. I was able to manually square off from my position, which proved that it was in order book anyway ... Is there any parameter I was missing or should I use 'order number' while doing a sell trade?
Let me try again tomorrow and will let you know if I face the same error. Thank you