hide long namesshow long names
hide short namesshow short names
Integer type:  int32  int64  nag_int  show int32  show int32  show int64  show int64  show nag_int  show nag_int

PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

NAG Toolbox: nag_pde_1d_blackscholes_closed (d03nd)

Purpose

nag_pde_1d_blackscholes_closed (d03nd) computes an analytic solution to the Black–Scholes equation for a certain set of option types.

Syntax

[f, theta, delta, gamma, lambda, rho, ifail] = d03nd(kopt, x, s, t, tmat, tdpar, r, q, sigma)
[f, theta, delta, gamma, lambda, rho, ifail] = nag_pde_1d_blackscholes_closed(kopt, x, s, t, tmat, tdpar, r, q, sigma)

Description

nag_pde_1d_blackscholes_closed (d03nd) computes an analytic solution to the Black–Scholes equation (see Hull (1989) and Wilmott et al. (1995))
(f)/(t) + (rq) S (f)/(S) + ( σ2 S2 )/2 (2f)/(S2) = rf
f t + (r-q) S f S + σ2 S2 2 2f S2 =rf
(1)
Smin < S < Smax,   tmin < t < tmax,
Smin< S<Smax,   tmin<t< tmax,
(2)
for the value ff of a European put or call option, or an American call option with zero dividend qq. In equation (1) tt is time, SS is the stock price, XX is the exercise price, rr is the risk free interest rate, qq is the continuous dividend, and σσ is the stock volatility. The parameter rr, qq and σσ may be either constant, or functions of time. In the latter case their average instantaneous values over the remaining life of the option should be provided to nag_pde_1d_blackscholes_closed (d03nd). An auxiliary function nag_pde_1d_blackscholes_means (d03ne) is available to compute such averages from values at a set of discrete times. Equation (1) is subject to different boundary conditions depending on the type of option. For a call option the boundary condition is
f (S, t = tmat ) = max (0,SX)
f (S, t = tmat ) = max (0,S-X)
where tmattmat is the maturity time of the option. For a put option the equation (1) is subject to
f (S, t = tmat ) = max (0,XS) .
f (S, t = tmat ) = max (0,X-S) .
nag_pde_1d_blackscholes_closed (d03nd) also returns values of the Greeks
Θ = (f)/(t),   Δ = (f)/(x),   Γ = (2f)/(x2),   Λ = (f)/(σ),   ρ = (f)/(r).
Θ= f t ,   Δ= f x ,   Γ= 2f x2 ,   Λ= f σ ,   ρ= f r .
nag_specfun_opt_bsm_greeks (s30ab) also computes the European option price given by the Black–Scholes–Merton formula together with a more comprehensive set of sensitivities (Greeks).
Further details of the analytic solution returned are given in Section [Algorithmic Details].

References

Hull J (1989) Options, Futures and Other Derivative Securities Prentice–Hall
Wilmott P, Howison S and Dewynne J (1995) The Mathematics of Financial Derivatives Cambridge University Press

Parameters

Compulsory Input Parameters

1:     kopt – int64int32nag_int scalar
Specifies the kind of option to be valued:
kopt = 1kopt=1
A European call option.
kopt = 2kopt=2
An American call option.
kopt = 3kopt=3
A European put option.
Constraints:
  • kopt = 1kopt=1, 22 or 33;
  • if q0q0, kopt2kopt2.
