alpeb / go-finance

Go library containing a collection of financial functions for time value of money (annuities), cash flow, interest rate conversions, bonds and depreciation calculations.
Mozilla Public License 2.0
177 stars 23 forks source link

Add cashflow ScheduledInternalRateOfReturn #3

Closed brunoyb closed 4 years ago

brunoyb commented 4 years ago

This is the implementation of Excel's XIRR function. It is very similar to IRR, the only difference being that this one takes payment dates into account.

I also took the opportunity to make a small simplification to dNetPresentValue's formula.

See: https://support.office.com/en-us/article/xirr-function-de1242ec-6477-445b-b11b-a303ad9adc9d See: https://support.office.com/en-us/article/xnpv-function-1b42bbf6-370f-4532-a0eb-d67c16b664b7

brunoyb commented 4 years ago

Hi! I found your library and it is very useful, thank you! I also needed the XIRR function, so I decided to contribute it, so here is my implementation.

Feel free to comment on anything you think should be changed.

Thanks again for creating this library!

alpeb commented 4 years ago

Thank you so much @brunoyb ! I'll be taking a look in the next couple of days :+1:

brunoyb commented 4 years ago

Oh, and I forgot to mention, I based this implementation on this Rust version: https://github.com/cskr/xirr/blob/master/src/lib.rs I tried to make the necessary changes to follow the patterns of your project.

rv-vsilva commented 4 years ago

+1

brunoyb commented 4 years ago

Hey! Awesome! Glad I could help!