# Homework 2 Simple Binomial Interest Option Pricing Model

## Computational Finance

Scenario You are managing a fixed-income portfolio, and you would like to explore adding value by selling interest rate caps and related products to corporations whose management would like to hedge some interest rate risk. To evaluate these deals, you require a valuation of caps, floors, and collars.

Action You will be given a program that uses a binomial option pricing model to price caps. You will modify the program to value floors as well.

Concept This problem set illustrates the versatility of the binomial model and in particular its usefulness in valuing interest-dependent claims. You will be making more extensive changes than in the previous homeworks.

Instructions

1. Put the program file Caplet.java and the associated HTML file Caplet.html in a directory on your machine where you want to work. Compile the program and run it, trying different values for the current interest rate and the capped level.
2. Modify the program to include inputs for the various parameters that now are set only in the constructor of F_I_bin. To do this, you will need TextFields for the new inputs, a new method in F_I_bin that can be used to set the values, and a call to the new method from the applet's recalc method.
3. Write new public methods for the class F_I_bin that can be used to value floors. The new method will be very similar to the existing method cap. Provide for floor valuation in the applet.
4. Thought question How might a CFO of a publicly traded corporation use this sort of program?

Extra for Experts

1. Write a member function to evaluate a collar, which is the difference between a cap and a floor. Two possible approaches are: using the existing cap and floor functions (quickest to program) and as a standalone function modeled after the cap function (quickest to run).
2. Write a member function that is like a cap but that only pays 1/2 of the additional interest above some level. (For example, it might pay the full excess interest above 5.5% up to 7.5% and then only half the additional amount above that.)

Challenger

Often we want to know what setting of cap and floor will make a collar a fair trade. Write a program that can be given the cap value and will find the floor value that makes the collar a fair deal without any up-front transfer (i.e. gives it a price of zero).

Program Files

Conceptually, the binomial model in this Homework is almost identical to the binomial model in Homework 1. However, the underlying variable that is changing through the binomial tree is the short-maturity interest rate rather than a stock price. Because the interest rate is varying through the tree, so is the one-period discount factor used to compute the prices of up- and down-states.

Exhibit A: the HTML file Caplet.html

<HTML>
<TITLE>Binomial Cap Pricing Program</TITLE>
<BODY>
<APPLET CODE=Caplet.class WIDTH=400 HEIGHT=100>
</APPLET>
</BODY>
</HTML>

Exhibit B: the program file Caplet.java

//
// Fixed income binomial cap pricing applet
//
import java.applet.*;
import java.awt.*;

public class Caplet extends Applet {
F_I_bin c2;
double caprate,rzero;
Label capval;
TextField interest_rate, capped_level;
public Caplet() {
setLayout(new GridLayout(3,2));
add(new Label("Cap value (per \$100 face) ="));
c2 = new F_I_bin((double) 2.0, (int) 24, (double) 0.01, (double) 0.05,
(double) 0.125, (int) 5001);
recalc();}
public boolean action(Event ev, Object arg) {
if(ev.target instanceof TextField) {
recalc();
return true;}
return false;}
double text2double(TextField tf) {
return Double.valueOf(tf.getText()).doubleValue();}
void recalc() {
capval.setText(String.valueOf((float) (100 * c2.cap(text2double(capped_level)/100.0,
text2double(interest_rate)/100.0))));}}
//
// Fixed-income binomial option pricing engine
//

class F_I_bin {
int nper;
double tinc,up,down,sigma,rbar,kappa,prfact;
double [] r,val;

public F_I_bin(double ttm,int nper,double sigma,double rbar,double kappa,
int maxternodes) {
this.nper=nper;
tinc = ttm/(double) nper;
this.sigma = sigma;
up = sigma*Math.sqrt(tinc);
this.rbar = rbar;
this.kappa = kappa;
prfact = kappa*Math.sqrt(tinc)/(2.0*sigma);
val = new double[maxternodes];
r = new double[maxternodes];}

double bprice(double r0) {
int i,j;
double prup;
//initialize terminal payoffs
//i is the number of up moves
for(i=0;i<=nper;i++) {
//  r[i] = r0 + up * (double)(2*i-nper);   not needed for this claim
val[i] = 1.0;}
//compute prices back through the tree
//j is the number of periods from the end
//i is the number of up moves from the start
for(j=1;j<=nper;j++) {for(i=0;i<=nper-j;i++) {
r[i] = r0 + up * (double) (2*i-nper + j);
prup = 0.5 + prfact*(rbar-r[i]);
prup = Math.min((double) 1.0,Math.max((double) 0.0,prup));
val[i] = (prup*val[i+1]+(1.0-prup)*val[i])*Math.exp(-r[i]*tinc);}}
return(val[0]);}

double cap(double level,double r0) {
int i,j;
double prup;
//initialize terminal payoffs
//i is the number of up moves
for(i=0;i<=nper;i++) {
//  r[i] = r0 + up * (double)(2*i-nper);   not needed for this claim
val[i] = 0.0;}
//compute prices back through the tree
//j is the number of periods from the end
//i is the number of up moves from the start
for(j=1;j<=nper;j++) {for(i=0;i<=nper-j;i++) {
r[i] = r0 + up * (double) (2*i-nper + j);
prup = 0.5 + prfact*(rbar-r[i]);
prup = Math.min((double) 1.0,Math.max((double) 0.0,prup));
val[i] = (prup*val[i+1]+(1.0-prup)*val[i])*Math.exp(-r[i]*tinc)
+ Math.max((double) 0.0,(r[i]-level)*tinc);}}
return(val[0]);}}