Created
June 15, 2015 14:18
-
-
Save StuartGordonReid/8fdcde7f15b4c8481970 to your computer and use it in GitHub Desktop.
Geometric Brownian Motion Stochastic Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 - https://gist.github.com/StuartGordonReid/f01f479c783dd40cc21e | |
""" | |
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