Using the basic fundamental factor tutorial, I've been playing around with some factors. 

This tutorial is creating a long/short portfolio where you go long top ranked stocks and short poorest ranking ones. I would instead like to compare each quintile against the benchmark (say SPY) to see if the alpha is consistent and gets worse for each quintile and at what times different factors might perform better. 

I imagine this would be done by looping the portfolio creation and creating multiple portfolios (one for each quintile), but not sure how that can be done and the only post I can find about it from 2014 and doesn't seem that valid anymore. 

Does anyone have any ideas? Coding in Python.