Introduction to Monte Carlo simulations and option pricing

Fredrik Olsson

Fredrik Olsson

Data Scientist

Nov 26
2019

In this post we are going to introduce the mathematical statistics concept Monte Carlo simulations. We will use financial option pricing as our use case in demonstrating the Monte Carlo approach, and will therefore also introduce derivate assets and financial options, and how we price these contracts. This post will serve as a introductory post to Pricing financial options using Monte Carlo simulations where we will price two rather complicated option examples using Monte Carlo simulations.

Derivative assets and financial options

Before we get into the Monte Carlo simulations, we will start off with a quick introduction to derivative assets and financial options. A derivative is a financial contract between two (or more) parties, where the contract's value depends on another asset. We say that the derivative derives its value from the value of this underlying asset. Financial options are typical examples of derivative assets.

It does not have to be complicatedIt does not have to be complicated

There are very many different types of derivative assets. They vary in terms of e.g. their structure, number and types of underlying assets, and time to maturity. Common examples of underlying assets are stocks, interest rates, bonds, currencies and market indexes. In this post we will only look at perhaps the simplest type of financial option that has one stock as the underlying asset, namely the European call option.

Consider that you want to buy a stock at some future time point TT. You can of course just wait until this future time point, but this will leave you with the uncertainty of not knowing what you will have to pay for the stock. One way to get rid of the uncertainty is to enter a so called forward contract. This is a contract between you and a counterpart where you agree to exchange the stock at time TT for some fix value KK decided today when entering the contract. Denoting the value of the stock at time tt by S(t)S(t), this will give you the following payoff at time TT:

Φ(S(T))=S(T)K \Phi(S(T)) = S(T) - K

You can see it as buying the stock for KK in the forward contract and then selling the stock at market price S(T)S(T). The value KK is set such that the value of the forward contract is free to enter for both parties, i.e. that the value of the contract today (at t=0t=0) is zero.

So, with the help of the forward contract, we are able to get rid of the uncertainty of not knowing what we will have to pay for the stock. However, if the market price of the stock at time TT happens to be lower than KK, we are still obligated to fulfill the forward contract, and thus making a loss since we could have bought the stock cheaper directly from the market. Rather, we would only want to exchange the stock if S(T)>KS(T) > K. This leads us in on financial option contracts. As the name indicates, it gives us the option to exercise the contract only if it is profitable to us.

In this case, we then like to have an option giving us the possibility of buying the stock at time TT for KK if S(T)>KS(T)>K, and if not, we do not exercise the option. This is called an European call option, and for this option we instead have the following payoff at time TT:

Φ(S(T))=max(S(T)K,0) \Phi(S(T)) = \max(S(T)-K, 0)

with the corresponding payoff-diagram (when K=90K=90):

Payoff-diagram for the European call optionPayoff-diagram for the European call option

With this option, we know that we will not have to pay more than KK for the stock, and have thus removed the uncertainty as well as eliminating the risk of the future stock price being lower than KK. The counterpart in the contract is still obligated to sell the stock for KK even though it is worth more on the market, so the option contract is more advantageous to us, and is unlike the forward contract not a contract that is free to enter. The counterpart carries all the risk and should thus be compensated for this. So, the question is then what this compensation should be, i.e. how do we price this European call option. That is the question we will tackle throughout the rest of this blog post.

The way we price contracts of this kind is that we discount the expected future payoff back to today, so the price of an European call option today, which we denote Π(0)\Pi(0), is given as:

Π(0)=erTE[max(S(T)K,0)] \Pi(0) = e^{-rT}\mathbb{E}[\max(S(T)-K,0)]

Note that the rr is the (continuously compounded) risk free interest rate, so erTe^{-rT} is the discount factor. Maybe you have not encountered a discount factor before. There is a time value in money. It is always better to get money sooner than later, since we can invest it and get some return. You can see the discount factor as something that change the value of the future cash flow at time TT, so that it is comparable to a cash flow today. Also, E\mathbb{E} denotes the expected value. So, if we are going to evaluate this expected value, we need a distribution for the underlying stock, i.e. we need the distribution for S(T)S(T). Therefore, we need a model for the stock.

