Last active
July 23, 2018 16:41
-
-
Save dirkolbrich/aa4c9790a7126e85492e1277f4fbb7ed to your computer and use it in GitHub Desktop.
This file contains hidden or 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 matplotlib.pyplot as plt | |
import numpy as np | |
def geometric_brownian(years, drift, sigma, startPrice): | |
T=years | |
mu = drift | |
simga = sigma | |
S0 = startPrice | |
dt = 0.01 | |
N = round(T/dt) | |
t = np.linspace(0, T, N) | |
print(len(t)) | |
W = np.random.standard_normal(size = N) | |
W = np.cumsum(W)*np.sqrt(dt) | |
X = (mu-0.5*sigma**2)*t + sigma*W | |
S = S0*np.exp(X) | |
return t, S | |
t1, S1 = geometric_brownian(10, 0, 0, 100) | |
plt.plot(t1, S1) | |
t1, S1 = geometric_brownian(10, -0.1, 0.02, 100) | |
plt.plot(t1, S1) | |
t1, S1 = geometric_brownian(10, 0, 0.05, 100) | |
plt.plot(t1, S1) | |
t1, S1 = geometric_brownian(10, 0.1, 0.1, 100) | |
plt.plot(t1, S1) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment