How to get the average price of an executed order?
-
Greetings all!
Is there a function / method under Python Smart API, which will fetch the average price at which an order was executed?
This is important because, my algo tries to hedge an open position, depending on the price at which the first order is executed. So if I don't get the average price, my hedgeorder won't be executed.
Consider the code below:
def placeOrder(tradingSymbol, symbolToken, transactionType, price):
if price == 0:
orderType = "MARKET"
else:
orderType = "LIMIT"
try:
orderparams = {
"variety": "NORMAL",
"tradingsymbol": tradingSymbol,
"symboltoken": symbolToken,
"transactiontype": transactionType,
"exchange": "NFO",
"ordertype": orderType,
"producttype": "INTRADAY",
"duration": "IOC",
"price": price,
"squareoff": "0",
"stoploss": "0",
"quantity": QUANTITY
}
orderResponse = obj.placeOrder(orderparams)
print(orderResponse)
logger.info("Order generated: "+str(orderResponse)+" "+transactionType+" price "+str(price))
orderStatus = "SUCCESS"except Exception as e: logger.info(e) print(e) orderStatus = "FAILED" return orderStatus
Can I use the order ID received in orderResponse variable, to fetch the average price for that order?
Please help!Note: I don't want to use the order subscribe option, to monitor my position. I just want a single call to get the average price.
Thanks,
-Sudip