Finance - Maple Programming Help

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

Finance

 OrnsteinUhlenbeckProcess
 create new Ornstein-Uhlenbeck process

 Calling Sequence OrnsteinUhlenbeckProcess(${x}_{0}$, mu, theta, sigma, opts)

Parameters

 ${x}_{0}$ - algebraic expression; initial value mu - algebraic expression; long-running mean theta - algebraic expression; the speed of mean reversion sigma - algebraic expression; the volatility parameter opts - (optional) equation(s) of the form option = value where option is scheme; specify options for the OrnsteinUhlenbeckProcess command

Options

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

Description

 • The OrnsteinUhlenbeckProcess command creates an Ornstein-Uhlenbeck process. This is a stochastic process $X\left(t\right)$ governed by the stochastic differential equation (SDE)

$\mathrm{dX}\left(t\right)=\mathrm{\theta }\left(\mathrm{\mu }-X\left(t\right)\right)\mathrm{dt}+\mathrm{\sigma }\mathrm{dW}\left(t\right)$

where theta, sigma, and mu are real constants.

 • The parameter ${x}_{0}$ defines the initial value of the underlying stochastic process.
 • The parameter theta is the speed of mean-reversion. The parameter mu is the long-running mean. The parameter sigma is the volatility. In general, theta, mu, and sigma can be any algebraic expressions. However, if the process is to be simulated, these parameters must be assigned numeric values.
 • 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 $X\left(t+\mathrm{dt}\right)$ given $X\left(t\right)$.

Examples

 > with(Finance):
 > r := OrnsteinUhlenbeckProcess(r0, mu, theta, sigma);
 ${r}{≔}{\mathrm{_X0}}$ (1)
 > Drift(r(t));
 ${\mathrm{\theta }}{}\left({\mathrm{\mu }}{-}{\mathrm{_X0}}{}\left({t}\right)\right)$ (2)
 > Diffusion(r(t));
 ${\mathrm{\sigma }}$ (3)
 > r0 := 0.5;
 ${\mathrm{r0}}{≔}{0.5}$ (4)
 > theta := 1.0;
 ${\mathrm{\theta }}{≔}{1.0}$ (5)
 > mu := 0.25;
 ${\mathrm{\mu }}{≔}{0.25}$ (6)
 > sigma := 0.3;
 ${\mathrm{\sigma }}{≔}{0.3}$ (7)
 > PathPlot(r(t), t = 0..3, timesteps = 100, replications = 10, thickness = 3, color = red..blue, axes = BOXED);

Here is an example using the transition density.

 > mu := 0.02;
 ${\mathrm{\mu }}{≔}{0.02}$ (8)
 > theta := 1.0;
 ${\mathrm{\theta }}{≔}{1.0}$ (9)
 > sigma := 0.001;
 ${\mathrm{\sigma }}{≔}{0.001}$ (10)
 > r0 := 0.05;
 ${\mathrm{r0}}{≔}{0.05}$ (11)
 > r := OrnsteinUhlenbeckProcess(r0, mu, theta, sigma);
 ${r}{≔}{\mathrm{_X1}}$ (12)
 > q := OrnsteinUhlenbeckProcess(r0, mu, theta, sigma, scheme = unbiased);
 ${q}{≔}{\mathrm{_X2}}$ (13)
 > p := dsolve({diff(x(t), t) = theta*(mu-x(t)), x(0) = r0});
 ${p}{≔}{x}{}\left({t}\right){=}\frac{{1}}{{50}}{+}\frac{{3}{}{{ⅇ}}^{{-}{t}}}{{100}}$ (14)
 > P1 := PathPlot(r(t), t = 0..5, timesteps = 5, replications = 1, color = red):
 > P2 := PathPlot(q(t), t = 0..5, timesteps = 5, replications = 1, color = blue):
 > P3 := plot(rhs(p), t = 0..5, color = green):
 > plots[display](P1, P2, P3, thickness = 3, axes = BOXED);

Here is a realization of the Ornstein-Uhlenbeck process as a subordinated Wiener process.

 > mu := 0.02;
 ${\mathrm{\mu }}{≔}{0.02}$ (15)
 > theta := 1.0;
 ${\mathrm{\theta }}{≔}{1.0}$ (16)
 > sigma := 0.01;
 ${\mathrm{\sigma }}{≔}{0.01}$ (17)
 > r0 := 0.05;
 ${\mathrm{r0}}{≔}{0.05}$ (18)
 > r := OrnsteinUhlenbeckProcess(r0, mu, theta, sigma);
 ${r}{≔}{\mathrm{_X3}}$ (19)
 > tau := (exp(2*theta*t)-1)/2/theta;
 ${\mathrm{\tau }}{≔}{0.5000000000}{}{{ⅇ}}^{{2.0}{}{t}}{-}{0.5000000000}$ (20)
 > W := WienerProcess(tau);
 ${W}{≔}{\mathrm{_W}}$ (21)
 > q := t -> r0*exp(-theta*t)+mu*(1-exp(-theta*t))+sigma*exp(-theta*t)*W(t);
 ${q}{≔}{t}{↦}{\mathrm{r0}}{\cdot }{{ⅇ}}^{{-}{\mathrm{\theta }}{\cdot }{t}}{+}{\mathrm{\mu }}{\cdot }\left({1}{-}{{ⅇ}}^{{-}{\mathrm{\theta }}{\cdot }{t}}\right){+}{\mathrm{\sigma }}{\cdot }{{ⅇ}}^{{-}{\mathrm{\theta }}{\cdot }{t}}{\cdot }{W}{}\left({t}\right)$ (22)
 > R := PathPlot(r(t), t = 0..3, timesteps = 100, replications = 3, thickness = 3, color = red):
 > Q := PathPlot(q(t), t = 0..3, timesteps = 100, replications = 3, thickness = 3, color = blue):
 > plots[display](R, Q);
 > ExpectedValue(Int(r(u), u = 0..1), replications = 10^4, timesteps = 100);
 $\left[{\mathrm{value}}{=}{0.03902469384}{,}{\mathrm{standarderror}}{=}{0.00004066146237}\right]$ (23)
 > ExpectedValue(Int(q(u), u = 0..1), replications = 10^4, timesteps = 100);
 $\left[{\mathrm{value}}{=}{0.03898350713}{,}{\mathrm{standarderror}}{=}{0.0001753525705}\right]$ (24)

References

 Brigo, D., Mercurio, F., Interest Rate Models: Theory and Practice. New York: Springer-Verlag, 2001.
 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.
 Vasicek, O.A., An Equilibrium Characterization of the Term Structure, Journal of Financial Economics, 5 (1977), pp 177-188.

Compatibility

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