2:     x – double scalar
The exercise price XX.
Constraint: x0.0x0.0.
3:     s – double scalar
The stock price at which the option value and the Greeks should be evaluated.
Constraint: s0.0s0.0.
4:     t – double scalar
The time at which the option value and the Greeks should be evaluated.
Constraint: t0.0t0.0.
5:     tmat – double scalar
The maturity time of the option.
Constraint: tmatttmatt.
6:     tdpar(33) – logical array
Specifies whether or not various parameters are time-dependent. More precisely, rr is time-dependent if tdpar(1) = truetdpar1=true and constant otherwise. Similarly, tdpar(2)tdpar2 specifies whether qq is time-dependent and tdpar(3)tdpar3 specifies whether σσ is time-dependent.
7:     r( : :) – double array
Note: the dimension of the array r must be at least 33 if tdpar(1) = truetdpar1=true, and at least 11 otherwise.
If tdpar(1) = falsetdpar1=false then r(1)r1 must contain the constant value of rr. The remaining elements need not be set.
If tdpar(1) = truetdpar1=true then r(1)r1 must contain the value of rr at time t and r(2)r2 must contain its average instantaneous value over the remaining life of the option:
tmat
= r(ζ)dζ.
t
r^=ttmatr(ζ)dζ.
The auxiliary function nag_pde_1d_blackscholes_means (d03ne) may be used to construct r from a set of values of rr at discrete times.
8:     q( : :) – double array
Note: the dimension of the array q must be at least 33 if tdpar(2) = truetdpar2=true, and at least 11 otherwise.
If tdpar(2) = falsetdpar2=false then q(1)q1 must contain the constant value of qq. The remaining elements need not be set.
If tdpar(2) = truetdpar2=true then q(1)q1 must contain the constant value of qq and q(2)q2 must contain its average instantaneous value over the remaining life of the option:
tmat
= q(ζ)dζ.
t
q^=ttmatq(ζ)dζ.
The auxiliary function nag_pde_1d_blackscholes_means (d03ne) may be used to construct q from a set of values of qq at discrete times.
9:     sigma( : :) – double array
Note: the dimension of the array sigma must be at least 33 if tdpar(3) = truetdpar3=true, and at least 11 otherwise.
If tdpar(3) = falsetdpar3=false then sigma(1)sigma1 must contain the constant value of σσ. The remaining elements need not be set.
If tdpar(3) = truetdpar3=true then sigma(1)sigma1 must contain the value of σσ at time t, sigma(2)sigma2 the average instantaneous value σ̂σ^, and sigma(3)sigma3 the second-order average σσ-, where:
tmat
σ̂ = σ(ζ)dζ,
t
σ^=ttmatσ(ζ)dζ,
σ =
(tmat ) ∫ σ2(ζ)dζt 1 / 2
.
σ-= ( ttmat σ2 (ζ) dζ ) 1/2 .
The auxiliary function nag_pde_1d_blackscholes_means (d03ne) may be used to compute sigma from a set of values at discrete times.
Constraints:
  • if tdpar(3) = falsetdpar3=false, sigma(1) > 0.0sigma1>0.0;
  • if tdpar(3) = truetdpar3=true, sigma(i) > 0.0sigmai>0.0, for i = 1,2,3i=1,2,3.

Optional Input Parameters

None.

Input Parameters Omitted from the MATLAB Interface

None.

Output Parameters

1:     f – double scalar
The value ff of the option at the stock price s and time t.
2:     theta – double scalar
3:     delta – double scalar
4:     gamma – double scalar
5:     lambda – double scalar
6:     rho – double scalar
The values of various Greeks at the stock price s and time t, as follows:
theta = Θ = (f)/(t), delta = Δ = (f)/(s), gamma = Γ = (2f)/(s2) ,
lambda = Λ = (f)/(σ), rho = ρ = (f)/(r).
theta=Θ= f t , delta=Δ= f s , gamma=Γ= 2f s2 , lambda=Λ= f σ , rho=ρ= f r .
7:     ifail – int64int32nag_int scalar
ifail = 0ifail=0 unless the function detects an error (see [Error Indicators and Warnings]).

Error Indicators and Warnings

Errors or warnings detected by the function:
  ifail = 1ifail=1
