Source language: Translate to:

IRR Function

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

IRR Function

Postby dcaqu » Sun Nov 19, 2006 12:28 pm

Hi,
We're developing a set of financial calculators for use in a training course which include PV and IRR. The current IRR solution uses a PV function already developed and then solves by interpolation (using the user's input) for zero NPV. So we get the user to calculate two NPV values using the PV calculator one just positve and one just negative of the investment amount and then solve by the formula:

IRR = lo hrate + ((lo hrateNPV/lo hrateNPV + hi hrateNPV)*(hi hrate- lo hrate))

where hrate = the hurdle rate

This gives us a usable estimate of the IRR, however we would like to calculate it more accurately so before we reinvent the wheel we thought we'd check if anyone out there has done it before in NB5?

regards
dave :D
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.

Postby Sam Cox » Mon Nov 20, 2006 5:25 am

Don't know if this will help or not, but ...

The hpwNewLisp plug-in provides access to all of newLisp's built-in financial functions including 'irr'. From the newLisp help file:
irr

syntax: (irr list-amounts [list-times [num-guess]])

Calculate the internal rate of return of a cash flow per time period. The internal rate of return is the interest rate that makes the present value of a cash flow equal to 0.0 (zero). In-flowing (negative values) and out-flowing (positive values) amounts are specified in list-amounts. If no time periods are specified in list-times, amounts in list-amounts correspond to consecutive time periods increasing by 1 (1, 2, 3—). The algorithm used is iterative, with an initial guess of 0.5 (50 percent). Optionally, a different initial guess can be specified. The algorithm returns when a precision of 0.000001 (0.0001 percent) is reached. nil is returned if the algorithm cannot converge after 50 iterations.

irr is often used to decide between different types of investments.

example:
(irr '(-1000 500 400 300 200 100))
→ 0.2027

(npv 0.2027 '(500 400 300 200 100))
→ 1000.033848 ; ~ 1000

(irr '(-1000 500 400 300 200 100) '(0 3 4 5 6 7))
→ 0.0998

(irr '(-5000 -2000 5000 6000) '(0 3 12 18))
→ 0.0321

If an initial investment of 1,000 yields 500 after the first year, 400 after two years, and so on, finally reaching 0.0 (zero) after five years, then that corresponds to a yearly return of about 20.2 percent. The next line demonstrates the relation between irr and npv. Only 9.9 percent returns are necessary when making the first withdrawal after three years.

In the last example, securities were initially purchased for 5,000, then for another 2,000 three months later. After a year, securities for 5,000 are sold. Selling the remaining securities after 18 months renders 6,000. The internal rate of return is 3.2 percent per month, or about 57 percent in 18 months.

See also the fv, nper, npv, pmt, and pv functions.
User avatar
Sam Cox
 
Posts: 768
Joined: Fri Apr 01, 2005 7:30 am
Location: Loveland CO USA

Postby dcaqu » Mon Nov 20, 2006 10:26 am

Many thanks Sam,
We'll look into the plug in as you suggest.

Ciao!
Dave :D
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.

hpwNewLISP

Postby dcaqu » Mon Nov 20, 2006 10:57 am

Hi,
We downloaded the hpwNewLISP plug-in but it's not intuitive how to use it is there a help file anywhere or other driving instructions? Also there's lots of files in the download zip file apart from the NeoBook plugin are we supposed to have them in a specific folder (NeoBook?) in order for it all to work? Finally there's a NeoSoftware runtime plug-in does this need to be distributed with any compiled pub that uses the plug-in for it to work?

Thanks in advance for any help or suggestions.
Dave :D
User avatar
dcaqu
 
Posts: 9
Joined: Wed Jun 28, 2006 12:40 am
Location: Worcs U.K.


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests