Skip to content

Commit

Permalink
fix(stats.py): handle numpy version compatibility issue by using np.p…
Browse files Browse the repository at this point in the history
…rod instead of np.product to calculate expected return
  • Loading branch information
petercool committed Oct 12, 2024
1 parent fa0a91a commit df04d85
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion quantstats/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ def expected_return(returns, aggregate=None, compounded=True, prepare_returns=Tr
if prepare_returns:
returns = _utils._prepare_returns(returns)
returns = _utils.aggregate_returns(returns, aggregate, compounded)
return _np.product(1 + returns) ** (1 / len(returns)) - 1
if _np.__version__.startswith("1."):
return _np.product(1 + returns) ** (1 / len(returns)) - 1
return _np.prod(1 + returns) ** (1 / len(returns)) - 1


def geometric_mean(retruns, aggregate=None, compounded=True):
Expand Down

0 comments on commit df04d85

Please sign in to comment.