quantstats icon indicating copy to clipboard operation
quantstats copied to clipboard

AttributeError: module 'numpy' has no attribute 'product'

Open justin8shan opened this issue 1 year ago • 3 comments

numpy only has function as of np.prod instead of np.product Which version of numpy is np.product available in?

justin8shan avatar Sep 21 '24 07:09 justin8shan

I had a same issue. Just change line 96 in "stats.py" return _np.product(1 + returns) ** (1 / len(returns)) - 1 -> return _np.prod(1 + returns) ** (1 / len(returns)) - 1

then It'll work again.

i-am-garden avatar Sep 30 '24 05:09 i-am-garden

numpy.product was deprecated in numpy 1.25, with this PR and removed in numpy 2.x. This should be a quick and simple find all and replace, since np.prod has been around since at least numpy 1.7 and the requirements for this package ask for: https://github.com/ranaroussi/quantstats/blob/fa0a91a42400978bcc95f5f2fb2cf20e6f7af56c/requirements.txt#L2

antoniouaa avatar Oct 07 '24 23:10 antoniouaa

I am on numpy 2.1.3, Still getting same error

pranjal5215 avatar Feb 05 '25 11:02 pranjal5215

Since there are several thumbs up on the previous indicating folks are still having trouble, to reiterate: You need to use a version less than 2.0 or switch the calls to np.prod as product doesn't exist in 2.0 or later.

kav avatar Jun 23 '25 19:06 kav

Closing this issue as it's older than 2025 and has been specifically addressed in release 0.0.64. The numpy compatibility layer now handles deprecated functions like np.product → np.prod.

ranaroussi avatar Jul 18 '25 14:07 ranaroussi