Thursday, September 19, 2019

programming - What is the Most Efficient Way to Calculate the Internal Rate of Return IRR?


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.



Answer



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


No comments:

Post a Comment

technique - How credible is wikipedia?

I understand that this question relates more to wikipedia than it does writing but... If I was going to use wikipedia for a source for a res...