Whats the difference between LIMIT order and Stop loss order in API?

I was going thru the api doc and realised that I have to give all the parameters to both LIMIT order and STOP LOSS order. So I started to wondering whats the difference between these two methods in api. For reference code for both methos is as below:

import requests

url = ‘https://api-hft.upstox.com/v2/order/place
headers = {
‘Content-Type’: ‘application/json’,
‘Accept’: ‘application/json’,
‘Authorization’: ‘Bearer {your_access_token}’,
}

data = {
‘quantity’: 1,
‘product’: ‘I’,
‘validity’: ‘DAY’,
‘price’: 20.0,
‘tag’: ‘string’,
‘instrument_token’: ‘NSE_EQ|INE528G01035’,
‘order_type’: ‘LIMIT’,
‘transaction_type’: ‘BUY’,
‘disclosed_quantity’: 0,
‘trigger_price’: 20.1,
‘is_amo’: False,
}

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))

import requests

url = ‘https://api-hft.upstox.com/v2/order/place
headers = {
‘Content-Type’: ‘application/json’,
‘Accept’: ‘application/json’,
‘Authorization’: ‘Bearer {your_access_token}’,
}

data = {
‘quantity’: 1,
‘product’: ‘I’,
‘validity’: ‘DAY’,
‘price’: 20.0,
‘tag’: ‘string’,
‘instrument_token’: ‘NSE_EQ|INE528G01035’,
‘order_type’: ‘SL’,
‘transaction_type’: ‘BUY’,
‘disclosed_quantity’: 0,
‘trigger_price’: 19.5,
‘is_amo’: False,
}

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))

If someone can explain, when should I use the STOP loss rather than LIMIT order, it will help a lot.

Hi , can anyone please answer my query. If my question is not clear, let me put it again.

Why do I need to put a trigger price in the LIMIT order. IF I have to then how its different from STOP LOSS order.
Thru the UI, when ever we place a limit order, it means that broker is sending the order to the order book. And when we place a stop loss limit order, it means that broker will send the order only when its triggered. So I am confused why limit order has triger price parameter

Hi @amit44, You are correct that the trigger_price is applicable only for SL orders. However, it is still a mandatory field and must be specified. You can pass either zero or an appropriate value based on the order_type.

For a detailed explanation, please refer to: What are the different stock market Order Types on Upstox? - Upstox Help Center

Thanks

1 Like