Example: Price of a Security
The price per $100 face value of a 10 year bond which pays interest semiannually is returned in this example.
using System;
using Imsl.Finance;
public class priceEx1
{
public static void Main(String[] args)
{
DateTime settlement = DateTime.Parse("7/1/85");
DateTime maturity = DateTime.Parse("7/1/95");
double rate = .06;
double yield = .07;
double redemption = 105.0;
Bond.Frequency freq = Bond.Frequency.SemiAnnual;
DayCountBasis dcb = DayCountBasis.BasisNASD;
double price = Bond.Price(settlement, maturity, rate, yield,
redemption, freq, dcb);
Console.Out.WriteLine("The price of the bond is " +
price.ToString("C"));
}
}
Output
The price of the bond is $95.41
Link to C# source.