Getting Open Positions Using AliceBlue Ant API

This function is developed over AliceBlue Official Python library.

def get_open_positions(portfolio):
  for j in range(len(portfolio)):
    if (int(portfolio[j]['Netqty']) == 0):
      portfolio.pop(j) 
    return portfolio

open_positions = get_open_positions(alice.get_netwise_positions())

print(open_positions)

I used the pop function after doing StackOverflow. It basically scans all positions one by one and deletes the positions whose open quantity is 0 i.e. the position is closed.