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.