Take the 2-minute tour ×
Quantitative Finance Stack Exchange is a question and answer site for finance professionals and academics. It's 100% free, no registration required.

I have built a program that prices financial assets and it does this in part by calculating the IRR. The problem is that it does not run as quickly as I would like it to.

I currently use the Newton-Raphson method of calculating roots of equations, but then switch to the Interval Bisection method after a set number of tries. This is because there is a chance that the Newton-Raphson method cannot find the IRR, for instance, due to asymptotes. My understanding is that the Newton-Raphson method is more efficient for the cases that it actually works with, which is why my system is currently set up like this.

Is there a more efficient formula or algorithm that I can use to calculate the IRR of a financial asset than the ones that I am currently employing? Or, if there is none, is there a way I can change my current order of calculations to make it more efficient?

If you are in need of any of the formulas that I use to actually be written in this question, please let me know. Thank you for your time.

Update

The pricing software that I have designed is a PHP extension written in the C language. This is because it is a web based program. I cannot change languages due to reasons to do with the company that I work for, so, despite them being good suggestions, I cannot use PERL or the Excel IRR function. I didn't mention the languages before as I didn't think that they were too important due to the fact that I am looking for an increase in mathematical efficiency, not computational.

share|improve this question

2 Answers 2

up vote 0 down vote accepted

You could try Brent's method, it works well.

share|improve this answer
    
I have been looking at this and it potentially could be the best solution. I think I will implement this and then do some speed tests, thank you –  Jamie1596 Jul 4 at 15:28

No reputation for comments (sorry). What programming language / libraries are you using?

I think that the Excel library just does 20 iterations.

You might find it useful to look at the Perl module Finance::Math::IRR That particular library uses a secant method. The Gnumeric gnumeric.org apparently uses Newton's.

There is a very short paper by Moten & Thron that offers an improvment to the secant method that they claim is more efficient.

share|improve this answer
    
Sorry, I'll update my question to let you know what technology that I am using. I'll take a look at the Secant method, thanks for that. –  Jamie1596 Jul 4 at 7:52
    
Also, how much do you know about the Secant method? Do you how efficient it is in comparison to the Newton-Raphson method or the Interval Bisection method? –  Jamie1596 Jul 4 at 8:05
    
The question on language/library was not meant to suggest changing anything. Even when you have very compelling reasons to write a routine from scratch it is helpful to use a reference model to verify your results and to make sure that your performance is reasonable. –  Bill Jul 4 at 18:07
    
As a gross generalization, the Secant method is probably a bit faster than Newton-Raphson. However, as a general method for finding roots it is not guaranteed. Brent's method, as suggested by experquiste is guaranteed. –  Bill Jul 4 at 22:29

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.