If I have shorted some instrument, say NIFTY12000CE as an MIS market order with VARIETY_REGULAR param in placeOrder call. The order got placed and executed successfully. Now at some point of time during the day, my code needs to squareoff this position. How do I go about it ? Which API to use ? Is there an example ?
Great. I though so too. Would like to confirm following code to exit all short positions. Map> pos = kiteConnect.getPositions(); List positions=pos.get("day"); Position p=null; for ( int i=0;iorderParams.quantity = p.sellQuantity; orderParams.transactionType = Constants.TRANSACTION_TYPE_BUY; orderParams.orderType = Constants.ORDER_TYPE_MARKET; orderParams.tradingsymbol = p.tradingSymbol; orderParams.exchange = Constants.EXCHANGE_NFO; orderParams.validity = Constants.VALIDITY_DAY; orderParams.product = Constants.PRODUCT_MIS; Order order = kiteConnect.placeOrder(orderParams, Constants.VARIETY_REGULAR);
Map> pos = kiteConnect.getPositions();
List positions=pos.get("day");
Position p=null;
for ( int i=0;iorderParams.quantity = p.sellQuantity;
orderParams.transactionType = Constants.TRANSACTION_TYPE_BUY;
orderParams.orderType = Constants.ORDER_TYPE_MARKET;
orderParams.tradingsymbol = p.tradingSymbol;
orderParams.exchange = Constants.EXCHANGE_NFO;
orderParams.validity = Constants.VALIDITY_DAY;
orderParams.product = Constants.PRODUCT_MIS;
Order order = kiteConnect.placeOrder(orderParams, Constants.VARIETY_REGULAR);
}
Thanks