I am new to coding and am trying to write an algorithm that does multiple conditional sorts on a universe of stocks. First, I want to filter out all stocks with liquidity below a threshold, stocks with avg price below $5 and then take the top 3000 by market cap of the remaining stocks as my universe. I have figured out how to do that part already.
Next, I want do several conditional sorts on that universe of the 3000 remaining stocks using various factors. This is the part I cannot figure out. For example, I want to sort the 3000 stocks by PE ratio, and take the top 1000. Then I want to sort that list of 1000 stocks by 12 month momentum, and take the highest 333. Then I want to take that list of 333 stocks and sort by ROE, and take the highest 111. Then I want to go long the top 10 stocks in the list of the 111 stocks. Any help would be greatly appreciated.