Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Ryan17wow opened this issue Oct 7, 2020 · 0 comments
Open

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

Ryan17wow opened this issue Oct 7, 2020 · 0 comments

Comments

@Ryan17wow
Copy link

Ryan17wow commented Oct 7, 2020

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant