Example: Treasury Bill Yield
The yield for a 1 year Treasury bill is returned in this example.
using System;
using Imsl.Finance;
public class tbillyieldEx1
{
public static void Main(String[] args)
{
DateTime settlement = DateTime.Parse("7/1/85");
DateTime maturity = DateTime.Parse("7/1/86");
double price = 94.93;
double tbillyield = Bond.Tbillyield(settlement, maturity, price);
Console.Out.WriteLine("The yield for the T-bill is " +
tbillyield.ToString("P"));
}
}
Output
The yield for the T-bill is 5.27 %
Link to C# source.