package com.imsl.test.example.finance;
import com.imsl.finance.*;
import java.text.*;
import java.util.*;
/**
*
* Computes the price of a bond with an odd short last coupon
* and multiple coupon periods.
*
* This example calculates the price of an odd short last coupon with multiple
* coupon period to redemption.
*
*
* Settlement | 02/25/1993 |
* Maturity | 06/01/2005 |
* Last Coupon | 12/15/2004 |
* Rate | 0.06875 |
* Yield | 0.0725 |
* Redemption Value | 100.0 |
* Payment Frequency | Bond.SEMIANNUAL |
* Day Count Basis | DayCountBasis.Basis30e360 |
*
*
*
* @see Code
* @see Output
*
*/
public class BondPriceEx6 {
static final DateFormat dateFormat
= DateFormat.getDateInstance(DateFormat.SHORT, Locale.US);
static private GregorianCalendar parse(String s) throws ParseException {
GregorianCalendar cal = new GregorianCalendar();
cal.setTime(dateFormat.parse(s));
return cal;
}
public static void main(String args[]) throws ParseException {
GregorianCalendar settlement = parse("02/25/1993");
GregorianCalendar maturity = parse("06/01/2005");
GregorianCalendar lastCoupon = parse("12/15/2004");
double price = Bond.price(settlement, maturity, lastCoupon, 0.06875,
0.0725, 100.0, Bond.SEMIANNUAL,
DayCountBasis.Basis30e360);
System.out.println("The price is " + price);
}
}