quantopian / alphalens

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

ValueError: min() arg is an empty sequence #312

Closed fzhcary closed 5 years ago

fzhcary commented 5 years ago

hi, I am having this issue ( data are sorted by dates ascending ) Is this caused by numpy version? my alpha lens, pandas and numpy version are 0.3.2 0.22.0 1.14.0

I created factor_data using

factor_data = alphalens.utils.get_clean_factor_and_forward_returns(factor, pricing, periods=(1, 5, 10), quantiles=5, bins=None)

Do I have to use quantiles=5? could it be the quantiles values cause problem

Any clue is appreciated. Thanks a lot!

======================================================

ValueErrorTraceback (most recent call last)

in () ----> 1 alphalens.tears.create_summary_tear_sheet(factor_data) /home/frank/Envs/alphalens/local/lib/python2.7/site-packages/alphalens/plotting.pyc in call_w_context(*args, **kwargs) 43 with plotting_context(), axes_style(), color_palette: 44 sns.despine(left=True) ---> 45 return func(*args, **kwargs) 46 else: 47 return func(*args, **kwargs) /home/frank/Envs/alphalens/local/lib/python2.7/site-packages/alphalens/tears.pyc in create_summary_tear_sheet(factor_data, long_short, group_neutral) 271 for q in range(1, int(quantile_factor.max()) + 1)], 272 axis=1) --> 273 for p in periods} 274 275 autocorrelation = pd.concat( /home/frank/Envs/alphalens/local/lib/python2.7/site-packages/alphalens/tears.pyc in ((p,)) 271 for q in range(1, int(quantile_factor.max()) + 1)], 272 axis=1) --> 273 for p in periods} 274 275 autocorrelation = pd.concat( /home/frank/Envs/alphalens/local/lib/python2.7/site-packages/alphalens/performance.pyc in quantile_turnover(quantile_factor, quantile, period) 736 # find the frequency at which the factor is computed 737 idx = quant_name_sets.index --> 738 freq = min([idx[i] - idx[i-1] for i in range(1, min(10, len(idx)))]) 739 shift = int(pd.Timedelta(period) / freq) 740 ValueError: min() arg is an empty sequence
luca-s commented 5 years ago

Do I have to use quantiles=5? could it be the quantiles values cause problem

No, you can split your data in as many bins as you like.

luca-s commented 5 years ago

Could you compare your input data to the example NBs? This is just to be sure it is not a formatting issue.