LINEBURG

 << Пред. стр. страница 11(всего 20)ОГЛАВЛЕНИЕ След. стр. >>
exchange rates[i] = uu*exchange rates[iв€’1]; // terminal tree nodes
}
for (i=0; i<=no steps; ++i) call values[i] = max(0.0, (exchange rates[i]в€’K));
for (int step=no stepsв€’1; step>=0; в€’в€’step) {
for (i=0; i<=step; ++i) {
exchange rates[i] = d*exchange rates[i+1];
call values[i] = (pDown*call values[i]+pUp*call values[i+1])*Rinv;
call values[i] = max(call values[i], exchange rates[i]в€’K); // check for exercise
};
};
return call values;
};

Code 9.9: Binomial Currency Option

The program

void test binomial approximations currency options(){
double S = 50.0; double K = 52.0;
double r = 0.08; double rf=0.05;
double sigma = 0.2; double time=0.5;

int no steps = 100;
cout << " european currency option call = "
<< currency option price call american binomial(S,K,r,rf,sigma,time,no steps) << endl;
};

provides the output
european currency option call = 2.23129

Example 9.5: Currency option price

75
9.7 References

The original source for binomial option pricing was the paper by Cox et al. . Good textbook discussions
are in Cox and Rubinstein , Bossaerts and Г˜degaard  and Hull .
Exercise 10.
Consider an European call option on non-dividend paying stock, where S = 100, K = 100, Пѓ = 0.2, (T в€’ t) = 1
and r = 0.1.

1. Calculate the price of this option using Black Scholes
2. Calculate the price using a binomial approximation, using 10, 100 and 1000 steps in the approximation.
3. Discuss what are sources of diп¬Ђerences in the estimated prices.

76
Chapter 10

Finite Diп¬Ђerences
Contents
10.1 Explicit Finite diп¬Ђerences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.2 European Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
10.3 American Options. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79

10.1 Explicit Finite diп¬Ђerences

The method of choice for any engineer given a diп¬Ђerential equation to solve is to numerically approximate it
using a п¬Ѓnite diп¬Ђerence scheme, which is to approximate the continous diп¬Ђerential equation with a discrete
diп¬Ђerence equation, and solve this diп¬Ђerence equation.

10.2 European Options.

For European options we do not need to use the п¬Ѓnite diп¬Ђerence scheme, but we show how one would п¬Ѓnd the
european price for comparison purposes. We show the case of an explicit п¬Ѓnite diп¬Ђerence scheme in code 10.1.
A problem with the explicit version is that it may not converge for certain combinations of inputs.

77
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

double option price put european п¬Ѓnite diп¬Ђ explicit(const double& S,
const double& X,
const double& r,
const double& sigma,
const double& time,
const int& no S steps,
const int& no t steps) {
double sigma sqr = sigma*sigma;
unsigned int M; // need M = no S steps to be even:
if ((no S steps%2)==1) { M=no S steps+1; } else { M=no S steps; };
double delta S = 2.0*S/M;
vector<double> S values(M+1);
for (unsigned m=0;m<=M;m++) { S values[m] = m*delta S; };
int N=no t steps;
double delta t = time/N;

vector<double> a(M);
vector<double> b(M);
vector<double> c(M);
double r1=1.0/(1.0+r*delta t);
double r2=delta t/(1.0+r*delta t);
for (unsigned int j=1;j<M;j++){
a[j] = r2*0.5*j*(в€’r+sigma sqr*j);
b[j] = r1*(1.0в€’sigma sqr*j*j*delta t);
c[j] = r2*0.5*j*(r+sigma sqr*j);
};
vector<double> f next(M+1);
for (unsigned m=0;m<=M;++m) { f next[m]=max(0.0,Xв€’S values[m]); };
double f[M+1];
for (int t=Nв€’1;t>=0;в€’в€’t) {
f=X;
for (unsigned m=1;m<M;++m) {
f[m]=a[m]*f next[mв€’1]+b[m]*f next[m]+c[m]*f next[m+1];
};
f[M] = 0;
for (unsigned m=0;m<=M;++m) { f next[m] = f[m]; };
};
return f[M/2];
};

Code 10.1: Explicit п¬Ѓnite diп¬Ђerences calculation of european put option

78
10.3 American Options.

We now compare the American versions of the same algoritms, the only diп¬Ђerence being the check for exercise
at each point. Code 10.2 shows the code for an american put option.

#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;

