Example: Year Fraction
The year fraction of a 30/360 year starting 8/1/85 and ending 7/1/86 is returned in this example.
using System;
using Imsl.Finance;
public class yearfracEx1
{
public static void Main(String[] args)
{
DateTime start = DateTime.Parse("8/1/85");
DateTime end = DateTime.Parse("7/1/86");
DayCountBasis dcb = DayCountBasis.BasisNASD;
double yearfrac = Bond.Yearfrac(start, end, dcb);
Console.Out.WriteLine("The year fraction of the 30/360 period "
+ "is " + yearfrac);
}
}
Output
The year fraction of the 30/360 period is 0.916666666666667
Link to C# source.