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:
*
*
* Settlement | 11/11/1992 |
* Maturity | 03/01/2005 |
* Issue date | 06/15/1992 |
* First Coupon | 03/01/1993 |
* Rate | 0.0935 |
* Price | 112.478106 |
* Redemption Value | 100.0 |
* Payment Frequency | Bond.SEMIANNUAL |
* Day Count Basis | DayCountBasis.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);
}
}