Using various implementations I found on the net, I came up with a python implementation:
def xirr(transactions): years = [(ta[0] - transactions[0][0]).days / 365.0 for ta in transactions] residual = 1 step = 0.05 guess = 0.05 epsilon = 0.0001 limit = 10000 while abs(residual) > epsilon and limit > 0: limit -= 1 residual = 0.0 for i, ta in enumerate(transactions): residual += ta[1] / pow(guess, years[i]) if abs(residual) > epsilon: if residual > 0: guess += step else: guess -= step step /= 2.0 return guess-1 from datetime import date tas = [ (date(2010, 12, 29), -10000), (date(2012, 1, 25), 20), (date(2012, 3, 8), 10100)] print xirr(tas) #0.0100612640381
source share