Number of open positions
Is there a way to get the number of all the open positions without looping through all the data to find if self.getposition(d) has a size > 0?
I needed it in Sizer
After debugging I found the positions in self.broker.positions are not only the ones with positive size so I'm back to looping. To get the nuber of open positions inside a Sizer I am using a list comprehension:
open_positions = len([position for position in self.broker.positions if self.broker.getposition(position).size > 0])
anyone can suggest a better solution?