Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
How are cumulative returns compute in alphalens?

When using tearsheet, 2 graphs are produced among other things that show cumulative returns;

1) factor weighted long/short portfolio cumulative return
2) cumulative return by quantile

After creating a min example pipeline with 2 stocks held over 1 day, I have been able to compute the returns for 2) but not for 1), it does not appear to be simply the return differential between the long and short quintile but something else. Does someone know how those returns are computed?

1 response

I have also tried to play with only 2 stocks and 2 quantiles in order to understand how alphalens work.

My observations are the following:
1) Use equal_weight=True to have equally weighted positions instead of factor-weighted positions.
1) Use demeaned = True to construct a long/short portfolio. You can get the same result by returns_quantile2 - returns_quantile1.
2) Use demeaned = False to construct a long-only portfolio. You can get the same result by returns_quantile2 + returns_quantile1.

To compute 2), you can use the following:

ls_factor_returns = al.performance.factor_returns(factor_data)  
(ls_factor_returns+1).cumprod()

And it will be equal to plotting the results from al.plotting.plot_cumulative_returns method.

What I don't understand so far, how alphalens work with odd numbers of quantiles. How the middle quantile is treated? Does it split the stocks into long and short positions?