double option price put american п¬Ѓnite diп¬Ђ explicit( const double& S,
const double& X,
const double& r,
const double& sigma,
const double& time,
const int& no S steps,
const int& no t steps) {
double sigma sqr = sigma*sigma;

int M; // need M = no S steps to be even:
if ((no S steps%2)==1) { M=no S steps+1; } else { M=no S steps; };
double delta S = 2.0*S/M;
vector<double> S values(M+1);
for (int m=0;m<=M;m++) { S values[m] = m*delta S; };
int N=no t steps;
double delta t = time/N;

vector<double> a(M);
vector<double> b(M);
vector<double> c(M);
double r1=1.0/(1.0+r*delta t);
double r2=delta t/(1.0+r*delta t);
for (int j=1;j<M;j++){
a[j] = r2*0.5*j*(в€’r+sigma sqr*j);
b[j] = r1*(1.0в€’sigma sqr*j*j*delta t);
c[j] = r2*0.5*j*(r+sigma sqr*j);
};
vector<double> f next(M+1);
for (int m=0;m<=M;++m) { f next[m]=max(0.0,Xв€’S values[m]); };
vector<double> f(M+1);
for (int t=Nв€’1;t>=0;в€’в€’t) {
f=X;
for (int m=1;m<M;++m) {
f[m]=a[m]*f next[mв€’1]+b[m]*f next[m]+c[m]*f next[m+1];
f[m] = max(f[m],Xв€’S values[m]); // check for exercise
};
f[M] = 0;
for (int m=0;m<=M;++m) { f next[m] = f[m]; };
};
return f[M/2];
};

Code 10.2: Explicit п¬Ѓnite diп¬Ђerences calculation of american put option

Readings Brennan and Schwartz  is one of the п¬Ѓrst п¬Ѓnance applications of п¬Ѓnite diп¬Ђerences. Section
14.7 of Hull  has a short introduction to п¬Ѓnite diп¬Ђerences. Wilmott et al.  is an exhaustive source
on option pricing from the perspective of solving partial diп¬Ђerential equations.

79
The program

void test explicit п¬Ѓnite diп¬Ђerences(){
double S = 50.0;
double K = 50.0;
double r = 0.1;
double sigma = 0.4;
double time=0.4167;
int no S steps=20;
int no t steps=11;
cout << " explicit finite differences, european put price = ";
cout << option price put european п¬Ѓnite diп¬Ђ explicit(S,K,r,sigma,time,no S steps,no t steps)
<< endl;
cout << " explicit finite differences, american put price = ";
cout << option price put american п¬Ѓnite diп¬Ђ explicit(S,K,r,sigma,time,no S steps,no t steps)
<< endl;
};

provides the output
explicit finite differences, european put price = 4.03667
explicit finite differences, american put price = 4.25085

Example 10.1: Explicit п¬Ѓnite diп¬Ђerences

80
Chapter 11

Option pricing by simulation
Contents
11.1 Simulating lognormally distributed random variables . . . .......... . . 81
11.2 Pricing of European Call options . . . . . . . . . . . . . . . .......... . . 82
11.3 Hedge parameters . . . . . . . . . . . . . . . . . . . . . . . . .......... . . 83
11.4 More general payoп¬Ђs. Function prototypes . . . . . . . . . .......... . . 83
11.5 Improving the eп¬ѓciency in simulation . . . . . . . . . . . . .......... . . 85
11.5.1 Control variates. . . . . . . . . . . . . . . . . . . . . . . . . ........... . . 85
11.5.2 Antithetic variates. . . . . . . . . . . . . . . . . . . . . . . . ........... . . 86
11.5.3 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ........... . . 88
11.6 More exotic options . . . . . . . . . . . . . . . . . . . . . . . .......... . . 90
11.7 Exercises . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .......... . . 90

We now consider using Monte Carlo methods to estimate the price of an European option, and let us п¬Ѓrst
consider the case of the вЂњusualвЂќ European Call, which is priced by the Black Scholes equation. Since there
is already a closed form solution for this case, it is not really necessary to use simulations, but we use the
case of the standard call for illustrative purposes.
At maturity, a call option is worth

cT = max(0, ST в€’ X)

At an earlier date t, the option value will be the expected present value of this.

