Derivative Pricing Within Microsoft Excel:) 0), (Max 0), (Max (
Derivative Pricing Within Microsoft Excel:) 0), (Max 0), (Max (
By George Levy
Microsoft Excel is widely used to analyse and graph financial data. The purpose of this article is to show
how to customise Excel to the needs of a particular individual or company and enhance the power of
Excel for financial analysis. We illustrate the use of a Visual Basic routine to evaluate an option's value
that depends on the value of one underlying asset. We then discuss the use of other routines called
within Excel to evaluate an option's value that depends on the values of multiple underlying assets.
V p = e rT E[max( X S T ),0] . Here X is the strike price, T is the maturity of the option, r is the risk
_
S T is the market value of the asset at maturity and E[] denotes the expectation
T
If it is assumed that the value of the asset follows geometric Brownian motion and S has a lognormal
distribution the Black-Scholes formula [1] can be used to price the options as follows:
Vc = S 0 N (d1 ) e rT X N ( d 2 ),
V p = S 0 N ( d1 ) + e rT X N ( d 2 )),
where
d1 = (log ( S 0 / X ) + (r 2 / 2)T ) /( T ), d 2 = d1
and N ( x) =
where
1
2
x2 / 2
dx
S 0 is the current value of the asset and is the volatility of the asset.
The cumulative standard normal distribution, N (x ) ,can be evaluated in Excel by using the function
NORMDIST. The definition of this function is as follows:
NORMDIST(x,mean,standard_dev,cumulative)
This function returns the normal cumulative distribution for the specified mean and standard deviation.
Function parameters:
x : is the value for which you want the distribution.
mean: is the arithmetic mean of the distribution.
standard_dev: is the standard deviation of the distribution.
cumulative: is a logical value that determines the form of the function. If cumulative is TRUE,
NORMDIST returns the cumulative distribution function; if FALSE, it returns the probability density
function.
temp As Double
d1 As Double
d2 As Double
SQT As Double
value As Double
temp = Log(S0 / X)
d1 = temp + (r - q + (sigma * sigma / 2#)) * T
SQT = Sqr(T)
d1 = d1 / (sigma * SQT)
d2 = d1 - sigma * SQT
If (putcall = 0) Then ' a call option
value = S0 * Exp(-q * T) * WorksheetFunction.NormDist(d1, 0#, 1#, True) _
- WorksheetFunction.NormDist(d2, 0#, 1#, True) * X * Exp(-r * T)
Else ' a put option
value = -S0 * Exp(-q * T) * WorksheetFunction.NormDist(-d1, 0#, 1#, True) + _
X * WorksheetFunction.NormDist(-d2, 0#, 1#, True) * Exp(-r * T)
End If
bs_opt = value
End Function
Once the function has been defined it can be accessed interactively using the Paste Function facility
within Excel as shown below.
The function bs_opt can also be incorporated into other Visual Basic code within Excel. To illustrate, if
the following Visual Basic subroutine is defined:
Private Sub MANY_EUROPEANS_Click()
.
.
.
For i = 1 To 65
S0 = Sheet1.Cells(i + 1, 1).value
X = Sheet1.Cells(i + 1, 2).value
putcall = Sheet1.Cells(i + 1, 3).value
Sheet1.Cells(i + 1, 4).value = bs_opt(S0, X, sigma, T, r, q, putcall)
Next i
End Sub
then when the button labelled "CALCULATE OPTIONS" is clicked, the values of 65
European options will be calculated using the data in columns 1-3 on worksheet 1.
current asset value, S , may (for instance) refer to the current temperature,
temperature, r , the mean temperature, etc.
Cumulative standard normal distributions can also be used to provide closed form solutions
for rainbow options involving multiple assets. Examples of rainbow call options on two assets
are as follows:
_
Vc = e rT E[max(max(S1T , S 2T ) X ),0]
spread option,
portfolio option,
Vc = e rT E[max(min(S1T , S 2T ) X ),0]
Vc = e rT E[max(S1T S 2T ) X ),0]
_
Vc = e rT E[max(S1T X 1 , S 2T X 2 ),0]
_
Here
S1T and S 2T are the values of assets one and two at maturity respectively, and T , r , X and
E[] have their usual meanings. The closed form solutions for these options involve terms such as
S10 N 2 (d1 , d * , 12 ) where
d1 = (log ( S10 / X ) + (r + 12 / 2) T ) /( 1 T ) , d * = (log ( S10 / S 20 ) + ( 12 / 2) T ) /( 1 T ),
12 = ( 1 2 ) / , and 2 = 1 + 2 2 1 2
S10 and S 20 are the current values of assets one and two respectively, is the correlation between
the assets and 1 and 2 are the volatilities of assets one and two.
Here
N 2 ( x, y, 12 ) =
y x
1
2 1
2
12
2
)
( x 2 2 12 y 2 ) / 2 (1 12
dx dy
Unfortunately Excel does not provide a function to evaluate the integral N 2 ( x, y , 12 ) . This means that
software developers are faced with the choice of either writing their own function or using a commercially
available function. Although there are various methods to approximate this integral, for example [1], it
would not be computationally efficient to implement these in Visual Basic. This means that the developer
would have to write the function in another language say C++ and then call it from Excel [3]. Since this
approach could be time consuming and error prone it might be more cost effective to make use of
commercially available software [4].
However, once the choice has been made a rainbow pricing function (say bs_opt_rainbow) can be added
to the Paste Function facility in a similar way to how the function bs_opt was created. This approach can
be used to customise Excel to the needs of particular individuals or companies and can also greatly
enhance the power of Excel for financial analysis.
George Levy is a numerical analyst at NAG Ltd UK, he can be contacted at george@nag.co.uk.
References
rd
[1] J C Hull, Options, Futures and other Derivatives, Prentice Hall International Inc, 3 Edition 1997.
[2] R McIntyre, Black-Scholes will do, Energy Power and Risk Management, November 1999.
[3] G F Levy, Calling 32-bit NAG C DLL functions from Visual Basic 5 and Microsoft Office, NAG
Technical Report, TR2/98, 1998
[4] Such as the G01 chapter of the NAG Numerical Library form NAG Ltd and NAG Inc.