package com.imsl.test.example.finance; import com.imsl.finance.*; import java.text.*; import java.util.*; /** *

* Computes the yield of a bond with an odd long first coupon. *

* * This example calculates the yield of an odd long first coupon with the * following settings: *
* * * * * * * * * * *
Settlement11/11/1992
Maturity03/01/2005
Issue date06/15/1992
First Coupon03/01/1993
Rate0.0935
Price112.478106
Redemption Value100.0
Payment FrequencyBond.SEMIANNUAL
Day Count BasisDayCountBasis.BasisActualActual
*
* * @see Code * @see Output */ public class BondYieldEx2 { 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 issue = parse("06/15/1992"); GregorianCalendar firstCoupon = parse("03/01/1993"); double yield = Bond.yield(settlement, maturity, issue, firstCoupon, 0.0935, 112.478106, 100.0, Bond.SEMIANNUAL, DayCountBasis.BasisActualActual); System.out.println("The yield is " + yield); } }