NAG Library Routine Document
D03NDF
1 Purpose
D03NDF computes an analytic solution to the Black–Scholes equation for a certain set of option types.
2 Specification
SUBROUTINE D03NDF ( |
KOPT, X, S, T, TMAT, TDPAR, R, Q, SIGMA, F, THETA, DELTA, GAMMA, LAMBDA, RHO, IFAIL) |
INTEGER |
KOPT, IFAIL |
REAL (KIND=nag_wp) |
X, S, T, TMAT, R(*), Q(*), SIGMA(*), F, THETA, DELTA, GAMMA, LAMBDA, RHO |
LOGICAL |
TDPAR(3) |
|
3 Description
D03NDF computes an analytic solution to the Black–Scholes equation (see
Hull (1989) and
Wilmott et al. (1995))
for the value
of a European put or call option, or an American call option with zero dividend
. In equation
(1) is time,
is the stock price,
is the exercise price,
is the risk free interest rate,
is the continuous dividend, and
is the stock volatility. The parameter
,
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 D03NDF. An auxiliary routine
D03NEF 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
where
is the maturity time of the option. For a put option the equation
(1) is subject to
D03NDF also returns values of the Greeks
S30ABF 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 8.1.
4 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
5 Parameters
- 1: KOPT – INTEGERInput
On entry: specifies the kind of option to be valued:
- A European call option.
- An American call option.
- A European put option.
Constraints:
- , or ;
- if , .
- 2: X – REAL (KIND=nag_wp)Input
On entry: the exercise price .
Constraint:
.
- 3: S – REAL (KIND=nag_wp)Input
On entry: the stock price at which the option value and the Greeks should be evaluated.
Constraint:
.
- 4: T – REAL (KIND=nag_wp)Input
On entry: the time at which the option value and the Greeks should be evaluated.
Constraint:
.
- 5: TMAT – REAL (KIND=nag_wp)Input
On entry: the maturity time of the option.
Constraint:
.
- 6: TDPAR() – LOGICAL arrayInput
On entry: specifies whether or not various parameters are time-dependent. More precisely, is time-dependent if and constant otherwise. Similarly, specifies whether is time-dependent and specifies whether is time-dependent.
- 7: R() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
R
must be at least
if
, and at least
otherwise.
On entry: if
then
must contain the constant value of
. The remaining elements need not be set.
If
then
must contain the value of
at time
T and
must contain its average instantaneous value over the remaining life of the option:
The auxiliary routine
D03NEF may be used to construct
R from a set of values of
at discrete times.
- 8: Q() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
Q
must be at least
if
, and at least
otherwise.
On entry: if
then
must contain the constant value of
. The remaining elements need not be set.
If
then
must contain the constant value of
and
must contain its average instantaneous value over the remaining life of the option:
The auxiliary routine
D03NEF may be used to construct
Q from a set of values of
at discrete times.
- 9: SIGMA() – REAL (KIND=nag_wp) arrayInput
-
Note: the dimension of the array
SIGMA
must be at least
if
, and at least
otherwise.
On entry: if
then
must contain the constant value of
. The remaining elements need not be set.
If
then
must contain the value of
at time
T,
the average instantaneous value
, and
the second-order average
, where:
The auxiliary routine
D03NEF may be used to compute
SIGMA from a set of values at discrete times.
Constraints:
- if , ;
- if , , for .
- 10: F – REAL (KIND=nag_wp)Output
On exit: the value
of the option at the stock price
S and time
T.
- 11: THETA – REAL (KIND=nag_wp)Output
- 12: DELTA – REAL (KIND=nag_wp)Output
- 13: GAMMA – REAL (KIND=nag_wp)Output
- 14: LAMBDA – REAL (KIND=nag_wp)Output
- 15: RHO – REAL (KIND=nag_wp)Output
On exit: the values of various Greeks at the stock price
S and time
T, as follows:
- 16: IFAIL – INTEGERInput/Output
-
On entry:
IFAIL must be set to
,
. If you are unfamiliar with this parameter you should refer to
Section 3.3 in the Essential Introduction for details.
For environments where it might be inappropriate to halt program execution when an error is detected, the value
is recommended. If the output of error messages is undesirable, then the value
is recommended. Otherwise, if you are not familiar with this parameter, the recommended value is
.
When the value is used it is essential to test the value of IFAIL on exit.
On exit:
unless the routine detects an error or a warning has been flagged (see
Section 6).
6 Error Indicators and Warnings
If on entry
or
, explanatory error messages are output on the current error message unit (as defined by
X04AAF).
Errors or warnings detected by the routine:
On entry, | , |
or | , |
or | when , |
or | , |
or | , |
or | , |
or | , |
or | , with , |
or | , with , for some , or . |
7 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
D03NEF are exact for polynomials of degree up to
.
8.1 Algorithmic Details
The Black–Scholes analytic formulae are used to compute the solution. For a European call option these are as follows:
where
is the cumulative Normal distribution function and
is its derivative
The functions
,
,
and
are average values of
,
and
over the time to maturity:
The Greeks are then calculated as follows:
Note: that is obtained from substitution of other Greeks in the Black–Scholes partial differential equation, rather than differentiation of . The values of , 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 with respect to , not .
For a European put option the equivalent equations are:
The analytic solution for an American call option with 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.
9 Example
This example solves the Black–Scholes equation for valuation of a -month American call option on a non-dividend-paying stock with an exercise price of $50. The risk-free interest rate is 10% per annum, and the stock volatility is 40% per annum.
The option is valued at a range of times and stock prices.
9.1 Program Text
Program Text (d03ndfe.f90)
9.2 Program Data
Program Data (d03ndfe.d)
9.3 Program Results
Program Results (d03ndfe.r)