Example: Internal Rate of Return - Variable Schedule
A farmer buys 10 young cows and a bull for $4500. The first year he does not expect to sell any calves, he just expects to feed them. Thereafter, he expects to be able to sell calves to offset the cost of feed. He expects them to be productive for 9 years, after which time he will liquidate the herd. The internal rate of return is computed after 9 years.
using System;
using Imsl.Finance;
public class xirrEx1
{
public static void Main(String[] args)
{
double[] pmt = new double[]{- 4500.0, - 800.0,
800.0, 800.0,
600.0, 600.0,
800.0, 800.0,
700.0, 3000.0};
System.DateTime[] dates =
new System.DateTime[]{DateTime.Parse("1/1/98"),
DateTime.Parse("10/1/98"),
DateTime.Parse("5/5/99"),
DateTime.Parse("5/5/00"),
DateTime.Parse("6/1/01"),
DateTime.Parse("7/1/02"),
DateTime.Parse("8/30/03"),
DateTime.Parse("9/15/04"),
DateTime.Parse("10/15/05"),
DateTime.Parse("11/1/06")};
double xirr = Finance.Xirr(pmt, dates);
Console.Out.WriteLine("After approximately 9 years, the " +
"internal rate of return \n" +
"on the cows is " + xirr.ToString("P"));
}
}
Output
After approximately 9 years, the internal rate of return
on the cows is 7.69 %
Link to C# source.