Skip to content

Instantly share code, notes, and snippets.

Created June 15, 2015 14:18
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Geometric Brownian Motion Stochastic Process
import math
import numpy
import random
import decimal
import scipy.linalg
import numpy.random as nrand
import matplotlib.pyplot as plt
Note that this Gist uses the Model Parameters class found here -
def geometric_brownian_motion_log_returns(param):
This method constructs a sequence of log returns which, when exponentiated, produce a random Geometric Brownian
Motion (GBM). GBM is the stochastic process underlying the Black Scholes options pricing formula.
:param param: model parameters object
:return: returns the log returns of a geometric brownian motion process
assert isinstance(param, ModelParameters)
wiener_process = numpy.array(brownian_motion_log_returns(param))
sigma_pow_mu_delta = (param.gbm_mu - 0.5 * math.pow(param.all_sigma, 2.0)) * param.all_delta
return wiener_process + sigma_pow_mu_delta
def geometric_brownian_motion_levels(param):
Returns a sequence of price levels for an asset which evolves according to a geometric brownian motion
:param param: model parameters object
:return: the price levels for the asset
return convert_to_prices(param, geometric_brownian_motion_log_returns(param))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment