TVM solve for interest rate, revisited
|
06-21-2022, 04:40 PM
(This post was last modified: 06-29-2022 02:56 PM by Albert Chan.)
Post: #20
|
|||
|
|||
RE: TVM solve for interest rate, revisited
(06-18-2022 11:03 PM)Thomas Okken Wrote: Albert, thank you very much for these algorithms! TVM improvement nicely remove the need for iterator, using counter to ensure 2 f's before rate search. Here is an updated Python find_rate(), using sentinel values, instead of counter. Code: def find_rate(n, pv, pmt, fv, i=None, verbose=False): Above relied on IEEE-754 NaN special propety: (NaN != x) returns True; all other kinds of NaN comparisons returns False. We could also remove NaN's ahead of time, using function math.isnan() Code: from math import isnan Udpate: using counter is shorter and simpler Code: def find_rate(n, pv, pmt, fv, i=None, verbose=False, c=2): |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)