sreenivasdoosa / sdoosa-algo-trade-python

Algo trade project in python
521 stars 320 forks source link

Fetching open positions #21

Open rejeesh31 opened 3 years ago

rejeesh31 commented 3 years ago

Hi Srini, Could you help with a function to fetch the open position (qty) by passing the 'tradingsymbol'? Similar to below. Many Thanks!

def fetchPrice(orderId):
  logging.info('Fetching order price %s', orderId)
  kite = getKite()
  try:
    price = kite.order_history(order_id=orderId)[(len(kite.order_history(order_id=orderId)))-1]['average_price']
    logging.info('Order status fetched for orderId = %s price = %s', orderId, price)
    return price
  except Exception as e:
    logging.info('Order status fetch failed: %s', e.message)