Finance - Maple Programming Help

Home : Support : Online Help : Mathematics : Finance : Stochastic Processes : Finance/GeometricBrownianMotion

Finance

 GeometricBrownianMotion
 create new Brownian motion process

 Calling Sequence GeometricBrownianMotion(${x}_{0}$, mu, sigma, opts) GeometricBrownianMotion(${x}_{0}$, mu, sigma, t, opts)

Parameters

 ${x}_{0}$ - real constant; initial value mu - algebraic expression, operator or procedure; drift parameter sigma - algebraic expression, operator, procedure or a one-dimensional stochastic process; volatility parameter t - name; time parameter opts - (optional) equation(s) of the form option = value where option is scheme; specify options for the GeometricBrownianMotion command

Options

 • scheme = unbiased or Euler -- This option specifies which discretization scheme should be used for simulating this process.

Description

 • The GeometricBrownianMotion command creates a new geometric Brownian motion process. This is a stochastic process $S\left(t\right)$, which is governed by the stochastic differential equation (SDE)

$\frac{\mathrm{dS}\left(t\right)}{S\left(t\right)}=\mathrm{\mu }\left(t\right)\mathrm{dt}+\mathrm{\sigma }\left(t\right)\mathrm{dW}\left(t\right)$

where

 – $\mathrm{\mu }=\mathrm{\mu }\left(t\right)$ is the drift parameter
 – $\mathrm{\sigma }=\mathrm{\sigma }\left(t\right)$ is the volatility parameter

and

 – $W\left(t\right)$ is the standard Wiener process.
 • The parameter ${x}_{0}$ defines the initial value of the underlying stochastic process. It must be a real constant.
 • The parameter mu is the drift. In the simplest case of a constant drift mu is a real number (that is, any expression of type $\mathrm{realcons}$). Time-dependent drift can be given either as an algebraic expression or as a Maple procedure. If mu is given as an algebraic expression, then the parameter t must be passed to specify which variable in mu should be used as a time variable. A Maple procedure defining a time-dependent drift must accept one parameter (the time) and return the corresponding value for the drift.
 • The parameter sigma is the volatility. Similar to the drift parameter, the volatility can be constant or time-dependent. Unlike drift, volatility can involve other (one-dimensional) stochastic variables.
 • The scheme option specifies the discretization scheme used for simulation of this process. By default the standard Euler scheme is used. When scheme is set to unbiased the transition density will be used to simulate a value $S\left(t+\mathrm{dt}\right)$ given $S\left(t\right)$. This scheme is appropriate in the case of a time-dependent drift and/or volatility.
 • In the multi-dimensional case the drift and the volatility parameter must be constant. The drift parameter must be specified as a Vector and the volatility parameter must be a symmetric matrix that defines the covariance between the individual components.

Examples

 > $\mathrm{with}\left(\mathrm{Finance}\right):$
 > $T≔2.0$
 ${T}{≔}{2.0}$ (1)

