I was not able to do intraday for the CRUDEOIL 6600 CE using the api.
why is it happening.
code:
import requests
import json
def access_token():
with open('jsons/access_token.json','r') as file:
access_token = json.load(file)
return access_token['access_token']
def buy(access_token, instrument_token):
url = 'https://api-hft.upstox.com/v2/order/place'
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': f'Bearer {access_token}',
}
data = {
'quantity': 1,
'product': 'I',
'validity': 'DAY',
'price': 41.50,
'tag': 'string',
'instrument_token': instrument_token,
'order_type': 'SL',
'transaction_type': 'BUY',
'disclosed_quantity': 0,
'trigger_price': 41.00,
'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 __name__ == '__main__':
token = access_token()
instrument_token = 'MCX_FO|434267'
buy(token,instrument_token)
error: