2024-10-20

Monte Carlo simulations

Statistical model to simulate future uncertainties by using past data and building probability distributions which we sample to create simulated realized data

We will look at a simple application today in stock indexes but these models can get quite complex depending on the number of parameters we have and how uncertain each one is

In any model there \(n\) simulations and each simulation has steps \(t\)

We then gather a mean \(\bar{x}\) and standard deviation \(s\) of a statistic from our data, for each simulation we generate a path of returns by sampling a distribution with our gathered \(\bar{x}\) and \(s\).

Visulization of Application

  • \(S_0 = intial \; price\)
  • \(n = simulations\)
  • \(t = steps\)
  • \(\bar{x} = mean \; daily \; return\)
  • \(s = standard \; deviation \; of \; daily \; returns\)
  • \(X = random \; return \; from \; N(\bar{x}, s)\)

For each sample we take \(S_0\) and multiply by \((1+X_i)\) representing how much our price should change by giving us, \(S_0\cdot(1+X_1)\cdot(1+X_2)\cdot\left[...\right]\cdot(1+X_{t-1})\cdot(1+X_t)\) \(S_0\cdot\prod_{i=1}^{t}\left(1+X_i\right)\)

Data

Normal Distribution Selection

\(N(x | \mu, \sigma^2) = \frac{1}{\sqrt{2 \pi \sigma^2}} \exp\left(-\frac{(x - \mu)^2}{2 \sigma^2}\right)\), good estimate of data

Model Code

monte_carlo_normal <- function(price, sims, steps) {
  log_price <- log(price)
  past_returns <- diff(log_price) 
  past_returns <- na.omit(past_returns)
  x_bar <- mean(past_returns) 
  s <- sd(past_returns)
  value_paths <- data.frame(matrix(nrow = steps + 1, ncol = sims))
  return_paths <- data.frame(matrix(nrow = steps, ncol = sims))
  colnames(value_paths) <- paste0("sim", 1:sims)
  colnames(return_paths) <- paste0("ret", 1:sims)
  for (sim in 1:sims) {
    future_returns <- rnorm(steps, mean=x_bar, sd=s)
    value_pathing <- 1+(future_returns)
    future_values <- cumprod(c(last(price), value_pathing))
    value_paths[, sim] <- future_values
    return_paths[, sim] <- future_returns
  }
  return(list(value_paths = value_paths, return_paths = return_paths))
}

Model Plot

Model Range

An extremely simple/naive way for market makers to anticipate the movement of the market in order to price derivatives like options

Model Correlation

Greatest Correlation to Realized Path: .399

Greatest Inverse Correlation to Realized Path: -.388