Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
Quick Alphalens Quantile Question

Hello all, I am currently analyzing a strategy with alphalens. Basically, the hopeful alpha factor relates to dividend yield. So for example I'd like to purchase the top (say 20%) of companies with the highest dividend yield. I am therefore ranking them in descending order, so that #1 rank would be the company with the highest dividend yield.

My question is, depending on whether or not the rank is ascending or descending, my plots turn out quite different. Basically I am wondering what alphalens is considering quantile 1, and what it is considering quantile 5. With these ranked in descending order, the mean return in bps for quantile 5 looks positive... so I'd want to (in theory) buy that quantile. However if I change it to ascending order, the plots are exactly the opposite. I might be over thinking this, but with this factor ranked in DESCENDING order, would quantile 5 be the stocks with the highest dividend yield, or the lowest?

Thanks!

Thanks!

1 response

look at your "factor_alpha_data = alphalens.utils.get_clean_factor_and_forward_returns()" output. This is the cleaned up data that will be used by the tearsheets. For each date/asset it has the target return, your factor value, and the assigned quantile.
I'm pretty sure that if you negate your factor then "factor_alpha_data" will assign opposite quantiles to your assets.

However I noticed recently when the tearsheets calculate cumulative returns they don't just do a sum(all returns in factor_alpha_data Q5) - sum(all returns in factor_alpha_data Q1) they somehow weight the returns by the score. And then the tearsheet shows a completely different returns chart from what you'd plot by factor_alpha_data sum(Q5)-sum(Q1). And now I'm also very confused about how the algo environment will generate positions from my scores.