Hi @Pradeep_Jaiswar ,
I am unable place a BUY order using upstox Api
Please find below code
def place_order(self,quantity,instrument_token,tran_type) :
url =f’https://api-v2.upstox.com/order/place’
headers ={
'accept': 'application/json',
'Api-Version': '2.0' ,
'Content-Type': 'application/json',
'Authorization': f'Bearer {self.access_token}'
}
data = {
"quantity": quantity,
"product": self.PRODUCT_D,
"validity":self.VALIDITY_DAY,
"price": 0.0,
"tag": self.TAG,
"instrument_token": instrument_token, #"NSE_EQ|INE848E01016"
"order_type": self.ORDER_TYPE_MARKET,
"transaction_type":tran_type ,
"disclosed_quantity": 0,
"trigger_price": 0.0,
"is_amo": self.IS_AMO
}
response = requests.post(url,headers=headers,data=data)
# js_reponse = response.json()["data"]["order_id"]
print(response.status_code)
print(response.url)
print(response.text)
print(data)
Status code:-
400
End Point:-
https://api-v2.upstox.com/order/place
Please find below dictionary as data:-
{‘quantity’: 15, ‘product’: ‘D’, ‘validity’: ‘DAY’, ‘price’: 0.0, ‘tag’: ‘NA’, ‘instrument_token’: ‘NSE_FO|47344’, ‘order_type’: ‘MARKET’, ‘transaction_type’: ‘BUY’, ‘disclosed_quantity’: 0, ‘trigger_price’: 0.0, ‘is_amo’: False}
Error:-
{“status”:“error”,“errors”:[{“errorCode”:“UDAPI100038”,“message”:“Invalid input passed to the API”,“propertyPath”:null,“invalidValue”:null,“error_code”:“UDAPI100038”,“property_path”:null,“invalid_value”:null}]}
Please have look and fix the issue
Thank You!!