order_url = “https://api-hft.upstox.com/v3/order/place”
order_params_leg1 = {
“instrument_token”: instrument[0],
“quantity”: qty,
“order_type”: “MARKET”, # Order type
“transaction_type”: “SELL”,
“price”: 0, # Required for API even for market orders
“validity”: “DAY”,
“product”: “D”, # Replace ‘NRML’ with valid product value
“trigger_price”: 0 # Explicitly added
}
order_params_leg2 = {
"instrument_token": instrument[1],
"quantity": qty,
"order_type": "MARKET",
"transaction_type": "BUY",
"price": 0,
"validity": "DAY",
"product": "D", # Replace 'NRML' with valid product value
"trigger_price": 0
}
response_leg1 = make_request(‘POST’, order_url, headers=headers, params=order_params_leg1)
response_leg2 = make_request(‘POST’, order_url, headers=headers, params=order_params_leg2)
Errors:
Leg 1 (Sell) order failed.
Error Response from API: {‘status’: ‘error’, ‘errors’: [{‘errorCode’: ‘UDAPI1026’, ‘message’: ‘Instrument key is required’, ‘propertyPath’: ‘instrumentKey’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1026’, ‘property_path’: ‘instrumentKey’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1006’, ‘message’: ‘Product is required’, ‘propertyPath’: ‘product’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1006’, ‘property_path’: ‘product’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1009’, ‘message’: ‘TransactionType is required’, ‘propertyPath’: ‘side’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1009’, ‘property_path’: ‘side’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1008’, ‘message’: ‘Price is required’, ‘propertyPath’: ‘price’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1008’, ‘property_path’: ‘price’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1007’, ‘message’: ‘Validity is required’, ‘propertyPath’: ‘validity’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1007’, ‘property_path’: ‘validity’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1004’, ‘message’: ‘Valid order type is required’, ‘propertyPath’: ‘orderType’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1004’, ‘property_path’: ‘orderType’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1036’, ‘message’: “The ‘‘trigger_price’’ is required”, ‘propertyPath’: ‘triggerPrice’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1036’, ‘property_path’: ‘triggerPrice’, ‘invalid_value’: None}]}
Error Code: UDAPI1026, Message: Instrument key is required
Error Code: UDAPI1006, Message: Product is required
Error Code: UDAPI1009, Message: TransactionType is required
Error Code: UDAPI1008, Message: Price is required
Error Code: UDAPI1007, Message: Validity is required
Error Code: UDAPI1004, Message: Valid order type is required
Error Code: UDAPI1036, Message: The ‘‘trigger_price’’ is required
Leg 2 (Buy) order failed.
Error Response from API: {‘status’: ‘error’, ‘errors’: [{‘errorCode’: ‘UDAPI1006’, ‘message’: ‘Product is required’, ‘propertyPath’: ‘product’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1006’, ‘property_path’: ‘product’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1007’, ‘message’: ‘Validity is required’, ‘propertyPath’: ‘validity’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1007’, ‘property_path’: ‘validity’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1036’, ‘message’: “The ‘‘trigger_price’’ is required”, ‘propertyPath’: ‘triggerPrice’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1036’, ‘property_path’: ‘triggerPrice’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1004’, ‘message’: ‘Valid order type is required’, ‘propertyPath’: ‘orderType’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1004’, ‘property_path’: ‘orderType’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1008’, ‘message’: ‘Price is required’, ‘propertyPath’: ‘price’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1008’, ‘property_path’: ‘price’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1026’, ‘message’: ‘Instrument key is required’, ‘propertyPath’: ‘instrumentKey’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1026’, ‘property_path’: ‘instrumentKey’, ‘invalid_value’: None}, {‘errorCode’: ‘UDAPI1009’, ‘message’: ‘TransactionType is required’, ‘propertyPath’: ‘side’, ‘invalidValue’: None, ‘error_code’: ‘UDAPI1009’, ‘property_path’: ‘side’, ‘invalid_value’: None}]}
Error Code: UDAPI1006, Message: Product is required
Error Code: UDAPI1007, Message: Validity is required
Error Code: UDAPI1036, Message: The ‘‘trigger_price’’ is required
Error Code: UDAPI1004, Message: Valid order type is required
Error Code: UDAPI1008, Message: Price is required
Error Code: UDAPI1026, Message: Instrument key is required
Error Code: UDAPI1009, Message: TransactionType is required