On entry,kopt < 1kopt<1,
orkopt > 3kopt>3,
orkopt = 2kopt=2 when q0q0,
orx < 0.0x<0.0,
ors < 0.0s<0.0,
ort < 0.0t<0.0,
ortmat < ttmat<t,
orsigma(1)0.0sigma10.0, with tdpar(3) = falsetdpar3=false,
orsigma(i)0.0sigmai0.0, with tdpar(3) = truetdpar3=true, for some i = 1i=1, 22 or 33.

Accuracy

Given accurate values of r, q and sigma no further approximations are made in the evaluation of the Black–Scholes analytic formulae, and the results should therefore be within machine accuracy. The values of r, q and sigma returned from nag_pde_1d_blackscholes_means (d03ne) are exact for polynomials of degree up to 33.

Further Comments

Algorithmic Details

The Black–Scholes analytic formulae are used to compute the solution. For a European call option these are as follows:
f = S e (Tt) N (d1) X e (Tt) N(d2)
f= S e -q^ (T-t) N (d1)- X e -r^ (T-t) N(d2)
where
d1 = (log(S / X) + ( + σ2 / 2)(Tt))/(σsqrt(Tt)),
d2 = (log(S / X) + (σ2 / 2)(Tt))/(σsqrt(Tt)) = d1σsqrt(Tt),
d1 = log(S/X)+(r^-q^+σ-2/2)(T-t) σ-T-t , d2 = log(S/X)+(r^-q^-σ-2/2)(T-t) σ-T-t =d1-σ-T-t,
N(x)N(x) is the cumulative Normal distribution function and N(x)N(x) is its derivative
N(x) =
x
1/(sqrt(2π))eζ2 / 2dζ,
N(x) = 1/(sqrt(2π)) ex2 / 2.
N(x) = 12π -x e-ζ2/2dζ, N(x) = 12π e-x2/2.
The functions q^, r^, σ̂σ^ and σσ- are average values of qq, rr and σσ over the time to maturity:
q̂ = T 1/(T − t) ∫ q(ζ)dζ, t r̂ = T 1/(T − t) ∫ r(ζ)dζ, t σ̂ = T 1/(T − t) ∫ σ(ζ)dζ, t σ =
( T )1/(T − t) ∫ σ2(ζ)dζ t 1 / 2
.
q^ = 1T-t tT q(ζ)dζ, r^ = 1T-t tT r(ζ)dζ, σ^ = 1T-t tT σ(ζ)dζ, σ- = ( 1T-t tT σ2(ζ)dζ) 1/2 .
The Greeks are then calculated as follows:
Δ = (f)/(S) = e(Tt) N(d1) + (Se(Tt) N(d1)Xe(Tt) N(d2))/(σS×sqrt(Tt)),
Γ = (2 f)/(S2) = (Se(Tt) N(d1) + Xe(Tt) N(d2))/(σS2sqrt(Tt)) + (Se(Tt) N(d1)Xe(Tt) N(d2))/(σ2S2(Tt)),
Θ = (f)/(t) = rf + (qr) SΔ(σ2 S2)/2Γ,
Λ = (f)/(σ) = ((X d1 e(Tt) N(d2)S d2 e(Tt) N(d1))/(σ2)) σ̂,
ρ = (f)/(r) = X(Tt) e(Tt) N(d2) + ((Se(Tt)N(d1)Xe(Tt)N(d2)) sqrt(Tt))/(σ).
Δ = f S =e-q^(T-t) N(d1)+ Se-q^(T-t) N(d1)-Xe-r^(T-t) N(d2) σ-ST-t , Γ = 2 f S2 = Se-q^(T-t) N(d1)+Xe-r^(T-t) N(d2) σ-S2T-t + Se-q^(T-t) N(d1)-Xe-r^(T-t) N(d2) σ-2S2(T-t) , Θ = f t =rf+(q-r) SΔ- σ2 S22Γ, Λ = f σ =( X d1 e-r^(T-t) N(d2)-S d2 e-q^(T-t) N(d1) σ-2 ) σ^, ρ = f r =X(T-t) e-r^(T-t) N(d2)+ (Se-q^(T-t) N(d1)-Xe-r^(T-t) N(d2)) T-tσ-.
Note: that ΘΘ is obtained from substitution of other Greeks in the Black–Scholes partial differential equation, rather than differentiation of ff. The values of qq, rr and σσ appearing in its definition are the instantaneous values, not the averages. Note also that both the first-order average σ̂σ^ and the second-order average σσ- appear in the expression for ΛΛ. This results from the fact that ΛΛ is the derivative of ff with respect to σσ, not σ̂σ^.
For a European put option the equivalent equations are:
f = Xe(Tt) N(d2)Se(Tt) N(d1),
Δ = (f)/(S) = e(Tt) N(d1) + (Se(Tt) N(d1)Xe(Tt) N(d2))/(σS×sqrt(Tt)),
Γ = (2f)/(S2) = (Xe(Tt) N(d2) + Se(Tt) N(d1))/(σS2sqrt(Tt)) + (Xe(Tt) N(d2)Se(Tt) N(d1))/(σ2S2(Tt)),
Θ = (f)/(t) = rf + (qr)SΔ(σ2S2)/2Γ,
Λ = (f)/(σ) = ((Xd1 e(Tt) N(d2)S d2 e(Tt) N(d1))/(σ2)) σ̂,
ρ = (f)/(r) = X(Tt) e(Tt) N(d2) + ((Se(Tt)N(d1)Xe(Tt)N(d2)) sqrt(Tt))/(σ̂).
f = Xe-r^(T-t) N(-d2)-Se-q^(T-t) N(-d1), Δ = f S =-e-q^(T-t) N(-d1)+ Se-q^(T-t) N(-d1)-Xe-r^(T-t) N(-d2) σ-ST-t , Γ = 2f S2 = Xe-r^(T-t) N(-d2)+Se-q^(T-t) N(-d1) σ-S2T-t + Xe-r^(T-t) N(-d2)-Se-q^(T-t) N(-d1) σ-2S2(T-t) , Θ = f t =rf+(q-r)SΔ- σ2S22Γ, Λ = f σ =( Xd1 e-r^(T-t) N(-d2)-S d2 e-q^(T-t) N(-d1) σ-2 ) σ^, ρ = f r =-X(T-t) e-r^(T-t) N(-d2)+ (Se-q^(T-t) N(-d1)-Xe-r^(T-t) N(-d2)) T-tσ^.
The analytic solution for an American call option with q = 0q=0 is identical to that for a European call, since early exercise is never optimal in this case. For all other cases no analytic solution is known.

