quantopian / alphalens

Performance analysis of predictive (alpha) stock factors
http://quantopian.github.io/alphalens
Apache License 2.0
3.18k stars 1.12k forks source link

Issues with return data #378

Open noobmaster29 opened 4 years ago

noobmaster29 commented 4 years ago

Problem Description

I'm having issues with the returns being calculated. When I run a longer window, more current returns suddenly jump 200% in one day. As seen below in the attached images, if I run from September 2018 to Jan 2020, the daily returns look fairly normal. However, if I open the window to Jan 2018 to Jan 2020, there is a sudden huge jump in Oct 2019. I'm not sure what is causing this. Between the 2 runs, I did not change any variables or data. I only changed the starting date.

Code used to generate the returns: factor_data = alphalens.utils.get_clean_factor_and_forward_returns(predictive_factor, pricing, quantiles=5, #default is 5 bins=None, groupby=ticker_sector, groupby_labels=sector_names )

I've also tried to breakout the return and factor calculations (It produces the same issues):

returns = alphalens.utils.compute_forward_returns(predictive_factor, pricing)
factor_data = alphalens.utils.get_clean_factor(predictive_factor, returns, quantiles=5, #default is 5 bins=None, groupby=ticker_sector, groupby_labels=sector_names)

Screen Shot 2020-05-11 at 7 51 04 PM Screen Shot 2020-05-11 at 7 41 00 PM

Versions

noobmaster29 commented 4 years ago

I also plotted all the daily returns for all individual assets in the dataset and there doesn't seem to be any difference that would cause the huge jump seen in the cumulative return by quantile graph (Jan 2018 - Jan 2020).

download download (1)

I will take a look through the source code. Any thoughts on what might be causing this issue is welcomed. Thanks in advance.