Finance - Maple Programming Help

# Online Help

###### All Products    Maple    MapleSim

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

Finance

 BlackScholesPrice
 compute the Black-Scholes price of a European-style option with given payoff

 Calling Sequence BlackScholesPrice(${S}_{0}$, K, T, sigma, r, d, optiontype) BlackScholesPrice(${S}_{0}$, P, T, sigma, r, d)

Parameters

 ${S}_{0}$ - algebraic expression; initial (current) value of the underlying asset K - algebraic expression; strike price T - algebraic expression; time to maturity sigma - algebraic expression; volatility r - algebraic expression; continuously compounded risk-free rate d - algebraic expression; continuously compounded dividend yield P - operator or procedure; payoff function optiontype - call or put; option type

Description

 • The BlackScholesPrice command computes the price of a European-style option with the specified payoff function.
 • The parameter ${S}_{0}$ is the initial (current) value of the underlying asset. The parameter T is the time to maturity in years.
 • The parameter K specifies the strike price if this is a vanilla put or call option. Any payoff function can be specified using the second calling sequence. In this case the parameter P must be given in the form of an operator, which accepts one parameter (spot price at maturity) and returns the corresponding payoff.
 • The sigma, r, and d parameters are the volatility, the risk-free rate, and the dividend yield of the underlying asset. These parameters can be given in either the algebraic form or the operator form. The parameter d is optional. By default, the dividend yield is taken to be 0.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$

