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 short last coupon and one or fewer
* coupon periods.
*
* This example calculates the yield of an odd short last coupon with one or
* less coupon period to redemption.
*
*
* Settlement | 02/07/1993 |
* Maturity | 08/01/1993 |
* Last Coupon | 02/04/1993 |
* Rate | 0.065 |
* Price | 100.540457 |
* Redemption Value | 100.0 |
* Payment Frequency | Bond.SEMIANNUAL |
* Day Count Basis | DayCountBasis.Basis30e360 |
*
*
*
* @see Code
* @see Output
*
*
*/
public class BondYieldEx7 {
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("08/01/1993");
GregorianCalendar lastCoupon = parse("02/04/1993");
double yield = Bond.yield(settlement, maturity, lastCoupon, 0.065,
100.540457, 100.0, Bond.SEMIANNUAL,
DayCountBasis.Basis30e360);
System.out.println("The yield is " + yield);
}
}