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 first * coupon. *

* * This example calculates the price of an odd short first coupon with the * following settings: * * * * * * * * * * *
Settlement11/11/1992
Maturity03/01/2005
Issue date10/15/1992
First Coupon03/01/1993
Rate0.0785
Yield0.0625
Redemption Value100.0
Payment FrequencyBond.SEMIANNUAL
Day Count BasisDayCountBasis.BasisActualActual
* * @see Code * @see Output */ public class BondPriceEx5 { 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("11/11/1992"); GregorianCalendar maturity = parse("03/01/2005"); GregorianCalendar issueDate = parse("10/15/1992"); GregorianCalendar firstCoupon = parse("03/01/1993"); double price = Bond.price(settlement, maturity, issueDate, firstCoupon, 0.0785, .0625, 100.0, Bond.SEMIANNUAL, DayCountBasis.BasisActualActual); System.out.println("The price is " + price); } }