What is wrong with this code? Everything looks good to me but its giving error. How to know what is the exact issue?
headers = {
‘accept’: ‘application/json’,
‘Api-Version’: ‘2.0’,
‘Content-Type’: ‘application/json’,
‘Authorization’ : f’Bearer {access_tokens}’
}
data = {
“quantity”: 15,
“product”: “D”,
“validity”: “DAY”,
“price”: 0,
“tag”: None,
“instrument_token”: Instrument,
“order_type”: “MARKET”,
“transaction_type”: “BUY”,
“disclosed_quantity”: 0,
“trigger_price”: 0,
“is_amo”: False
}
print(headers)
print(data)
response = requests.request(‘POST’,‘https://api-v2.upstox.com/order/place’,headers=headers,data=data)
print(response)
Output:
nstrument(exchange=‘NSE_FO’, token=59288, parent_token=26009, symbol=‘banknifty23sep46200ce’, name=‘’, closing_price=2.4, expiry=‘1695839400000’, strike_price=46200.0, tick_size=5.0, lot_size=15, instrument_type=‘OPTIDX’, isin=None)
NSE_FO|59288
{‘accept’: ‘application/json’, ‘Api-Version’: ‘2.0’, ‘Content-Type’: ‘application/json’, ‘Authorization’: ‘Bearer {ACCESS_TOKEN}’}
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 0, ‘tag’: None, ‘instrument_token’: ‘NSE_FO|59288’, ‘order_type’: ‘MARKET’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 0, ‘is_amo’: False}
<Response [400]>