First you compute the price of a European call option with strike price 100, which matures in 1 year. This will define the price as a function of the risk-free rate, the dividend yield, and the volatility.

 > $\mathrm{BlackScholesPrice}\left(100,100,1,\mathrm{σ},r,d,'\mathrm{call}'\right)$
 ${-}{50}{}{{ⅇ}}^{{-}{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{d}{-}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){+}{50}{}{{ⅇ}}^{{-}{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{d}{-}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){+}{50}{}{{ⅇ}}^{{-}{d}}{-}{50}{}{{ⅇ}}^{{-}{r}}$ (1)

In this example you will use numeric values for the risk-free rate, the dividend yield, and the volatility.

 > $\mathrm{BlackScholesPrice}\left(100,100,1,0.3,0.05,0.03,'\mathrm{call}'\right)$
 ${12.44264640}$ (2)

You can also use the generic method in which the option is defined through its payoff function.

 > $\mathrm{BlackScholesPrice}\left(100,t→\mathrm{max}\left(t-100,0\right),1,\mathrm{σ},r,d\right)$
 ${50}{}{{ⅇ}}^{{-}{r}{-}{d}}{}\left({{ⅇ}}^{{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{d}{-}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){-}{{ⅇ}}^{{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{d}{-}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){-}{{ⅇ}}^{{d}}{+}{{ⅇ}}^{{r}}\right)$ (3)
 > $\mathrm{BlackScholesPrice}\left(100,t→\mathrm{max}\left(t-100,0\right),1,0.3,0.05,0.03\right)$
 ${12.44264640}$ (4)
 > $\mathrm{Price}≔\mathrm{BlackScholesPrice}\left(100,100,1,\mathrm{σ},r,0.03,'\mathrm{call}'\right)$
 ${\mathrm{Price}}{≔}{48.52227668}{+}{48.52227668}{}{\mathrm{erf}}{}\left(\frac{{0.7071067810}{}\left({-}{0.03000000000}{+}{r}{+}{0.5000000000}{}{{\mathrm{σ}}}^{{2}}\right)}{{\mathrm{σ}}}\right){-}{100.}{}{{ⅇ}}^{{-}{1.}{}{r}}{}\left({0.5000000000}{+}{0.5000000000}{}{\mathrm{erf}}{}\left(\frac{{0.7071067810}{}\left({-}{0.03000000000}{+}{r}{+}{0.5000000000}{}{{\mathrm{σ}}}^{{2}}\right)}{{\mathrm{σ}}}{-}{0.7071067810}{}{\mathrm{σ}}\right)\right)$ (5)
 > $\mathrm{plot3d}\left(\mathrm{Price},\mathrm{σ}=0..1,r=0..1,\mathrm{axes}=\mathrm{BOXED}\right)$ Here are similar examples for the European put option.

 > $\mathrm{BlackScholesPrice}\left(100,120,1,\mathrm{σ},r,d,\mathrm{put}\right)$
 ${-}{60}{}{{ⅇ}}^{{-}{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({5}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{d}{+}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){+}{50}{}{{ⅇ}}^{{-}{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({5}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{d}{+}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){+}{60}{}{{ⅇ}}^{{-}{r}}{-}{50}{}{{ⅇ}}^{{-}{d}}$ (6)
 > $\mathrm{BlackScholesPrice}\left(100,120,1,0.3,0.05,0.03,'\mathrm{put}'\right)$
 ${22.92329470}$ (7)
 > $\mathrm{BlackScholesPrice}\left(100,t→\mathrm{max}\left(120-t,0\right),1,\mathrm{σ},r,d\right)$
 ${-}{10}{}{{ⅇ}}^{{-}{r}{-}{d}}{}\left({6}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({5}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{d}{+}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){}{{ⅇ}}^{{d}}{-}{5}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({5}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{d}{+}{2}{}{r}\right){}\sqrt{{2}}}{{\mathrm{σ}}}\right){}{{ⅇ}}^{{r}}{-}{6}{}{{ⅇ}}^{{d}}{+}{5}{}{{ⅇ}}^{{r}}\right)$ (8)
 > $\mathrm{BlackScholesPrice}\left(100,t→\mathrm{max}\left(120-t,0\right),1,0.3,0.05,0.03,d\right)$
 ${22.92329473}$ (9)

In this example, you will compute the price of a strangle.

 > $S≔\mathrm{BlackScholesPrice}\left(100,t→\mathrm{piecewise}\left(t<90,90-t,t<110,0,t-110\right),1,\mathrm{σ},r,d\right)$
 ${S}{≔}{5}{}{{ⅇ}}^{{-}{r}{-}{d}}{}\left({9}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({{\mathrm{σ}}}^{{2}}{+}{4}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){}{{ⅇ}}^{{d}}{-}{10}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({-}{{\mathrm{σ}}}^{{2}}{+}{4}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){}{{ⅇ}}^{{r}}{+}{11}{}{{ⅇ}}^{{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({11}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){-}{10}{}{{ⅇ}}^{{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({11}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){-}{2}{}{{ⅇ}}^{{d}}\right)$ (10)
 > $C≔\mathrm{BlackScholesPrice}\left(100,110,1,\mathrm{σ},r,d,'\mathrm{call}'\right)$
 ${C}{≔}{-}{50}{}{{ⅇ}}^{{-}{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({-}{{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({11}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){+}{55}{}{{ⅇ}}^{{-}{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({{\mathrm{σ}}}^{{2}}{+}{2}{}{\mathrm{ln}}{}\left({11}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){+}{50}{}{{ⅇ}}^{{-}{d}}{-}{55}{}{{ⅇ}}^{{-}{r}}$ (11)
 > $P≔\mathrm{BlackScholesPrice}\left(100,90,1,\mathrm{σ},r,d,'\mathrm{put}'\right)$
 ${P}{≔}{45}{}{{ⅇ}}^{{-}{r}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({{\mathrm{σ}}}^{{2}}{+}{4}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){-}{50}{}{{ⅇ}}^{{-}{d}}{}{\mathrm{erf}}{}\left(\frac{{1}}{{4}}{}\frac{\sqrt{{2}}{}\left({-}{{\mathrm{σ}}}^{{2}}{+}{4}{}{\mathrm{ln}}{}\left({3}\right){-}{2}{}{\mathrm{ln}}{}\left({2}\right){-}{2}{}{\mathrm{ln}}{}\left({5}\right){+}{2}{}{d}{-}{2}{}{r}\right)}{{\mathrm{σ}}}\right){+}{45}{}{{ⅇ}}^{{-}{r}}{-}{50}{}{{ⅇ}}^{{-}{d}}$ (12)

Check:

 > $\mathrm{simplify}\left(S-C-P\right)$
 ${0}$ (13)

References

 Hull, J., Options, Futures, and Other Derivatives, 5th. edition. Upper Saddle River, New Jersey: Prentice Hall, 2003.

Compatibility

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