Financial Algorithms Cookbook | Time Value of Money

Cash Flow Algorithms

Cash flow analysis is an extension of the basic TVM concepts applied to compound interest problems when payments occur in regular periods and do not have the same value. Any financial investment can be represented as an initial investment of money and a series of cash flows that occur in regular periods of time. Each flow of money can be positive (received) or negative (paid out) and considered as a cash flow. Common cash flow problems usually involve the calculation of the Internal Rate of Return (IRR) or the Net Present Value (NPV).

Present Value Of a Series of Cashflows

The PV expresses the summation of t the present value of each anticipated cash flow calculated to the time it occured. Hence http://finance.bi.no/~bernt/gcc_prog/recipes/recipes/img20.png

Where:

  • Ct is the cashflow at time t.
  • Pt is the price one would pay today for the right to recive one dollar at a future date t.

Obtaining the value of Pt is not always practicle. A typical solution is to use a flat term structure, that is calculate the cash flows based on one interest rate from the time of the initial investment, the Discount Factor:

http://finance.bi.no/~bernt/gcc_prog/recipes/recipes/img23.png

So the Present Value is:

http://finance.bi.no/~bernt/gcc_prog/recipes/recipes/img24.png

To work out the Net Present Value, all you have to do is include the initial investment as cashflow C0.

Putting it all togeather gives us the below algorithm.

def  cashFlowPV(i, cashFlows):
    discountFactor = 1+i/100.0
    Pt = 1.0
    pv =cashFlows[0]
    for Ct in cashFlows[1:]:
        Pt *=  discountFactor 
        pv += Ct/Pt
    return pv

Example

You want to invest in development project that will return over 15%. You find a building that will cost 3.7 million, and will take a year to convert into appartments costing 1.2m. You would like to rent it for four years before selling it at 9.2 million.

C0C1C2C3C4C5C6
PurchaseRefurbish costsNet RentNet RentNet RentNet RentSold
3.7m1.2m300k315k330K347k9.2m
cashflows = [-3700000,-1200000,300000,315000,330000,347000,9200000]
i = 15
cashFlowPV(i, cashflows )
>>29,095.23

Thats good, but you now been offered by a friend a proposition of 15.8% for a similar investment.

i = 15.8
cashFlowPV(i, cashflows )
>>-144165.55

Clearly your friends investment is a better choice.

References

  • Gallager, T; Andrew Jr., J., Financial Management: Principals and Practices, Upper Saddle River, NJ: Prentice Hall, 1996
  • HP-12C Business Calculator Owner's Manual, Hewlett Packard, 1984
  • HP-10B Business Calculator Owner's Manual, Hewlett Packard, 1994