ValueErrorTraceback (most recent call last)
<ipython-input-81-4c3b7a9e2a3c> in <module>()
2 factor_data = al.utils.get_clean_factor_and_forward_returns(factor=factor_data_clean,
3 prices=prices,
----> 4 periods=periods, max_loss=0)
/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)
604 binning_by_group,
605 no_raise,
--> 606 zero_aware
607 )
608
/usr/local/lib/python2.7/dist-packages/alphalens/utils.pyc in dec(*args, **kwargs)
76 except ValueError as e:
77 if 'Bin edges must be unique' in str(e):
---> 78 rethrow(e, message)
79 raise
80 return dec
/usr/local/lib/python2.7/dist-packages/alphalens/utils.pyc in rethrow(exception, additional_message)
43 else:
44 e.args = (e.args[0] + m,) + e.args[1:]
---> 45 raise e
46
47
ValueError: Bin edges must be unique: array([ 18.22, 18.22, 18.22, 18.22, 18.22, 18.22])
An error occurred while computing bins/quantiles on the input provided.
This usually happens when the input contains too many identical
values and they span more than one quantile. The quantiles are choosen
to have the same number of records each, but the same value cannot span
multiple quantiles. Possible workarounds are:
1 - Decrease the number of quantiles
2 - Specify a custom quantiles range, e.g. [0, .50, .75, 1.] to get unequal
number of records per quantile
3 - Use 'bins' option instead of 'quantiles', 'bins' chooses the
buckets to be evenly spaced according to the values themselves, while
'quantiles' forces the buckets to have the same number of records.
4 - for factors with discrete values use the 'bins' option with custom
ranges and create a range for each discrete value
Please see utils.get_clean_factor_and_forward_returns documentation for
full documentation of 'bins' and 'quantiles' options.