Back to Community
Alphalens error I couldn't resolve for the past couple of days

Hello fellow quants,
I'm currently trying to analyse the PsychSignal database using alphalens but I keep running into the same problem. It won't run because there is an issue with bins/quantiles. I think it has something to do with the fact that there are many stocks for which the database returns 0 or NaN so it's not possible to create quantiles as usual. I have tried to use bins instead of quantiles and also I have tried to drop duplicates before passing this stuff to alphalens but I keep getting the following error. I'm thankful for any hints/suggestions!!!

Dropped 41.3% entries from factor data: 0.2% in forward returns computation and 41.1% in binning phase (set max_loss=0 to see potentially suppressed Exceptions).
MaxLossExceededErrorTraceback (most recent call last)
in ()
41
42 ### Ingest and format data
---> 43 factor_data = alphalens.utils.get_clean_factor_and_forward_returns(results['factor'], price_history,quantiles = 3, bins=None,periods=(1,5,10))
44
45 ### Run analysis
/usr/local/lib/python2.7/dist-packages/alphalens/utils.pyc in get_clean_factor_and_forward_returns(factor, prices, groupby, binning_by_group, quantiles, bins, periods, filter_zscore, groupby_labels, max_loss, zero_aware, cumulative_returns) 797 quantiles=quantiles, bins=bins,
798 binning_by_group=binning_by_group,
--> 799 max_loss=max_loss, zero_aware=zero_aware)
800
801 return factor_data
/usr/local/lib/python2.7/dist-packages/alphalens/utils.pyc in get_clean_factor(factor, forward_returns, groupby, binning_by_group, quantiles, bins, groupby_labels, max_loss, zero_aware) 625 message = ("max_loss (%.1f%%) exceeded %.1f%%, consider increasing it."
626 % (max_loss * 100, tot_loss * 100))
--> 627 raise MaxLossExceededError(message)
628 else:
629 print("max_loss is %.1f%%, not exceeded: OK!" % (max_loss * 100))
MaxLossExceededError: max_loss (35.0%) exceeded 41.3%, consider increasing it.

Loading notebook preview...
Notebook previews are currently unavailable.