Example: Bond-Equivalent Yield

The bond-equivalent yield for a 1 year Treasury bill is returned in this example.

import com.imsl.finance.*;
import java.text.*;
import java.util.*;

public class tbilleqEx1 {

    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("7/1/85");
        GregorianCalendar maturity = parse("7/1/86");
        double discount = .05;
        double tbilleq = Bond.tbilleq(settlement, maturity, discount);
        System.out.println("The bond-equivalent yield for the T-bill is "
                + tbilleq);
    }
}

Output

The bond-equivalent yield for the T-bill is 0.05270709977197674
Link to Java source.