Skip to content

When I use "bins" instead of "quantiles", it went wrong #387

@Ryan17wow

Description

@Ryan17wow

Problem Description

Please provide a minimal, self-contained, and reproducible example:

[factor_data = alphalens.utils.get_clean_factor_and_forward_returns(convpre,close,bins=[-10,-5,-1,0,10],periods=[1,5,10,20])]

Please provide the full traceback:

[ValueError                                Traceback (most recent call last)
<ipython-input-37-bcea1a6e8ef9> in <module>
----> 1 factor_data = alphalens.utils.get_clean_factor_and_forward_returns(convpre,close,bins=[-10,-5,-1,0,10],periods=[1,5,10,20])
      2 alphalens.tears.create_full_tear_sheet(factor_data)

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alphalens/utils.py 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)
    837                                    quantiles=quantiles, bins=bins,
    838                                    binning_by_group=binning_by_group,
--> 839                                    max_loss=max_loss, zero_aware=zero_aware)
    840 
    841     return factor_data

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alphalens/utils.py in get_clean_factor(factor, forward_returns, groupby, binning_by_group, quantiles, bins, groupby_labels, max_loss, zero_aware)
    636         binning_by_group,
    637         no_raise,
--> 638         zero_aware
    639     )
    640 

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alphalens/utils.py in dec(*args, **kwargs)
     74     def dec(*args, **kwargs):
     75         try:
---> 76             return func(*args, **kwargs)
     77         except ValueError as e:
     78             if 'Bin edges must be unique' in str(e):

/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/alphalens/utils.py in quantize_factor(factor_data, quantiles, bins, by_group, no_raise, zero_aware)
    129     if not ((quantiles is not None and bins is None) or
    130             (quantiles is None and bins is not None)):
--> 131         raise ValueError('Either quantiles or bins should be provided')
    132 
    133     if zero_aware and not (isinstance(quantiles, int)

ValueError: Either quantiles or bins should be provided]

Please provide any additional information below:

Versions

  • Alphalens version: 0.4.0
  • Python version: 3.60
  • Pandas version: 0.22
  • Matplotlib version: 1.40

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions