Financial Algorithms Cookbook | Time Value of Money

Algorithm: Calculating the Number of Compounding Periods (Payments)

Typical Uses

· To determine the number of periods required for an initial investment to grow to a specified amount · To determine the number of periods it will take to repay a loan.

Ingredients

To calculate the number of compounding periods you will need the following:

  • Present value: The value of the load or investment.
  • Periodic Interest rate: This is the interest rate in terms of the basic compounding period, which may be years, months, days, or any other time period. For example, an annual rate of 6% compounded quarterly would be 6*0.25, 1.5%.
  • Periodic Payment. For simple investments, this could be zero.
  • Future Value: Which in a loan that is paid out completely would be zero, otherwise it could be the final balloon payment. For an investment, this would be the final returned value.
  • Payment Mode: Weather in the payments are done in advance, at the beginning of the compounding period, or in arrears, at the end of the compounding period.
def  numberCompoundingPeriods(i, PV, PMT, FV, inAdv=False):
  i /= 100.0
  spmt = -PMT/i
  if inAdv:
    spmt *= (1.0+i)
  c = spmt – FV
  u = (spmt+PV)/c
  n = log(1.0/u)/log(1.0+i)
  return ceil(n)

Example

You are planning to build an extension for your house. You will need $350,000. The current interest rate for a credit line is 13% but your best friend offers you the loan at 10.5%. You agreed to make $3250 dollar payments at the end of each month, how many payments will be required to pay off this loan?

numberCompundingPeriods(10.5/12, 350000, 3250, 0, false)
>> 328.00

References

  • Gallager, T; Andrew Jr., J., Financial Management: Principals and Practices, Upper Saddle River, NJ: Prentice Hall, 1996
  • Kieso, D; Weygandt, Jerry, Intermediate Accounting, 9th Ed., New York, NY:John Wiley & Sons, Inc., 1993
  • BA II Plus Guidebook, Texas Instruments, Inc., 1996
  • HP-12C Business Calculator Owner's Manual, Hewlett Packard, 1984
  • HP-10B Business Calculator Owner's Manual, Hewlett Packard, 1994