ct = E[P V (max(0, ST в€’ X)]

Now, an important simplifying feature of option pricing is the вЂњrisk neutral result,вЂќ which implies that we
can treat the (suitably transformed) problem as the decision of a risk neutral decision maker, if we also
modify the expected return of the underlying asset such that this earns the risk free rate.

ct = eв€’r(T в€’t) E в€— [max(0, ST в€’ X)],

where E в€— [В·] is a transformation of the original expectation. One way to estimate the value of the call is
to simulate a large number of sample values of ST according to the assumed price process, and п¬Ѓnd the
estimated call price as the average of the simulated values. By appealing to a law of large numbers, this
average will converge to the actual call value, where the rate of convergence will depend on how many
simulations we perform.

11.1 Simulating lognormally distributed random variables

Lognormal variables are simulated as follows. Let x be normally distributed with mean zero and variance
Лњ
one. If St follows a lognormal distribution, then the one-period-later price St+1 is simulated as
12
St+1 = St e(rв€’ 2 Пѓ )+Пѓx ,
Лњ

or more generally, if the current time is t and terminal date is T , with a time between t and T of (T в€’ t),
в€љ
12
ST = St e(rв€’ 2 Пѓ )(T в€’t)+Пѓ T в€’tЛњ
x

Simulation of lognormal random variables is illustrated by code 11.1.

81
#include <cmath>
using namespace std;
#include "normdist.h"

double simulate lognormal random variable(const double& S, // current value of variable
const double& r, // interest rate
const double& sigma, // volatitily
const double& time) { // time to п¬Ѓnal date
double R = (r в€’ 0.5 * pow(sigma,2) )*time;
double SD = sigma * sqrt(time);
return S * exp(R + SD * random normal());
};

Code 11.1: Simulating a lognormally distributed random variable

11.2 Pricing of European Call options

For the purposes of doing the Monte Carlo estimation of the price if an European call

ct = eв€’r(T в€’t) E[max(0, ST в€’ X)],

note that here one merely need to simulate the terminal price of the underlying, ST , the price of the
underlying at any time between t and T is not relevant for pricing. We proceed by simulating lognormally
distributed random variables, which gives us a set of observations of the terminal price ST . If we let
ST,1 , ST,2 , ST,3 , . . . ST,n denote the n simulated values, we will estimate E в€— [max(0, ST в€’ X)] as the average
of option payoп¬Ђs at maturity, discounted at the risk free rate.
n
в€’r(T в€’t)
max (0, ST,i в€’ X)
ct = e
Л†
i=1

Code 11.2 shows the implementation of a Monte Carlo estimation of an European call option.

#include <cmath> // standard mathematical functions
#include <algorithm> // deп¬Ѓne the max() function
using namespace std;
#include "normdist.h" // deп¬Ѓnition of random number generator

double
option price call european simulated( const double& S, // price of underlying
const double& X, // exercise price
const double& r, // risk free interest rate
const double& sigma, // volatility of underlying
const double& time, // time to maturity (in years)
const int& no sims){ // number of simulations
double R = (r в€’ 0.5 * pow(sigma,2))*time;
double SD = sigma * sqrt(time);
double sum payoп¬Ђs = 0.0;
for (int n=1; n<=no sims; n++) {
double S T = S* exp(R + SD * random normal());
sum payoп¬Ђs += max(0.0, S Tв€’X);
};
return exp(в€’r*time) * (sum payoп¬Ђs/double(no sims));
};

Code 11.2: European Call option priced by simulation

82
11.3 Hedge parameters

It is of course, just as in the standard case, desirable to estimate hedge parameters as well as option prices.
We will show how one can п¬Ѓnd an estimate of the option delta, the п¬Ѓrst derivative of the call price with
respect to the underlying security: в€† = в€‚ct . To understand how one goes about estimating this, let us recall
в€‚S
that the п¬Ѓrst derivative of a function f is deп¬Ѓned as the limit

f (x + h) в€’ f (x)
f (x) = lim
h
hв†’0

Thinking of f (S) as the option price formula ct = f (S; X, r, Пѓ, (T в€’ t)), we see that we can evaluate the
option price at two diп¬Ђerent values of the underlying, S and S + q, where q is a small quantity, and estimate
the option delta as

f (S + q) в€’ f (S)
в€†=
q

In the case of Monte Carlo estimation, it is very important that this is done by using the same sequence of
random variables to estimate the two option prices with prices of the underlying S and S + q. Code 11.3
implements this estimation of the option delta. One can estimate other hedge parameters in a simular way.

#include <cmath> // standard mathematical functions
#include <algorithm> // deп¬Ѓne the max() function
using namespace std;
#include "normdist.h" // deп¬Ѓnition of random number generator

double option price delta call european simulated(const double& S,
const double& X,
const double& r,
const double& sigma,
const double& time,
const int& no sims){
double R = (r в€’ 0.5 * pow(sigma,2))*time;
double SD = sigma * sqrt(time);
double sum payoп¬Ђs = 0.0;
double sum payoп¬Ђs q = 0.0;
double q = S*0.01;
for (int n=1; n<=no sims; n++) {
double Z = random normal();
double S T = S* exp(R + SD * Z);
sum payoп¬Ђs += max(0.0, S Tв€’X);
double S T q = (S+q)* exp(R + SD * Z);
sum payoп¬Ђs q += max(0.0, S T qв€’X);
 << Пред. стр. страница 11(всего 20)ОГЛАВЛЕНИЕ След. стр. >>