Navigation

    SmartAPI Forum
    • Register
    • Login
    • Search
    • Categories
    • Popular
    • Groups
    • FAQs
    • API Docs

    How to get the average price of an executed order?

    Python SDK
    0
    1
    17
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      projectSB last edited by

      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

      1 Reply Last reply Reply Quote 0
      • First post
        Last post