Example: Bond Price - Odd Long Last Coupon
This example calculates the price of an odd long last coupon with one coupon period to redemption. Settlement |
02/07/1993 |
Maturity |
06/15/1993 |
Last Coupon |
10/15/1992 |
Rate |
0.0375 |
Yield |
0.0405 |
Redemption Value |
100.0 |
Payment Frequency |
Bond.SEMIANNUAL |
Day Count Basis |
DayCountBasis.Basis30e360 |
import com.imsl.finance.*;
import java.text.*;
import java.util.*;
public class OddLongLastOneCoupPriceEx {
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 price = Bond.price(settlement, maturity, lastCoupon, 0.0375,
0.0405, 100.0, Bond.SEMIANNUAL,
DayCountBasis.Basis30e360);
System.out.println("The price is " + price);
}
}
Output
The price is 99.87828601472134
Link to Java source.