Skip to content

Instantly share code, notes, and snippets.

@Rots
Rots / xirr.R
Last active August 29, 2015 14:06
#~ Title: XIRR Excel function simulation
#~
#~ Reference 1: XIRR manual - http://office.microsoft.com/en-gb/excel-help/xirr-HP005209341.aspx
#~ Reference 2: How to calculate IRR manually - http://www.s-anand.net/Calculating_IRR_manually.html
#~
#~ Step 1: enter zeroes (0) against dates that do not have any cash outflow or inflows.
#~ Step 1bis: calculate IRR for these cash flow values using normal IRR function.
#~ Step 1tris: or using an iteractive approach as bisection method to find the NPV zeroes.
#~ Step 2: multiply this value of IRR by 365 to get annual IRR (since, these are daily cash flows).
#~ Step 3: refine using the formula =( 1+ R / 365) ^ 365 - 1), where R is the the value obtained in Step2.