Black Scholes Model with Stock Simulation
Ziyi Zhu / July 17, 2021
5 min read • ––– views
The article explores the use of geometric Brownian Motion (GBM) to simulate the price of stocks. The concept naturally extends to the Black-Scholes-Merton (BSM) model which is widely used to estimate the pricing variation of financial instruments such as an options contract. Monte Carlo simulation (MCS) is then used to estimate the stock pricing and validate the model predictions.
Geometric Brownian Motion
Stochastic process
A geometric Brownian motion (GBM) is a continuous-time stochastic process in which the logarithm of the randomly varying quantity follows a Brownian motion (also called a Wiener process) with drift. The stock price is said to follow a GBM if it satisfies the following stochastic differential equation (SDE):
is a Wiener process or Brownian motion, and the expected return and the standard deviation of returns (volatility) are constants. We also assume the stock does not pay any dividends, there are no transaction costs and the continuously compounding interest rate is . Note that is normally distributed with mean and variance . For an arbitrary initial value the above SDE has the analytic solution:
The GBM is technically a Markov process. The stock price hence follows a random walk and is consistent with the weak form of the efficient market hypothesis (EMH).
# Calculate stock price at time t
S = S0 * np.exp(r * t - 1/2 * sigma**2 * t + sigma * np.random.randn() * np.sqrt(t))
Probability density function
Since the exponent of is normally distributed, we can use the change of variable formula to calculate the probability distribution of . Note that for the exponent is normally distributed with mean and variance . Hence, follows a log-normal distribution:
Maximum likelihood estimate
In order to estimate the percentage drift and percentage volatility , we use the previously calculated probability density function for log-normal distribution to obtain an expression for the log-likelihood:
Differentiate with respect to the model parameters to find the maximum likelihood (ML) estimate:
We can use the GBM to model real financial data by looking at the General Electric stock daily data over 20 business days.
High Low Open Close Volume Adj Close
Date
2021-06-01 14.34 14.10 14.23 14.15 50276900.0 14.139239
2021-06-02 14.18 14.01 14.18 14.09 39936800.0 14.079286
2021-06-03 14.37 13.94 13.99 14.09 63163800.0 14.079286
2021-06-04 14.20 13.86 14.16 13.96 64071200.0 13.949385
2021-06-07 14.07 13.86 14.00 13.91 37349100.0 13.899423
By calculating the mean and variance of the log returns, we can obtain an estimate of the risk free interest rate and volatility.
Black Scholes Model
The Black-Scholes Formula
The Black-Scholes call option formula is calculated by multiplying the stock price by the cumulative standard normal distribution. Thereafter, the net present value (NPV) of the strike price with risk-free interest rate and time to maturity is multiplied by the cumulative standard normal distribution and subtracted from the resulting value. The call option price is therefore given by:
is the risk-adjusted probability that the option will be exercised. is the factor by which the present value of contingent receipt of the stock exceeds the current stock price.
To price a derivative in the Black-Scholes world, we must do so under a measure which does not allow arbitrage (clearly the existence of arbitrage in any model is cause for concern). Such a measure is called a risk-neutral measure.
# Calculate the value of a call option using the Black-Scholes formula
d1 = (1 / sigma * np.sqrt(t)) * (np.log(S0/K) + (r + 1/2 * sigma**2 * t))
d2 = d1 - sigma * np.sqrt(t)
C = S0 * (norm.cdf(d1)) - np.exp(-r * t) * K * norm.cdf(d2)
Monte Carlo for vanilla option
Options are financial instruments that give the holder the right, but not the obligation, to buy or sell an underlying asset at a predetermined price within a given timeframe. A vanilla option is a call option or put option that has no special or unusual features. For a call option with strike , the payoff at time is given by:
We can compare the average payoff of an option simulated with GBM with its price calculated using the Black-Scholes model.
# Monte Carlo simulation
for i in range(NUM_SIMS):
stock_price = S0 * np.exp(r * t - 1/2 * sigma**2 * t + sigma * np.random.randn() * np.sqrt(t))
payoff[i] = (stock_price - K) * np.exp(-r * t) if stock_price > K else 0