Example: Interest Rate of a Fully Invested Security
The discount rate of a 10 year bond is returned in this example.
using System;
using Imsl.Finance;
public class intrateEx1
{
public static void Main(String[] args)
{
DateTime settlement = DateTime.Parse("7/1/85");
DateTime maturity = DateTime.Parse("7/1/95");
double investment = 7000.0;
double redemption = 10000.0;
DayCountBasis dcb = DayCountBasis.BasisActual365;
double intrate = Bond.Intrate(settlement, maturity, investment,
redemption, dcb);
Console.Out.WriteLine("The interest rate of the bond is " +
intrate);
}
}
Output
The interest rate of the bond is 0.0428336723517446
Link to C# source.