Skip to content
All library documents

Estimating GBM Parameters and Simulating Equity Price Paths

Article Quant Q&A · Author: upsc

Summary

The document presents a historical-data approach to estimating geometric Brownian motion parameters and generating sample future price paths. It computes log returns from adjusted closing prices, uses their sample mean and standard deviation to estimate drift and volatility, and simulates paths by applying normally distributed shocks to the GBM process. The example uses a single equity price series and shows simulated terminal values.

A second response distinguishes physical-measure simulation from option calibration. Volatility can be estimated from historical log returns, while drift is difficult to infer as a reliable forecast; momentum research sometimes uses recent returns as a rough expectation. For option valuation, implied volatility is relevant instead. The code and data source are dated, and the note does not assess parameter uncertainty, non-normal returns, changing volatility, or the sensitivity of simulated outcomes to the drift assumption.

Key ideas

  • Historical log returns provide estimates of GBM volatility and drift inputs.
  • The GBM simulation compounds normally distributed shocks to generate price paths.
  • Physical-measure forecasts and option-pricing calibration use different inputs.
  • Drift is difficult to estimate for future simulation and should be treated cautiously.
  • Historical GBM paths do not account for model risk or changing market conditions.

Tags

Full text
# Is there a python code for estimating the parameters of geometric brownian motion?


# Is there a python code for estimating the parameters of geometric brownian motion?












I was trying to find the parameters of GBM but could not find a python code for the same.

## Answer by Kiwiakos (score 3)

https://quant.stackexchange.com/a/21971

The code below pulls AAPL time series from Yahoo Finance, computes mean/std and simulates 100 paths that are 20 days long.

Input:

```
import pandas as pd
import numpy as np
from numpy.random import normal

# bring data
ticker = 'AAPL'
url = 'http://real-chart.finance.yahoo.com/table.csv?s=%s' % ticker
data = pd.read_csv(url, index_col='Date', parse_dates=True)
data.sort_index(inplace=True)
r = np.log(data['Adj Close']).diff().as_matrix()[1:]

# estimate parameters
sigma = np.std(r)
mu = np.mean(r) +0.5*sigma*sigma

# simulate paths
T = 20 # number of periods to simulate
N = 100 # number of scenarios
epsilon = normal(size=[T, N])
paths = data['Adj Close'][-1]*np.exp(np.cumsum(mu-0.5*sigma*sigma +sigma*epsilon, axis=0))

# output
print 'data from %s to %s' % (data.index[0].date(), data.index[-1].date())
print '%d scenarios of %d periods' % (N, T)
print paths[-1]
```

Output:

```
data from 1980-12-12 to 2015-11-27
100 scenarios of 20 periods
[ 110.05103396  115.22220256  102.15942834  137.8933195   128.98220659
  123.78995167  119.78760965  111.55081804  101.28873804  150.01698323
  118.17378031  129.26568517  116.89831894  120.14299291  100.92602175
  129.08661341  126.11134726  131.05832164  105.40035237  148.56201625
  117.6589326   135.80459977  116.3256132   118.11022374  138.24069944
  130.23096841  121.44359248   93.36990366  120.40376295  113.86096665
  112.79238568  104.29584358  154.99719687  133.25955192  108.20838712
  120.11125973  104.21453197  112.78981396  108.77688605  118.40240356
  156.99140878  130.91871886  111.0078855   139.71865207  145.2893878
  135.05797455  122.57696229   93.85711338  148.3231574   105.5308185
   98.42940505  106.28268823   99.49360753  118.41985903  152.10864408
  100.48435239   96.49837802  124.98286066  112.95868168  134.59980791
  132.01882861  109.43251849  151.64664262  116.37618346  112.04417492
  119.18353134  120.73513746   96.41828595  107.16867675  121.18435982
   90.45490766  110.88758748  126.11216937  106.48179123  147.52005583
  121.25689013  118.6405851   103.84301241  120.88770293  110.99499809
  119.6822996   112.84273236  131.80224893  124.77742484  135.99716652
  141.02784531  117.44045644  110.02261302  128.75145159  115.82045737
  129.60995183  115.7623887   133.83373679  116.89180599  103.1893998
  138.25279665  106.56185885  138.59835512  101.29356076  152.75506114]
```

## Answer by Richi Wa (score 0)

https://quant.stackexchange.com/a/21969

If you want to use GBM in the physical measure then just calculate the standard deviation of log returns to get $\sigma$. For $\mu$ there are many choices.

If you want to calibrate GBM to get option prices then you need the implied volatility and there is a package.

The OP said that he/she wants to simulate paths. If you don't want to price derivatives then you work in the "real world" measure.

Then $\sigma$ can be estimated as mentioned. $\mu$ is hard to assume (for the future). If you look at the literature of momentum strategies then some of them take the expectation of the last 3 to 6 months for the coming 3 to 6 months. I say this in the sense that there is the stylized fact that winners tend to win and losers tend to lose.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.