Closed shrektan closed 2 years ago
Since this is a scheduled cashflow and not periodic, it makes sense to have different IRR %, I am not sure why are you expecting the same results?
I tried it in google sheets to confirm the logic
Ok, I verify that Excel share the same logic that uses 365 to calculate the IRR.
The reason that I proposed this is I'm using this to calculate bond's YTM. Now I think this change probably should not be applied to this function...
I'm going to close this for now. Thanks.
Hi,
When converting date period into year fractions, it uses the simple algo
(days between start_date and end_date) / 365.0
. This actually results in slightly unexpected output when the year is a leap year (like 2020, see the example below).I don't know if it's intended or not.
Is it open to accept other options as the year fraction calculation algo, something similar to 30/365? (See below)
I'm happy to provide a PR if it's ok.
Thanks.
Related Source Code
https://github.com/raymon1/financial/blob/2ea69baf1fb40906f38e456d8c8b51f08f746083/src/scheduled_cashflow/xnpv.rs#L46
https://github.com/raymon1/financial/blob/2ea69baf1fb40906f38e456d8c8b51f08f746083/src/common/utils.rs#L31-L33
Example
Code
Output
I would expect both results are 0.05.
Suggested algo of calculating the year fraction