How to Place the SL or Exit orders on Open position

Hi Team,
How to place Stop Loss Order or Exit the Order on Open Positions.
E.g: I will Buy the 47700 CE at the strike price 300 and the order is executed. I want to place the SL order at 250 or want to exit the 47700 CE at 350.

I went through the Developer API. But SL and exit order placing details are not clear.

For an existing open position, you should place a separate limit order for 250 for your first case. To exit, you must place the opposite order leg (e.g., buy instead of sell) at the market price. If you wish to exit at a specific price, place a limit order. Note that these orders are only valid for the day they are issued.

The procedure will be streamlined with the introduction of the GTT order in Upstox.

How to place the opposite order leg with API

In your order payload, the value for the key transaction_type should be “SELL” if your initial order was “BUY” and “BUY” if it was “SELL.”

For instance, consider the following example where you place a “BUY” order:

{
    'quantity': 10,
    'product': 'D',
    'validity': 'DAY',
    'price': 0,
    'tag': 'string',
    'instrument_token': 'NSE_EQ|INE669E01016',
    'order_type': 'MARKET',
    'transaction_type': 'BUY',
    'disclosed_quantity': 0,
    'trigger_price': 0,
    'is_amo': False,
}

Subsequently, to exit this trade, your order API would look like this with a “SELL” transaction type:

{
    'quantity': 10,
    'product': 'D',
    'validity': 'DAY',
    'price': 0,
    'tag': 'string',
    'instrument_token': 'NSE_EQ|INE669E01016',
    'order_type': 'MARKET',
    'transaction_type': 'SELL',
    'disclosed_quantity': 0,
    'trigger_price': 0,
    'is_amo': False,
}

can i place two limit order after buying one order,
let say i buy one option with limit order

{
        quantity: 25,
        product: "D",
        validity: "DAY",
        price: ltp,
        tag: "string",
        instrument_token: instrumentKey,
        order_type: "LIMIT",
        transaction_type: "BUY",
        disclosed_quantity: 0,
        trigger_price: 0,
        is_amo: false,
      };

and then next second can i place two limit orders to exit my postion?
like below

      requestStoplose = {
        quantity: 25,
        product: "D",
        validity: "DAY",
        price: ltp * 0.9,
        tag: "string",
        instrument_token: instrumentKey,
        order_type: "LIMIT",
        transaction_type: "SELL",
        disclosed_quantity: 0,
        trigger_price: 0,
        is_amo: false,
      };

and

     requestProfitOrder = {
        quantity: 25,
        product: "D",
        validity: "DAY",
        price: ltp * 1.1,
        tag: "string",
        instrument_token: instrumentKey,
        order_type: "LIMIT",
        transaction_type: "SELL",
        disclosed_quantity: 0,
        trigger_price: 0,
        is_amo: false,
      };

You can set two limit orders, but be sure to cancel the second one if the first gets executed. In the example provided, the second limit order will be rejected because it involves product “D.” However, be cautious with intraday products, as the order might be executed as a short order.

Do you have any updates on GTT order implemented with API?

Currently, it is not possible to place a GTT (Good Till Triggered) order via API v2. We are actively working on enabling GTT functionality within the V2 API. Updates will be provided to you as soon as it becomes available.