How to find the status of an order

utlsingh
Hey all ,

I want to sell a share which i brought some time before but not confirm that it was executed or not . So , can anyone tell me how to know the new status of the buy order that i put some time before . And can anyone tell me what's the key and value for the returned map for the getPositions() and how it works .

Thanks in advance
Tagged:
  • venun
    venun edited December 2017
    if buy quantity >0 means you have a buy position
    if = 0 no position
    if < 0 sell position
  • rksingh
    rksingh edited December 2017
    I am posting my code(in python) which I use...
    Whenever we place order, we get order id. Below code uses this order id to check if placed order was successful or not...Hope this helps
    def placed_order_status(self, order_id):
    # check status of orders placed if successful or not
    self.order_successful = False
    if len(kite.trades(order_id)) == 0:
    print("Order placement failed for order_id ",order_id)
    else:
    self.order_successful = True
    print("Order Successful")
  • rksingh
    rksingh edited December 2017
    Below is my code to check open position(in python) if there exist any.
    This is the first step of my code. I use this data for various action

    def check_open_position(self):
    self.exchange = ' '
    self.product = ' '
    self.transaction_type = ' '
    self.qty = 0
    self.order_type = ' '
    # check if there exist any open position from previous/current day
    for i in range(0,len(kite.positions()['net'])):
    if (kite.positions()['net'][i]['buy_quantity'] !=
    kite.positions()['net'][i]['sell_quantity']):
    self.trading_symbol=kite.positions()['net'][0]['tradingsymbol']
    self.exchange=kite.positions()['net'][0]['exchange']
    self.qty=kite.positions()['net'][0]['quantity']
    self.product=kite.positions()['net'][0]['product']
    if kite.positions()['net'][0]['sell_quantity'] > 0:
    self.transaction_type="SELL"
    if kite.positions()['net'][0]['buy_quantity'] > 0:
    self.transaction_type="BUY"
    self.buy_price = kite.positions()['net'][0]['buy_price']
    self.position = 'Y'
    print ('Open Position: ',self.trading_symbol,self.exchange,self.qty,self.product,self.transaction_type)

  • sujith
    Hi,
    I think the easier way is to fetch orderbook and find order id which you got from order place response and check for status contains COMPLETE.
    If COMPLETE then you fetch positions.
    In the above code, you have too many conditions and to save bandwidth store positions response. In the above code to check one if statement you seem to making multiple API calls.
  • saurabh3679
    what are the other status possible? rejected, open, pending, partially executed?
This discussion has been closed.