The standard Black & Scholes model

Just as the dynamics of different phenomena in other areas often are described using differential equations, we use differential equations to model the stock as well. However, since the stock's price process is a stochastic (random) process, we will model the stock using stochastic differential equations. While the solution to an ordinary differential equation is the function that satisfies the equation, the solution to a stochastic differential equation is instead the random variable that satisfies the equation. There are many different models that we can use, all of different complexity. As a start, we will look at a rather simple model called the standard Black & Scholes model. This is the model that gives rise to the famous Black & Scholes formula for pricing European call and put options, a formula that typically shows up in finance courses.

In the standard Black & Scholes model, we have the following stochastic differential equation for the stock, also known as Geometric Brownian Motion:

dS(t)=rS(t)dt+σS(t)dW(t) dS(t) = rS(t)dt + \sigma S(t)dW(t)

Here σ\sigma is a positive constant, rr is still the risk free interest rate and the dd-symbol denotes the differential. The stochastic part enters with the W(t)W(t), which is called a standard Brownian Motion, and is the following Gaussian process:

W(t)N(0,t) W(t) \sim N(0, t)

Now, since this post is not about stochastic differential and integral calculus, we will not show how we can derive the solution to the Geometric Brownian Motion, but instead just state the solution. For more information on Geometric Brownian Motions including how to solve the equation, take a look at the Wikipedia page for Geometric Brownian Motion. We have that:

S(T)=S(0)e(rσ22)T+σW(T) S(T) = S(0)e^{(r-\frac{\sigma^2}{2})T + \sigma W(T)}

where S(0)S(0) is today's stock price. We can note that, since everything except W(T)N(0,T)W(T) \sim N(0, T) are deterministic constants, the price is the exponential of a normal distribution, and thus has a log-normal distribution.

Monte Carlo simulations

Now, after this quick introduction to derivative pricing, we can finally get into Monte Carlo simulations. In this fairly simple case with a European call option in the standard Black & Scholes model, we actually have an exact solution, namely the Black & Scholes formula mentioned before:

Π(0)=S(0)N(d1)erTN(d2) \Pi(0) = S(0)N(d_1) - e^{-rT} N(d_2)

where d1=1σT(log(S(0)K)+(r+σ22)T)d_1 = \frac{1}{\sigma\sqrt{T}}\cdot\left(\log(\frac{S(0)}{K}) + (r+\frac{\sigma^2}{2})T\right), d2=d1σTd_2 = d_1 - \sigma\sqrt{T} and N(x)N(x) is the distribution function of the standard normal distribution. Therefore, Monte Carlo simulations is not necessary in this case. However, it provides us with a simple example to introduce the concepts, and we also have an exact solution to compare our Monte Carlo estimates to.

Alright, Monte Carlo simulations. It is a method for estimating expected values of random variables. The basic Monte Carlo sampler is really just based upon one result in mathematical statistics, namely the law of large numbers. It states that if X1,X2,...,XnX_1,X_2,...,X_n are independent, identically distributed random variables, then:

1ni=1nφ(Xi)E[φ(X)], as n \frac{1}{n}\sum_{i=1}^n \varphi(X_i) \rightarrow \mathbb{E}[\varphi(X)], \text{ as } n\rightarrow\infty

where φ\varphi is some function satisfying E[φ(X)]<\mathbb{E}[\varphi(X)]<\infty. Inspired by this result, denoting our Monte Carlo estimate using $N$ simulations by E[φ(X)]NMC\mathbb{E}[\varphi(X)]_N^{MC}, the basic Monte Carlo sampler is given by:

for i=1 to Ndraw XiendE[φ(X)]NMC=1Ni=1Nφ(Xi) \begin{aligned} &\textbf{for } i=1 \textbf{ to } N \\ &\quad\quad \text{draw } X_i \\ &\textbf{end} \\ &\mathbb{E}[\varphi(X)]_N^{MC} = \frac{1}{N}\sum_{i=1}^N \varphi(X_i) \end{aligned}

