How to square-off a MIS Market order, that was executed successfully

samant
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 ?
  • rakeshr
    Now at some point of time during the day, my code needs to squareoff this position. How do I go about it ?
    There is no special APIs for this. You need to place a regular counter exit order(i.e here BUY, if shorted) to close the above position.
  • samant
    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);

    }
  • samant
    @rakeshr : Could you please confirm above comment ?

    Thanks
  • sujith
    It seems fine.
Sign In or Register to comment.