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

NumPy 2.x compatibility, np.NINF was removed #50

Open
ajjoslin opened this issue Sep 15, 2024 · 1 comment
Open

NumPy 2.x compatibility, np.NINF was removed #50

ajjoslin opened this issue Sep 15, 2024 · 1 comment

Comments

@ajjoslin
Copy link

Problem Description

To reproduce:

import pyfolio as pf
import yfinance as yf


history = yf.Ticker("MGK").history("max")
returns = history.Close.pct_change()
pf.create_returns_tear_sheet(returns, live_start_date="2020-1-1")

Traceback:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "c:\FamilyStuff\BudgetFinance\portfolio\env-portfolio\Lib\site-packages\empyrical\stats.py", line 741, in sortino_ratio
    else downside_risk(returns, required_return, period, annualization)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "c:\FamilyStuff\BudgetFinance\portfolio\env-portfolio\Lib\site-packages\empyrical\stats.py", line 821, in downside_risk
    np.NINF,
    ^^^^^^^
  File "c:\FamilyStuff\BudgetFinance\portfolio\env-portfolio\Lib\site-packages\numpy\__init__.py", line 414, in __getattr__
    raise AttributeError(
AttributeError: `np.NINF` was removed in the NumPy 2.0 release. Use `-np.inf` instead.

Additional info:

  • Root cause @ line 821 in empyrical.stats.py, in downside_risk() method
  • Could fix by getting updating empyrical (if available), or specifying a 1.x version of NumPy in requirements?

Versions

  • Pyfolio version: 0.9.7
  • empyrical-reloaded version: 0.5.10
  • Python version: 3.12.6
  • Pandas version: 2.2.2
  • Matplotlib version: 3.9.2
@ajjoslin
Copy link
Author

Looks like the folks at empyrical-reloaded are already tracking this issue: stefan-jansen/empyrical-reloaded#32

I've installed numpy==1.26.4 and it seems to work fine. This might be a good workaround until empyrical pushes a fix.

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