Skip to content

BUG: make ipmt return nan for per < 1 #22

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

Merged
merged 2 commits into from
Oct 30, 2019
Merged

Conversation

person142
Copy link
Member

@person142 person142 commented Oct 29, 2019

As stated in the the docs the period count starts at 1, so per < 1
doesn't make sense. The change also agrees with the results of Google
Sheet's IPMT.

Closes gh-17. Note that the suggested fix there appears to be
incorrect-returning 0 for when = 'begin' and per = 1 should
be the correct behavior as no interest has accrued at the beginning
of the first period. (Returning 0 also agrees with IPMT.)

As stated in the the docs the period count starts at 1, so `per < 1`
doesn't make sense. The change also agrees with the results of Google
Sheet's IPMT.

Closes numpygh-17.
Copy link
Member

@Kai-Striega Kai-Striega left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍 - do you intend to add any further changes?

ipmt = np.where(np.logical_and(when == 1, per == 1), 0, ipmt)
except IndexError:
pass
ipmt = np.array(_rbl(rate, per, total_pmt, pv, when) * rate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here and below the logic looks good to me. Having the extra comments is also appreciated. 👍

if isinstance(entry, Decimal):
return Decimal(value)
else:
return value
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should value here be case to the same dtype as entry?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point; fixed.

@person142
Copy link
Member Author

do you intend to add any further changes?

Not here-was planning on refactoring the tests for ppmt in a similar way to the tests for ipmt, but was going to save that for another PR to keep the diff small.

@Kai-Striega Kai-Striega merged commit b4e7a75 into numpy:master Oct 30, 2019
@Kai-Striega
Copy link
Member

Kai-Striega commented Oct 30, 2019

Merged, thanks @person142!

👍 To the ppmt changes being their own PR.

@person142 person142 mentioned this pull request Nov 9, 2019
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

Successfully merging this pull request may close these issues.

Financial functions ipmt and ppmt result in incorrect values for per=1
2 participants