Hi, I am trying to compute margin required for Buying/Selling of a PE/CE and I am encountering the following error: {'status': 'error', 'errors': [{'errorCode': 'UDAPI100011', 'message': 'Invalid Instrument key', 'propertyPath': 'instrument_token', 'invalidValue': 'NSE_FO|Nifty 50', 'error_code': 'UDAPI100011', 'property_path': 'instrument_token', 'invalid_value': 'NSE_FO|Nifty 50'}]}
The request is as follows:
margin_url = "https://api.upstox.com/v2/charges/margin"
headers = {
'accept': 'application/json',
'Api-Version': '2.0',
'Content-Type': 'application/json',
'Authorization': f'Bearer {access_token}'
}
data = {
'instruments': [
{
'instrument_key': 'NSE_FO|Nifty 50',
'quantity': 2,
'transaction_type': 'BUY',
'product': 'D',
'price': df2[df2['strike'] == round(spotMinusOneSD, -2)]['pe_ltp'].values[0]
}
]
}
response = requests.post(margin_url, headers=headers, json=data)
print(response.status_code)
print(response.json())
I am not very sure about the above code, but, I think I am not providing the right instrument_key, according to the errorCode. Can somebody help me fixing this, please?