Example

function nag_pde_1d_blackscholes_closed_example
kopt = int64(2);
x = 50;
s = 0;
t = 0;
tmat = 0.4166667;
tdpar = [false; false; false];
r = [0.1];
q = [0];
sigma = [0.4];
[f, theta, delta, gamma, lambda, rho, ifail] = ...
    nag_pde_1d_blackscholes_closed(kopt, x, s, t, tmat, tdpar, r, q, sigma)
 

f =

     0


theta =

     0


delta =

     0


gamma =

     0


lambda =

     0


rho =

     0


ifail =

                    0


function d03nd_example
kopt = int64(2);
x = 50;
s = 0;
t = 0;
tmat = 0.4166667;
tdpar = [false; false; false];
r = [0.1];
q = [0];
sigma = [0.4];
[f, theta, delta, gamma, lambda, rho, ifail] = ...
    d03nd(kopt, x, s, t, tmat, tdpar, r, q, sigma)
 

f =

     0


theta =

     0


delta =

     0


gamma =

     0


lambda =

     0


rho =

     0


ifail =

                    0



PDF version (NAG web site, 64-bit version, 64-bit version)
Chapter Contents
Chapter Introduction
NAG Toolbox

© The Numerical Algorithms Group Ltd, Oxford, UK. 2009–2013