First consider the case of a one-dimensional Brownian motion with constant drift and volatility.

 > $X≔\mathrm{GeometricBrownianMotion}\left(1.0,0.02,0.3\right):$
 > $\mathrm{PathPlot}\left(X\left(t\right),t=0..T,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$

Compute the drift and diffusion for functions of $X$.

 > $W≔\mathrm{GeometricBrownianMotion}\left(1,\mathrm{μ}\left(t\right),\mathrm{σ}\left(t\right),t\right):$
 > $\mathrm{Drift}\left(W\left(u\right)\right)$
 ${\mathrm{μ}}{}\left({t}\right){}{\mathrm{_X0}}{}\left({u}\right)$ (2)
 > $\mathrm{Diffusion}\left(W\left(u\right)\right)$
 ${\mathrm{σ}}{}\left({t}\right){}{\mathrm{_X0}}{}\left({u}\right)$ (3)
 > $\mathrm{Drift}\left(\mathrm{ln}\left(W\left(u\right)\right)\right)$
 ${\mathrm{μ}}{}\left({t}\right){-}\frac{{1}}{{2}}{}{{\mathrm{σ}}{}\left({t}\right)}^{{2}}$ (4)

Here is an example of a one-dimensional Brownian motion with time-dependent parameters given in algebraic form.

 > $\mathrm{μ}≔\mathrm{piecewise}\left(t<1,0.02,\frac{0.02}{t}\right)$
 ${\mathrm{μ}}{≔}{{}\begin{array}{cc}{0.02}& {t}{<}{1}\\ \frac{{0.02}}{{t}}& {\mathrm{otherwise}}\end{array}$ (5)
 > $\mathrm{σ}≔\mathrm{evalf}[3]\left(\mathrm{CurveFitting}:-\mathrm{Spline}\left(\left[\left[0,0.5\right],\left[1,0.3\right],\left[1.5,1.5\right],\left[2,1.0\right]\right],t,\mathrm{degree}=3\right)\right)$
 ${\mathrm{σ}}{≔}{{}\begin{array}{cc}{0.500}{-}{1.40}{}{t}{+}{1.20}{}{{t}}^{{3}}& {t}{<}{1.}\\ {-}{1.90}{+}{2.20}{}{t}{+}{3.60}{}{\left({-}{1.}{+}{t}\right)}^{{2}}{-}{6.40}{}{\left({-}{1.}{+}{t}\right)}^{{3}}& {t}{<}{1.5}\\ {1.}{}{t}{-}{6.}{}{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.}{}{\left({t}{-}{1.5}\right)}^{{3}}& {\mathrm{otherwise}}\end{array}$ (6)
 > $Y≔\mathrm{GeometricBrownianMotion}\left(1.0,\mathrm{μ},\mathrm{σ},t\right):$
 > $S≔\mathrm{SamplePath}\left(Y\left(t\right),t=0..T,\mathrm{replications}={10}^{6}\right):$

Here is the same example but with drift and volatility given in the form of Maple procedures.

 > $\mathrm{μ}≔\mathrm{unapply}\left(\mathrm{μ},t\right)$
 ${\mathrm{μ}}{≔}{t}{→}{\mathrm{piecewise}}{}\left({t}{<}{1}{,}{0.02}{,}\frac{{0.02}}{{t}}\right)$ (7)
 > $\mathrm{σ}≔\mathrm{unapply}\left(\mathrm{σ},t\right)$
 ${\mathrm{σ}}{≔}{t}{→}{\mathrm{piecewise}}{}\left({t}{<}{1.}{,}{0.500}{-}{1.40}{}{t}{+}{1.20}{}{{t}}^{{3}}{,}{t}{<}{1.5}{,}{-}{1.90}{+}{2.20}{}{t}{+}{3.60}{}{\left({-}{1.}{+}{t}\right)}^{{2}}{-}{6.40}{}{\left({-}{1.}{+}{t}\right)}^{{3}}{,}{1.}{}{t}{-}{6.}{}{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.}{}{\left({t}{-}{1.5}\right)}^{{3}}\right)$ (8)
 > $Z≔\mathrm{GeometricBrownianMotion}\left(1.0,\mathrm{μ},\mathrm{σ}\right):$
 > $S≔\mathrm{SamplePath}\left(Z\left(t\right),t=0..T,\mathrm{replications}={10}^{6}\right):$

You can simulate values for any path function given as a Maple procedure.

 > $X≔\mathrm{GeometricBrownianMotion}\left(1.0,0.05,0.3\right):$
 > $V≔\mathrm{SampleValues}\left(A→\mathrm{rtable_scanblock}\left(A,\left[\mathrm{rtable_dims}\left(A\right)\right],':-\mathrm{Maximum}'\right),X,0..T,\mathrm{timesteps}=100,\mathrm{replications}={10}^{5}\right):$

Here are examples involving stochastic volatility.

 > $R≔\mathrm{OrnsteinUhlenbeckProcess}\left(0.5,1.0,0.5,0.3\right):$
 > $Y≔\mathrm{GeometricBrownianMotion}\left(1.0,0.0,{R\left(t\right)}^{2},t\right):$
 > $\mathrm{PathPlot}\left(Y\left(t\right),t=0..3,\mathrm{timesteps}=100,\mathrm{replications}=10,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$

Here is the same using different discretization schemes. For presentation purposes consider a geometric Brownian motion with very low volatility and time-dependent drift. Compare the simulated results with the corresponding solution of an ordinary (non-stochastic) differential equation.

 > $f≔\mathrm{sin}\left(t\right)$
 ${f}{≔}{\mathrm{sin}}{}\left({t}\right)$ (9)
 > $\mathrm{W1}≔\mathrm{GeometricBrownianMotion}\left(1.0,f,0.001,t\right):$
 > $\mathrm{W2}≔\mathrm{GeometricBrownianMotion}\left(1.0,f,0.001,t,\mathrm{scheme}=\mathrm{unbiased}\right):$
 > $\mathrm{W3}≔\mathrm{eval}\left(y\left(t\right),\mathrm{dsolve}\left(\left\{\frac{\frac{ⅆ}{ⅆt}y\left(t\right)}{y\left(t\right)}=\mathrm{sin}\left(t\right),y\left(0\right)=1.0\right\}\right)\right)$
 ${\mathrm{W3}}{≔}\frac{{{ⅇ}}^{{-}{\mathrm{cos}}{}\left({t}\right)}}{{{ⅇ}}^{{-}{1}}}$ (10)
 > $\mathrm{plots}[\mathrm{display}]\left(\mathrm{plot}\left(\mathrm{W3},t=0..3\right),\mathrm{PathPlot}\left(\mathrm{W1}\left(t\right),t=0..3,\mathrm{timesteps}=10,\mathrm{replications}=10\right),\mathrm{thickness}=3,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$
 > $\mathrm{plots}[\mathrm{display}]\left(\mathrm{plot}\left(\mathrm{W3},t=0..3\right),\mathrm{PathPlot}\left(\mathrm{W2}\left(t\right),t=0..3,\mathrm{timesteps}=10,\mathrm{replications}=10\right),\mathrm{thickness}=3,\mathrm{axes}=\mathrm{BOXED},\mathrm{gridlines}=\mathrm{true}\right)$

References

 Glasserman, P., Monte Carlo Methods in Financial Engineering. New York: Springer-Verlag, 2004.
 Hull, J., Options, Futures, and Other Derivatives, 5th. edition. Upper Saddle River, New Jersey: Prentice Hall, 2003.

Compatibility

 • The Finance[GeometricBrownianMotion] command was introduced in Maple 15.