Finance - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

Home : Support : Online Help : Mathematics : Finance : Financial Instruments : Finance/LocalVolatility

Finance

 LocalVolatility
 compute the local volatilities given option prices

 Calling Sequence LocalVolatility(C, S, T, r, d, t, K)

Parameters

 C - algebraic expression or a procedure; price of a European call option S - list or Vector; values of the underlying asset T - list or Vector; time (in years) r - non-negative constant, algebraic expression or a yield term structure; risk-free rate d - non-negative constant, algebraic expression or a yield term structure; dividend yield t - name; variable representing time to maturity K - name; variable representing the strike price

Description

 • The LocalVolatility command computes local volatilities of the underlying asset implied by the specified prices of European call options. It is assumed that the underlying asset evolves according to the stochastic differential equation

$\frac{\mathrm{dS}\left(t\right)}{S\left(t\right)}=\left(r\left(t\right)-d\left(t\right)-\frac{{\mathrm{\sigma }\left(S\left(t\right),t\right)}^{2}}{2}\right)\mathrm{dt}+\mathrm{\sigma }\left(S\left(t\right),t\right)\mathrm{dW}\left(t\right)$

where

 – $r=r\left(t\right)$ is the risk-free rate,
 – $d=d\left(t\right)$ is the dividend yield,
 – $\mathrm{\sigma }=\mathrm{\sigma }\left(S,t\right)$ is the local volatility,

and

 – $W\left(t\right)$ is the standard Wiener process.
 • Note that the local volatility is a function of both time and the value of the underlying asset.
 • Let $P=P\left(t,K\right)$ denote the undiscounted price of the European call option with strike price K and maturity time t drawn on the underlying asset. If P(t, K) is known for all $0\le t$ and $0\le K$, then the local volatility sigma(S, t) of the underlying asset can be determined using the following equation:

$\frac{\partial }{\partial t}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}P\left(t,K\right)=\frac{{\mathrm{\sigma }\left(t,K\right)}^{2}{K}^{2}\left(\frac{{\partial }^{2}}{\partial {K}^{2}}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}P\left(t,K\right)\right)}{2}+\left(r\left(t\right)-d\left(t\right)\right)\left(P\left(t,K\right)-K\left(\frac{\partial }{\partial K}\phantom{\rule[-0.0ex]{0.4em}{0.0ex}}P\left(t,K\right)\right)\right)$

 • The parameter C is the discounted price of the European call option given as a function of the maturity time t and the strike price K.
 • The parameter S specifies values of the underlying asset for which local volatilities are to be computed. The parameter T specifies times for which local volatilities are to be computed. The LocalVolatility command returns a matrix V such that ${V}_{i,j}$ is the local volatility of the underlying asset at time ${T}_{j}$ when the value of the underlying asset is ${S}_{i}$.
 • The r and d parameters are the risk-free rate and the dividend yield. These parameters can be given in either the algebraic form or the operator form. If any of the parameters C, r, or d are given in the algebraic form, the parameters t and K must be specified to determine which variable represents time and which variable represents the strike price.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $r≔0.05$
 ${r}{≔}{0.05}$ (1)
 > $d≔0.03$
 ${d}{≔}{0.03}$ (2)
 > $\mathrm{S0}≔100$
 ${\mathrm{S0}}{≔}{100}$ (3)
 > $\mathrm{\sigma }≔t↦0.3$
 ${\mathrm{\sigma }}{≔}{t}{↦}{0.3}$ (4)
 > $C≔\mathrm{BlackScholesPrice}\left(100,K,t,\mathrm{\sigma },r,d\right)$
 ${C}{≔}{100.}{}{{ⅇ}}^{{-}{0.03000000000}{}{t}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022602}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{K}}\right){+}{0.06500000000}{}{t}\right)}{\sqrt{{t}}}\right)\right){-}{1.}{}{{ⅇ}}^{{-}{0.05000000000}{}{t}}{}{K}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{K}}\right){+}{0.06500000000}{}{t}\right)}{\sqrt{{t}}}{-}{0.2121320343}{}\sqrt{{t}}\right)\right)$ (5)
 > $L≔\mathrm{LocalVolatility}\left(C,S,T,r,d,t,K\right)$
 ${L}{≔}\sqrt{{2}}{}\sqrt{\frac{{0.03}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({100.}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022602}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}\right)\right){-}{1.}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right)\right){+}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}{3.000000000}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022602}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}\right)\right){+}{56.41895835}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}{}\left(\frac{{0.1532064691}}{\sqrt{{T}}}{-}\frac{{1.178511301}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{{{T}}^{{3}}{{2}}}}\right){+}{0.05000000000}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right){-}{0.5641895835}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}{}\left(\frac{{0.0471404520}}{\sqrt{{T}}}{-}\frac{{1.178511302}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{{{T}}^{{3}}{{2}}}}\right)\right){+}{0.02}{}{S}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}\frac{{132.9807600}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{S}{}\sqrt{{T}}}{-}{1.}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right){+}\frac{{1.329807601}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{\sqrt{{T}}}\right)}{{{S}}^{{2}}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}\frac{{1477.563997}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right){}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{{T}}^{{3}}{{2}}}{}{{S}}^{{2}}}{+}\frac{{132.9807600}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{{S}}^{{2}}{}\sqrt{{T}}}{+}\frac{{1.329807601}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{{S}{}\sqrt{{T}}}{+}\frac{{6.268773146}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right){}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{{S}{}{T}}\right)}}$ (6)
 > $\mathrm{plot3d}\left(L,S=80..120,T=0.2..2,\mathrm{axes}=\mathrm{BOXED}\right)$

