Skip to content

Financial function nper() incorrect for zero-rate annuities. #16

@adamrogoyski

Description

@adamrogoyski

When rate=0.0, the sign on present value is wrong, causing most degenerate cases to be incorrect.

As an example, making periodic payments of $10 for a $100 loan at progressively smaller interest rates shows the number of periods approaching 10:

numpy.nper(0.01, -10, 100, 0)
10.588644459423231

numpy.nper(0.001, -10, 100, 0)
10.055360184319873

numpy.nper(0.0001, -10, 100, 0)
10.005503577667028

numpy.nper(0.00001, -10, 100, 0)
10.000550035678859

numpy.nper(0.000001, -10, 100, 0)
10.000055001142128

If the interest rate is 0%, it should be exactly 10 payments, not -10:

numpy.nper(0, -10, 100, 0)
-10.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions