Individual order status API throws error for unknown reason!
-
@admin @Moderator_1 @Moderator_2
Hi Folks,
Please check the below issue:
I have used the individual order status API to fetch the order status after firing an order. It was working fine, but it threw the following error for one of them:The error was: [E 240208 15:03:27 smartConnect:479] Error occurred in ind_order_details: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None))
Note that the actual order got executed - order ID - 240208002143933.
Kindly help in understanding the root cause to avoid such issues in the future.
Here is the the code block used by me:
response = smartApi.placeOrderFullResponse(orderparams)
print(response)
if response['message'] == "SUCCESS":
uniqueOrderID = response['data']['uniqueorderid']
while True:
orderResponse = smartApi.individual_order_details(uniqueOrderID)
if orderResponse['data']['orderstatus'] == 'complete':
orderStatus = orderResponse['data']['orderstatus']
orderID = orderResponse['data']['orderid']
avgPrice = orderResponse['data']['averageprice']
logger.info(transactionType+" avgPrice of "+tradingSymbol+": "+str(avgPrice)+" order_ID: "+str(orderID)+" "+orderStatus)
break
if orderResponse['data']['orderstatus'] == 'rejected':
break
time.sleep(0.1) -
Hi @pskale7755
You can fetch unique order ID from place order response under key uniqueorderid
Reference:
https://smartapi.angelbroking.com/docs/OrdersSample Response:
{
"status":true,
"message":"SUCCESS",
"errorcode":"",
"data":{
"script":"SBIN-EQ",
"orderid":"200910000000111"
"uniqueorderid":"34reqfachdfih"
}
} -
@projectSB But how to get the "uniqueOrderID" as once you placed order, you usually get the order id not uniqueOrderID. can you please share some light.
@Moderator_2 , @projectSB -
@Moderator_2 I have used neither of the APIs you have mentioned. There is another API:
orderResponse = smartApi.individual_order_details(uniqueOrderID)
This allows you to extract the order status (Open, Completed or Rejected, and other details) directly without the need to fetch the whole orderbook / tradebook.
Isn't this the whole purpose of bringing the 'UniqueOrderId' feature you guys deployed?Anyways, my client ID is S382492
Please have a look and suggest what's the root cause. And also, whether we should be using the new API or not.
-
Hi @projectSB
Kindly share us the client code to analyze on the issue.
Please confirm which API consumed to retrieve the status of the order. (either orderbook or tradebook)https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/getOrderBook
https://apiconnect.angelbroking.com/rest/secure/angelbroking/order/v1/getTradeBookThanks & Regards,
SmartAPI team