Comparing with the European call option in the standard Black & Scholes model, we can estimate the price Π(0)\Pi(0) using the following Monte Carlo sampler:

for i=1 to Ndraw W(T)iN(0,T)endΠ(0)NMC=1Ni=1NerTmax(S(0)e(rσ22)T+σW(T)iK,0) \begin{aligned} &\textbf{for } i=1 \textbf{ to } N \\ &\quad\quad \text{draw } W(T)_i \sim N(0, T) \\ &\textbf{end} \\ &\Pi(0)_N^{MC} = \frac{1}{N}\sum_{i=1}^N e^{-rT}\cdot\max(S(0)e^{(r-\frac{\sigma^2}{2})T + \sigma W(T)_i} - K, 0) \end{aligned}

Now assuming that the initial stock price is S(0)=100S(0)=100, the so called strike price K=90K=90, the risk free interest rate r=1%r=1\%, the volatility of the stock σ=0.2\sigma=0.2 and that the time to maturity T=1T=1 year, we can implement the following Monte Carlo sampler in Python:

import numpy as np from scipy.stats import norm K = 90 # strike price s = 100 # initial stock price r = 0.01 # risk free interest rate (continuously compounded) sigma = 0.2 # volatility of the stock T = 1 # time to maturity (years) N = 100000 # size of the Monte Carlo sample # generate Monte Carlo sample mc = np.random.normal(0, np.sqrt(T), N) # W(T)s mc = s*np.exp((r-0.5*sigma**2)*T + sigma*mc) # S(T)s mc = np.exp(-r*T)*np.maximum(mc - K, 0) # option prices price = np.mean(mc) # estimated price # confidence interval price_std = np.std(mc) / np.sqrt(N) # standard deviation of the price estimator lo = price - norm.ppf(0.975)*price_std # lower bound of confidence interval for the price hi = price + norm.ppf(0.975)*price_std # upper bound of confidence interval for the price

Running a simulation (with N=100000N=100000) gives us the following price estimate and 95% confidence interval for the Monte Carlo estimated price:

Π(0)NMC=14.234IΠ(0)=(14.131,14.336) \begin{aligned} \Pi&(0)_N^{MC} = 14.234 \\ I_{\Pi(0)} &= (14.131, 14.336) \end{aligned}

We can compare with the exact value given by Black & Scholes formula by implementing this in Python as well:

d1 = (np.log(s/K) + (r + 0.5*sigma**2)*T) / (sigma*np.sqrt(T)) # d1 in B&S-formula d2 = d1 - sigma*np.sqrt(T) # d2 in B&S-formula bs_price = s*norm.cdf(d1) - np.exp(-r*T)*K*norm.cdf(d2) # price by B&S-formula

This gives us that Π(0)=14.193\Pi(0)=14.193, which we see lies in the confidence interval for our Monte Carlo estimated price. Note that we will get a different estimate if we were to repeat the Monte Carlo simulation, but if we look at the figure below of the estimate of 1000 different simulations, we see that they on average coincide with the exact value given by the Black & Scholes formula.

Different simulations of the option price and the exact value by B&S formulaDifferent simulations of the option price and the exact value by B&S formula

Conclusion

In this post, we managed to:

  • Introduce derivative assets and financial options, especially the European call option

  • Look at our first model for stocks, namely the standard Black&Scholes model

  • Introduce the concept of Monte Carlo simulations

  • Look at our first pricing example

As mentioned before, the pricing example we looked at here actually has an exact solution - the Black & Scholes formula - so the Monte Carlo approach was not necessary in this case.

In the follow-up blogpost Pricing financial options using Monte Carlo simulations we will look at two examples examples when we actually need to use the Monte Carlo approach demonstrated in this blogpost. Both these examples are definitely more challenging mathematically, but the ideas are the same as here in this post. The first example is a so called Basket call option, and in the second example we return to the European call option, but instead use a more complex stock model. In both cases, we cannot find an explicit formula for the price, so we actually need the Monte Carlo simulations to price the options.

Published on November 26th 2019

Last updated on March 1st 2023, 10:47

Fredrik Olsson

Fredrik Olsson

Data Scientist