JXIRR –Excel Compatible XIRR Implementation in Java.
XIRR is a Microsoft Excel compatible implementation of the XIRR algorithm in Java. I implemented it for my personal use in tracking my investments. Subsequently I decided to release the source code under the LGPL.
JXIRR 1.0.0 is released under the LGPL. That means you can download it,use it and freely distribute it.
Suggestions,flames to Gautam Satpathy (gautam AT satpathy DOT org).
Downloads
The code has been tested on Windows XP Professional. The source code package above does not install a JRE. You will need to download and install your own JRE/JDK (Java 5 Required).
Example Usage!
The JXIRR source is commented and comes with a small test program called TestXIRR.java under the in.satpathy.financial package.
public static void main( String[] args ){log( Testing XIRR... ) ;// GregorianCalendar dateStart = new GregorianCalendar( 1899,11,30 ) ;GregorianCalendar dateEnd = new GregorianCalendar( 2005,9,20 ) ;int daysBetween = XIRRData.getExcelDateValue( dateEnd ) ;log( Days Between = + daysBetween ) ;// Let us assume that the cells A1:A5 contain the numbers -6000,// 2134,1422,1933,and 1422,and the cells B1:B5 contain the// dates "1999-01-15","1999-04-04","1999-05-09",// "2000-03-12",and "2000-05-1". Then=// XIRR(A1:A5,B1:B5) returns 0.224838.double[] values = new double[5] ;double[] dates = new double[5] ;values[0] = -6000 ;values[1] = 2134 ;values[2] = 1422 ;values[3] = 1933 ;values[4] = 1422 ;dates[0] = XIRRData.getExcelDateValue( new GregorianCalendar(1999,0,15) ) ;dates[1] = XIRRData.getExcelDateValue( new GregorianCalendar(1999,3,4) ) ;dates[2] = XIRRData.getExcelDateValue( new GregorianCalendar(1999,4,9) ) ;dates[3] = XIRRData.getExcelDateValue( new GregorianCalendar(2000,2,12) ) ;dates[4] = XIRRData.getExcelDateValue( new GregorianCalendar(2000,4,1) ) ;XIRRData data = new XIRRData( 5,0.3,values,dates ) ;double xirrValue = XIRR.xirr(data ) ;log( XIRR = + xirrValue ) ;log( XIRR Test Completed... ) }Update Plans
June 2,2008
People have reported various scenarios under which JXIRR fails to reach a solution or reports an incorrect result. I plan to rework JXIRR to fix some of these bugs as soon as I can,perhaps in the next month or so.
Ports
Microsoft .NET Port
Chanan Tomer of Israel has ported JXIRR to .NET and has made it available to the community. Please contact Chanan at chanan @ vcmsoftware . com for details.
Download the .NET version – XIRR.rar or XIRR.zip.
Thanks Chanan!

