How to place a GTT order using API in node

Thanks for the quick reply, looking forward to you posting a link for it on this thread :pray:

Sir, today is the last day of this month. When are you able to bring the GTT order using API?? if you can’t bring this feature, then force us to change the broker!!

Hi @pratik_chaudhari

Thanks for your patience. We’ll be releasing this pretty soon! Shall keep you posted on this!

Hey @pratik_chaudhari

Shipping GTT by tomorrow.

2 Likes

@MohitGolecha

Please ship GTT with MTF in API also. It was promised for January end, after that it was mentioned to be February end.
I am personally experiencing huge losses with MTF without it, Please understand and deliver it this weekend.

yes please enable gtt so that once we place a buy order we can also set the target and the stop loss and also we should be able to modify the target and stoploss using the api

@Ulta_Pulta @athma_prathisti

Will be releasing today. But no MTF yet! That’ll take a lil more while

1 Like

once you release please share the api code for the same or like updated the api documents with sample code

Till when, MTF GTT is there from day 1 in other brokers. This is a leveraged product it should have it from the beginning.

1 Like

In other threads it was mentioned that bracket orders are also getting released with TSL, will that be released today as well.

@MohitGolecha
Congratulations its a great set of APIs, so that means I can place equity, Future and option any instrument key in these apis for intraday or delivery?
TSL and slicing option is missing but that is ok.
in the product apart from I, D you can add MTF as well it will save efforts and reuse the code.
MTF could be intraday or delivery if not closed before cutoff time it will be delivery else intraday.

1 Like

@MohitGolecha please bring MTF order API ASAP.

How can I place the market order for the entry leg using GTT. I am experimenting with this and I can see that it sends the entry order as LIMIT order. I am using IMMEDIATE.

Thanks

Hi @amit44
You can refer GTT example codes for reference Place GTT Order | Upstox Developer API

Hi @Ketan , I am using the same cuurently. And It send the entry leg as limit order. How to send the entry less as market order.

{
“strategy”: “ENTRY”,
“trigger_type”: “ABOVE”,
“trigger_price”: 7.3
},

Should I keep the trigger price as 0 and trigger_type as IMMEDIATE?

It is fine if GTT does not have the market order thru API. I was just wondering if its possible or not by changing these variables

Yes, in Upstox API’s GTT (Good Till Triggered) orders, the entry leg is usually a LIMIT order, and there’s no direct way to place a MARKET order using GTT.

However, to simulate a market order for the entry leg using GTT, you can try:

  1. Set the trigger_price to 0 (or as close to the current market price as possible).
  2. Use trigger_type as IMMEDIATE, so the order executes as soon as it is placed.
  3. Set the price parameter to a very high value for a buy order (or a very low value for a sell order).
  • This ensures the limit order gets executed at the best available market price.

Example:

json

CopyEdit

{
  "trigger_type": "IMMEDIATE",
  "orders": [
    {
      "transaction_type": "BUY",
      "quantity": 1,
      "price": 99999,   // High price for a buy order (ensures market-like execution)
      "order_type": "LIMIT",
      "product": "CNC",
      "exchange": "NSE",
      "instrument_token": "XYZ"
    }
  ],
  "trigger_price": 0
}

This method works because:

  • When GTT is triggered, it places a LIMIT order at the specified price.
  • If you set the price significantly above (for buys) or below (for sells) the current price, it acts like a market order.

Let me know if you need help tweaking this further! :rocket:

2 Likes

Hi Kartik,

Thanks for taking your time and suggesting your solution.
I tried your suggested approach and got an error saying that my target price should be larger than my entry price.

I am trying to use GTT to: a) Place a market order. and then b) place the stop loss and take profit orders.

For TP and SL orders, I have to give target price and stop loss price. And GTT order is giving me error that target should me more than entry price. I tried to keep the entry price too high 9999.
But calculating the targe price based on the sensible entry price (limit price).

Do you have any other approach. And I am using python code provides on doc for GTT order.

import requests

url = 'https://api.upstox.com/v3/order/gtt/place'
headers = {
    'Content-Type': 'application/json',
    'Accept': 'application/json',
    'Authorization': 'Bearer {your_access_token}',
}

data = {
    "type": "MULTIPLE",
    "quantity": 1,
    "product": "I",
    "rules": [
        {
            "strategy": "ENTRY",
            "trigger_type": "ABOVE",
            "trigger_price": 7.3
        },
        {
            "strategy": "TARGET",
            "trigger_type": "IMMEDIATE",
            "trigger_price": 9
        },
        {
            "strategy": "STOPLOSS",
            "trigger_type": "IMMEDIATE",
            "trigger_price": 6
        }
    ],
    "instrument_token": "NSE_EQ|INE669E01016",
    "transaction_type": "BUY"
}

try:
    # Send the POST request
    response = requests.post(url, json=data, headers=headers)

    # Print the response status code and body
    print('Response Code:', response.status_code)
    print('Response Body:', response.json())

except Exception as e:
    # Handle exceptions
    print('Error:', str(e))

Well, in that case, i suggest that you get the latest candle closing price or the calculated entry limit price and set that as the entry price with trigger type as IMMEDIATE/ABOVE/BELOW. Which basically means all GTT Orders are LIMIT Orders. I don’t think Upstox has given the functionality of GTT Market Entry Orders via the API.

@Ketan @shrini Please look into this and let us know if GTT Market Entry Orders will be allowed via the API.