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

 > with(Finance):
 > T := 2.0;
 ${T}{≔}{2.0}$ (1)

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

 > X := GeometricBrownianMotion(1.0, 0.02, 0.3):
 > PathPlot(X(t), t = 0..T, timesteps = 100, replications = 10, axes = BOXED, gridlines = true);

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

 > W := GeometricBrownianMotion(1, mu(t), sigma(t), t):
 > Drift(W(u));
 ${\mathrm{\mu }}{}\left({t}\right){}{\mathrm{_X1}}{}\left({u}\right)$ (2)
 > Diffusion(W(u));
 ${\mathrm{\sigma }}{}\left({t}\right){}{\mathrm{_X1}}{}\left({u}\right)$ (3)
 > Drift(ln(W(u)));
 ${\mathrm{\mu }}{}\left({t}\right){-}\frac{{{\mathrm{\sigma }}{}\left({t}\right)}^{{2}}}{{2}}$ (4)

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

 > mu := piecewise(t < 1, 0.02, 0.02/t);
 ${\mathrm{\mu }}{≔}\left\{\begin{array}{cc}{0.02}& {t}{<}{1}\\ \frac{{0.02}}{{t}}& {\mathrm{otherwise}}\end{array}\right\$ (5)
 > sigma := evalf[3](CurveFitting:-Spline([[0, 0.5], [1, 0.3], [1.5, 1.5], [2, 1.0]], t, degree = 3));
 ${\mathrm{\sigma }}{≔}\left\{\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.00}{}{t}{-}{6.00}{}{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.00}{}{\left({t}{-}{1.5}\right)}^{{3}}& {\mathrm{otherwise}}\end{array}\right\$ (6)
 > Y := GeometricBrownianMotion(1.0, mu, sigma, t):
 > S := SamplePath(Y(t), t = 0..T, replications = 10^6):

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

 > mu := unapply(mu, t);
 ${\mathrm{\mu }}{≔}{t}{↦}\left\{\begin{array}{cc}{0.02}& {t}{<}{1}\\ \frac{{0.02}}{{t}}& {\mathrm{otherwise}}\end{array}\right\$ (7)
 > sigma := unapply(sigma, t);
 ${\mathrm{\sigma }}{≔}{t}{↦}\left\{\begin{array}{cc}{0.500}{-}{1.40}{\cdot }{t}{+}{1.20}{\cdot }{{t}}^{{3}}& {t}{<}{1.}\\ {-}{1.90}{+}{2.20}{\cdot }{t}{+}{3.60}{\cdot }{\left({-}{1.}{+}{t}\right)}^{{2}}{-}{6.40}{\cdot }{\left({-}{1.}{+}{t}\right)}^{{3}}& {t}{<}{1.5}\\ {1.00}{\cdot }{t}{-}{6.00}{\cdot }{\left({t}{-}{1.5}\right)}^{{2}}{+}{4.00}{\cdot }{\left({t}{-}{1.5}\right)}^{{3}}& {\mathrm{otherwise}}\end{array}\right\$ (8)
 > Z := GeometricBrownianMotion(1.0, mu, sigma):
 > S := SamplePath(Z(t), t = 0..T, replications = 10^6):

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

 > X := GeometricBrownianMotion(1.0, 0.05, 0.3):
 > V := SampleValues(A -> rtable_scanblock(A, [rtable_dims(A)], ':-Maximum'), X, 0..T, timesteps = 100, replications = 10^5):

Here are examples involving stochastic volatility.

 > R := OrnsteinUhlenbeckProcess(0.5, 1.0, 0.5, 0.3):
 > Y := GeometricBrownianMotion(1.0, 0.0, R(t)^2, t):
 > PathPlot(Y(t), t = 0..3, timesteps = 100, replications = 10, axes = BOXED, gridlines = true);

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

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.