BUG: rate returning incorrect value
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 409
- Forks
- 98
- Avg merge
- 10h 43m
- Merged PRs (30d)
- 12
Description
Describe the issue:
I found a situation where npf.rate is not returning the same thing as my BA II Plus financial calculator or npf.irr. Even setting guess to the correct value does not get the expected answer.
Reproduce the code example:
import numpy_financial as npf
# This returns -1.8964420585461792
npf.rate(8, -440_000, 263_175, 25_500)
# This returns 0.5838779110248231 - Matches financial calculator
npf.irr([-440_000, 263_175, 263_175, 263_175, 263_175, 263_175, 263_175, 263_175, 263_175 + 25_500])
# Still returns -1.8964420585461792
npf.rate(8, -440_000, 263_175, 25_500, 0, 0.5838779110248231)
Error message:
No response
Runtime information:
print(numpy.version)
1.26.4
print(sys.version)
3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 (clang-1500.3.9.4)]
print(numpy.show_runtime())
WARNING: threadpoolctl not found in system! Install it by pip install threadpoolctl. Once installed, try np.show_runtime again for more detailed build information
[{'numpy_version': '1.26.4',
'python': '3.12.3 (main, Apr 9 2024, 08:09:14) [Clang 15.0.0 '
'(clang-1500.3.9.4)]',
'uname': uname_result(system='Darwin', node='HCOB-003406.local', release='23.4.0', version='Darwin Kernel Version 23.4.0: Fri Mar 15 00:12:49 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6020', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}}]
None
Context for the issue:
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the provided npf.rate and npf.irr examples, then inspect the npf.rate entry point and its rate-solving logic. Compare the equation and convergence behavior with npf.irr for these cash flows. Done means the reproduced case returns the expected rate and a regression test covers it.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- fintech-quant
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100