Question 1: is there an easier way to get a list of stocks that I currently own than this:

positions = [i for i in self.Portfolio.Keys if self.Portfolio[i].HoldStock]

I thought that Portfolio only included stocks that you own but apparently that's not the case so I had to implement this list comprehension. Seems there would be an easier way to just get a simple list of all the stocks currently held, but I couldn't find it.

 

Question 2: What is the proper way to get the list of stocks currently selected by your universe?

I have two universes, user-defined ETF's and stocks selected with coarse/fine selection. The two universes of stocks are treated entierly different by my algorithm so it's important that I have a list of a all stocks currently selected by the fundamentals. I don't care about which ones were added/removed today I just need all the ones that currently meet my criteria.

I tried everything mentioned on this thread: 

https://www.quantconnect.com/forum/discussion/1359/working-with-a-universe

with no luck. The only solution that i think worked is to append each stock's symbol to a list during the universe selection. like this:

for x in topFine: list.Add(x.Symbol) self.stocks_long.append(str(x.Symbol.Value)) return list

But now when I try and get the securities price I get an error saying that that the stock was not found in securities. If I add it to securities it then becomes part of my user-defined universe which would mess up the logic. I was under the assumption that all stocks selected with the universes were automatically added to securities and and had the data availible.

Author