# Stock Price Simulation

In this post, I'll introduce four stochastic processes commonly used to simulate stock prices. Formulation and Python implementation are presented one by one, with brief comments afterwards.

Before introducing the four methods, we first define a handy function to prepend a zero before a numpy array:

1 | def prepend(arr, val=0): |

# Brownian Motion

Brownian motion (BM) was initially exhibited and modeled in gas or liquid particle movements. The random motion was the solution to massive number of tiny collisions of particles in certain medium. Brownian motion was named after the botanist, Robert Brown, in 1827, and after almost a century introduced into the financial markets. People usually call a standard Brownian motion as a Wiener process, which has the following properties:

- \(W_0\overset{\text{a.s.}}{=}0\newcommand{\d}{\text{d}}\)
- \(W\) has independent increments \(\forall t > 0\)
- \(W\) has Gaussian increments: \(W_{t + \d t} - W_t \sim \mathcal{N}(0,\d t)\)
- \(W_t\) is continuous in \(t\) with probability \(1\)

A general BM follows SDE:

\[ \d S_t = \mu \d t + \sigma \d W_t \]

which directly gives solution by take integrals on both sides:

\[ S_t = S_0 + \mu t + \sigma W_t. \]

With all of these given, we can easily simulate the process as below.

1 | class BM: |

**Comments**: One may notice that we don't have any constraint posed on \(W\) — it can be however positive — and however negative. Therefore, while BM might give a simple and easy-to-implement solution for a short run, we don't really want to use it as it potentially gives us negative prices.

# Geometric Brownian Motion

Geometric Brownian Motion (GBM) was famous as been used in Fisher Black and Myron Scholes's 1973 paper, *The Pricing of Options and Corporate Liabilities*. The process is by definition positive and thus gives a fix for what we doubted in BM. The corresponding SDE is

\[ \d S_t = S_t(\mu \d t + \sigma \d W_t) \]

which gives solution

\[ S_t = S_0\exp\left\{\left(\mu-\frac{\sigma^2}{2}\right)t + \sigma W_t\right\}. \]

1 | class GBM: |

**Comments**: The GBM is good enough for most simulations. However, it is also well-known that the Black-Scholes model cannot give fat tails as is inspected empirically in stock markets.

# Merton's Jump Diffusion Process

Robert C. Merton, who shared the 1997 Nobel Price with Scholes (Black had passes away unfortunately), was one of the first academics to address some of the limitations in the GBM. In his 1976 paper, *Option Pricing when Underlying Stock Returns are Discontinuous*, he superimposed a "jump" component on the diffusion term so that the model can now simulate sudden economic shocks, i.e. jumps in prices. The jump \(J\) is given by the exponential of a compound Poisson process \(N\) with normal underlyings. The SDE is as follows.

\[\begin{align*} Y_i&\overset{\text{i.i.d.}}{\sim}\mathcal{N}(\gamma, \delta^2)&\text{(Jump Magnitude)}\\ \d N_t & \sim \text{Pois}(\lambda \d t)&\text{(Poisson Process)}\\ J_t &= \textstyle{\sum_{i=1}^{N_t}}Y_i&\text{(Jump)}\\ \d S_t &= S_t (\mu \d t + \sigma \d W_t + \d J_t).\\ \end{align*}\]

Merton's jump diffusion SDE has a closed-form solution:

\[ S_t = S_0 \exp\left\{\left(\mu -\frac{\sigma}{2}\right)t + \sigma W_t + J_t\right\}. \]

1 | class MertonJump: |

**Comments**: Merton's jump process solved the kurtosis mismatch problem in empirical financial data by minimally changing the GBM. However, with the discontinuous (and usually negative, corresponding to market clashes) jumps introduced in the model, we may witness frequent slumps and in general a decline in the total drift. On the other, the jump process still did not solve the constant volatility issue.

# The Heston Stochastic Volatility Process

In the early 1990's Steven Heston introduced this model where volatilities, different from the original GBM, are no longer constant. In the Heston model, volatilities evolve according to the Cox-Ingersoll-Ross process with a mean-reverting essense. As there're now two stochastic processes, we need two (potentially correlated) Wiener processes. The SDE is now

\[\begin{align*} \d W_t^S\d W_t^V &= \rho\d t & \text{(Correlated Wiener)}\\ \d V_t &= \kappa (\theta - V_t) \d t + \xi \sqrt{V_t} \d W_t^V &\text{(Cox-Ingersoll-Ross)}\\ \d S_t &= \mu S_t \d t + \sqrt{V_t}S_t \d W_t^S & \text{(Heston)} \end{align*}\]

1 | class Heston: |

**Comments**: The Heston model is one of the most popular stochastic volatility models in finance. In case one need even more freedom, he may opt for time-varying parameters e.g. \(\mu\to\mu_t\) and \(\xi\to\xi_t\).

# Plots

Finally, let's take a look at all the simulated price processes. The Brownian motion is shifted s.t. \(S_0=1\) like the rest models. Mutual parameters like \(\mu\) and \(\sigma\) are set to the same values. Each figure shows \(1000\) paths.