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

NPV giving wrong results #1

Open
ajinkya976 opened this issue Nov 14, 2020 · 1 comment
Open

NPV giving wrong results #1

ajinkya976 opened this issue Nov 14, 2020 · 1 comment

Comments

@ajinkya976
Copy link

ajinkya976 commented Nov 14, 2020

Hi,

For below calculations NPV is giving wrong results.

print(Finance.npv(rate: 0.05, values: <num>[1500, 2500, 3500, 4500, 6000]));

Answer through above code is : 15879.03959769849

But the correct answer is : 15122.89

npv calc

bkbonner added a commit to bkbonner/finance that referenced this issue Dec 3, 2021
@bkbonner
Copy link

bkbonner commented Dec 3, 2021

Yep, you're correct. It's because the author was using index for the time period (which is zero based in his code), but needs to have 1 added to correctly calculate the NPV.

I added a pull request to add null safety and to fix the NPV calculation and tests

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

2 participants