BOCh15

# References cox ross and rubinstein 1979 is the general

This preview shows page 1. Sign up to view the full content.

This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ure 15.1 C++ program for an American call option #include #include #include cmath algorithm vector // standard mathematical library // deﬁning the max() operator // STL vector templates double option price call american binomial( double S, // spot price double X, // exercice price double r, // interest rate double sigma, // volatility double t, // time to maturity int steps) { // no steps in binomial tree double R = exp(r*(t/steps)); // interest rate for each step double Rinv = 1.0/R; // inverse of interest rate double u = exp(sigma*sqrt(t/steps)); // up movement double uu = u*u; double d = 1.0/u; double p up = (R d)/(u d); double p down = 1.0 p up; vector double prices(steps+1); // price of underlying vector double call values(steps+1); // value of corresponding call 10 20 prices[0] = S*pow(d, steps); // ﬁll in the endnodes. for (int i=1; i =steps; ++i) prices[i] = uu*prices[i 1]; for (int i=0; i =steps; ++i) call values[i]=max(0.0,(prices[i] X)); // payoﬀ at maturity for (int step=steps...
View Full Document

## This document was uploaded on 02/15/2014 for the course BEM 103 at Caltech.

Ask a homework question - tutors are online