Closed bstpierre closed 3 years ago
The Pmt function returns NaN when rate is zero, but it should return a value.
package main import ( "fmt" gof "github.com/razorpay/go-financial" ) func main() { pmt := gof.Pmt(0, 120, 0, 120, 1) fmt.Printf("pmt is %f\n", pmt) // Should return -10 // e.g. from numpy: // >>> numpy.pmt(0, 120, 0, 1200, 1) // -10.0 }
Note that numpy_financial handles the zero-rate case explicitly: https://github.com/numpy/numpy-financial/blob/master/numpy_financial/_financial.py#L239
Hey @bstpierre, Thanks for bringing this up. Sorry, I somehow missed it. I have raised a PR to fix this now.
The Pmt function returns NaN when rate is zero, but it should return a value.
Note that numpy_financial handles the zero-rate case explicitly: https://github.com/numpy/numpy-financial/blob/master/numpy_financial/_financial.py#L239