XIRR

Post your tools and samples or ask for them.
FRBhote
India
Posts: 127
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

XIRR

Post by FRBhote » 21 Dec 2017, 07:43

Is there nay tool to do an IRR / XIRR calculation in TD?

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 691
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

XIRR

Post by Dave Rabelink » 21 Dec 2017, 08:13

Would indeed be nice if someone has these functions implemented.

If MS Office is part of the install base of your applications, you can use the Excel library to use those functions.

If not, you might implement your own functions in TD. There are several examples in Java/C++/C# and rewrite the formulas in TD.

Here some examples:
https://gist.github.com/ghalimi/4669712
https://stackoverflow.com/questions/517 ... alculation
https://www.codeproject.com/Tips/461049 ... alculation
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Jeff Luther
Site Admin
Site Admin
United States of America
Posts: 148
Joined: 04 Mar 2017, 18:34
Location: Palm Springs, California

XIRR

Post by Jeff Luther » 21 Dec 2017, 17:19

FR - Dave's link to the codeproject page (the third link down in his reply) looks to me to be a good start for transliterating the formula from C/C++ to SAL, if that's what you decide to do.

I also found a web page (in English) that seems to have a good overview and explanation for what the IRR calcuation does:
http://www.investinganswers.com/financi ... n-irr-2130
And a write-up on the difference between XIRR and IRR: https://www.asimplemodel.com/reference/ ... vs-%3Dirr/

FYI, I did something like this years ago to get the RIPEMD-160 message hash encryption algorithm to work in SAL. The test APP file in the RIPEMD-160 zip in my samples section, available here: http://www.jeffluther.net/TD/#Code_Samples
has info. in the APP Description about where the original C source came from.
Jeff Luther @ PC Design
Palm Springs, California
TD info. & samples: http://www.jeffluther.net/TD/

FRBhote
India
Posts: 127
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

XIRR

Post by FRBhote » 22 Dec 2017, 04:36

Yup. The third one looks good. Let me try it out.

FRBhote
India
Posts: 127
Joined: 09 Mar 2017, 05:32
Location: Hyderabad, India

XIRR

Post by FRBhote » 02 Jan 2018, 07:31

Tried using https://www.codeproject.com/Tips/461049 ... alculation in TD. For 6 elements in the array, I get 8.6% as compared to Excel 9%.

But when I reduce the elements to 5 or less I always get 1%. Wonder where I am wrong.
You do not have the required permissions to view the files attached to this post.

Dave Rabelink
Founder/Site Admin
Founder/Site Admin
Netherlands
Posts: 691
Joined: 24 Feb 2017, 09:12
Location: Gouda, The Netherlands

XIRR

Post by Dave Rabelink » 02 Jan 2018, 08:54

I'm surely not a financial expert, so the meaning of this is above my head ;)

But what I see is that your implementation seems to be conform the sample.
I run the original c++ sample in visual studio and get the same results there compared to TD. Also when passing less numofflows.

But maybe you have to read this, which explains the several different ways to calculate it and indicates there is no real correct way to calculate:

http://www.corality.com/tutorials/calculate-irr-excel

(seems the IRR Excel function is to be avoided)
Regards,
Dave Rabelink

Image
Articles and information on Team Developer Tips & Tricks Wiki
Download samples, documents and resources from TD Sample Vault
Videos on TDWiki YouTube Channel

Return to “Tools & Samples”

Who is online

Users browsing this forum: [Ccbot] and 0 guests