Friday, 2 January 2015

COMPUTATIONAL FINANCE: Internal Rate Of Return for uneven cash flows (The Time Lags).

You wanted to know what was the return of a share last year, but you can not compute it due to dividends?

This is basically a problem of computational finance not one of Economics Engineering nor Financial Mathematics.

There is R, an excellent programming language if you are dealing with statistics and data science....

The following algorithm and source code is a courtesy of Professor Pasquale Cirillo:

#f=function(y) D1*exp(-t0.5*y)+D2*exp(-t1*y)+D3*exp(-t1.5*y)+PT*exp(-T*y)-P0

#uniroot(f,lower=j,upper=k)

This uniroot function is crucial and of capital importance when you are writing the upper and lower values

The following example will clear this up :

On december 18, 2013.  You bought a share of Stock Exchange.  The next 3 dates are dividends and the last date is when you are closing your position...

21.6    18/12/2013
0.78    30/04/2014
0.32    27/06/2014
0.32    31/10/2014
19.2     17/12/2014

Computer work:

f=function(y) 0.78*exp(-133*y)+0.32*exp(-191*y)+0.32*exp(-317*y)+19.2*exp(-365*y)-21.6
uniroot(f,lower=-1,upper=1) 

Your Work:

y=-0.000152587.  This is a daily rate in continuous time .  Year rate= y*365, exp^(-0.055694255)=0.9458283   =>  -1 = -0.0541717

effective rate: -5.41717%

What if...   uniroot(f,lower=-2,upper=2) or -1 and 0 ??

y=-0.0001220703.  This is a daily rate in continuous time. Annual = -0.0445556595

Converting to discrete time =0.9564224-1 = -0.0435776  => -4.35776%

By using a year scale instead of a day scale, the yearly continuous rate is: -0.048047, so thus:
0.953089-1 =-0.046911.  This is -4.6911%

By using interpolation.  Our daily continuous rate is:
-0.0001316 or -4.8034% per year but in discrete time this translates to:  -4.68986189% per year


Your effective IRR will be the third computation....These algorithms can be deployed to compute rates for ventures and other financial vehicles with not regular events


Sources: Pasquale Cirillo at TU Delft and R
              http://pbil.univ-lyon1.fr/Rweb/Rweb.general.html 
(online computations)

No comments:

Post a Comment