Option sell with stop loss price API


  • Hi, Can anyone please help me with placing option sell order through API ?

    I am assuming, i need to give variety as "STOPLOSS" and give the stoploss price while placing the order. Do i need to enter anything in price or square off fields as well ? I want to sell the option at market price and put SL value, Would i be required to place an order at market price and then place an order for SL ? thanks

    	String sPriceString=String.valueOf(sPrice);
    	OrderParams orderParams = new OrderParams();
    	orderParams.variety = "STOPLOSS";
    	orderParams.quantity = 1;
    	orderParams.symboltoken = symbolToken;
    	orderParams.exchange = Constants.EXCHANGE_NFO;
    	orderParams.ordertype = Constants.ORDER_TYPE_SL;
    	orderParams.tradingsymbol = tradingSymbol;
    	orderParams.producttype = Constants.PRODUCT_INTRADAY;		;
    	orderParams.duration = Constants.VALIDITY_DAY;
    	orderParams.transactiontype = Constants.TRANSACTION_TYPE_SELL;
    	orderParams.price = null;
    	orderParams.squareoff = null;
    	orderParams.stoploss = sPriceString;

  • @nehasrivastava strange it works for me as per expectation


  • Thanks @prateekjjw001 for sharing the details. I think, ROBO order placement is required (which is under development as per post in forum) as with the above available options i had tried, either option is getting sold at market price with no SL or an order goes into pending state waiting for the price to match up.


  • @nehasrivastava you can see here
    https://smartapi.angelbroking.com/docs/Orders
    triggerprice The price at which an order should be triggered (SL, SL-M)


  • Thanks @prateekjjw001 for the reply. are you referring to price field or triggerprice value to set? I had a look at the code and only price field is defined. Does API support triggerprice as well if I include in the request? Thanks


  • @nehasrivastava you need to give params like below:
    order_type='STOPLOSS_LIMIT'
    variety='STOPLOSS'
    triggerprice=sl trigger price
    price=limit price (or 0.0 for SL-M order)

    I did not give anything for "stoploss" and "squareoff" parameter


  • Hi @Admin, i am able to place the order with the below parameters but stop loss field is not getting reflected in the order. Only a sell order gets executed, I want a pending order with SL values and trigger price.Also there is no trigger field defined in the Order parameters, kindly help. thanks

    String sPriceString=String.valueOf(sPrice);
    OrderParams orderParams = new OrderParams();
    orderParams.variety = "NORMAL";
    orderParams.quantity = 25;
    orderParams.symboltoken = symbolToken;
    orderParams.exchange = Constants.EXCHANGE_NFO;
    orderParams.ordertype = Constants.ORDER_TYPE_MARKET;
    orderParams.tradingsymbol = tradingSymbol;
    orderParams.producttype = Constants.PRODUCT_INTRADAY; ;
    orderParams.duration = Constants.VALIDITY_DAY;
    orderParams.transactiontype = Constants.TRANSACTION_TYPE_SELL;
    orderParams.price = Double.valueOf(0);
    orderParams.squareoff = "0";
    orderParams.stoploss = "5.1";