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 last coupon and * one coupon period.

* * This example calculates the yield of an odd long last coupon with one coupon * period to redemption. *
* * * * * * * * * *
Settlement02/07/1993
Maturity06/15/1993
Last Coupon10/15/1992
Rate0.0375
Price99.878286
Redemption Value100.0
Payment FrequencyBond.SEMIANNUAL
Day Count BasisDayCountBasis.Basis30e360
*
* @see Code * @see Output */ public class BondYieldEx4 { 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/07/1993"); GregorianCalendar maturity = parse("06/15/1993"); GregorianCalendar lastCoupon = parse("10/15/1992"); double yield = Bond.yield(settlement, maturity, lastCoupon, 0.0375, 99.878286, 100.0, Bond.SEMIANNUAL, DayCountBasis.Basis30e360); System.out.println("The yield is " + yield); } }