First you obtain a symbolic expression for the local volatility in terms of time and underlying value.

 > $\mathrm{LocalVolatility}\left(C,S,T,r,d,t,K\right)$
 $\sqrt{{2}}{}\sqrt{\frac{{0.03}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({100.}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022602}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}\right)\right){-}{1.}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right)\right){+}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}{3.000000000}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022602}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}\right)\right){+}{56.41895835}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}{}\left(\frac{{0.1532064691}}{\sqrt{{T}}}{-}\frac{{1.178511301}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{{{T}}^{{3}}{{2}}}}\right){+}{0.05000000000}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right){-}{0.5641895835}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{S}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}{}\left(\frac{{0.0471404520}}{\sqrt{{T}}}{-}\frac{{1.178511302}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{{{T}}^{{3}}{{2}}}}\right)\right){+}{0.02}{}{S}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}\frac{{132.9807600}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{S}{}\sqrt{{T}}}{-}{1.}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)\right){+}\frac{{1.329807601}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{\sqrt{{T}}}\right)}{{{S}}^{{2}}{}{{ⅇ}}^{{0.05}{}{T}}{}\left({-}\frac{{1477.563997}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right){}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{{T}}^{{3}}{{2}}}{}{{S}}^{{2}}}{+}\frac{{132.9807600}{}{{ⅇ}}^{{-}{0.03000000000}{}{T}}{}{{ⅇ}}^{{-}\frac{{5.555555546}{}{\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}^{{2}}}{{T}}}}{{{S}}^{{2}}{}\sqrt{{T}}}{+}\frac{{1.329807601}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{{S}{}\sqrt{{T}}}{+}\frac{{6.268773146}{}{{ⅇ}}^{{-}{0.05000000000}{}{T}}{}\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right){}{{ⅇ}}^{{-}{\left(\frac{{2.357022603}{}\left({\mathrm{ln}}{}\left(\frac{{100.}}{{S}}\right){+}{0.06500000000}{}{T}\right)}{\sqrt{{T}}}{-}{0.2121320343}{}\sqrt{{T}}\right)}^{{2}}}}{{S}{}{T}}\right)}}$ (7)

Alternatively, you can compute values of the local volatility for any given value of S and T.

 > $S≔⟨90,95,100,105,110⟩$
 ${S}{≔}\left[\begin{array}{c}{90}\\ {95}\\ {100}\\ {105}\\ {110}\end{array}\right]$ (8)
 > $T≔⟨0.5,1.0,1.5⟩$
 ${T}{≔}\left[\begin{array}{c}{0.5}\\ {1.0}\\ {1.5}\end{array}\right]$ (9)
 > $\mathrm{LocalVolatility}\left(C,S,T,r,d,t,K\right)$
 $\left[\begin{array}{ccc}{0.299999999966666653}& {0.299999999466666667}& {0.299999999566666675}\\ {0.300000000033333325}& {0.299999999700000020}& {0.299999999800000028}\\ {0.299999999900000036}& {0.299999999733333356}& {0.299999999833333364}\\ {0.299999999999999989}& {0.3000000000}& {0.2999999998}\\ {0.300000000466666694}& {0.3000000000}& {0.2999999999}\end{array}\right]$ (10)

References

 Gatheral, J., The Volatility Surface: A Practitioner's Guide, (with foreword by Nassim Taleb), Wiley, 2006.
 Hull, J., Options, Futures, and Other Derivatives, 5th. edition. Upper Saddle River, New Jersey: Prentice Hall, 2003.

Compatibility

 • The Finance[LocalVolatility] command was introduced in Maple 15.
 • For more information on Maple 15 changes, see Updates in Maple 15.