Fredrik Olsson
Data Scientist
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.
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.
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 . 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 for some fix value decided today when entering the contract. Denoting the value of the stock at time by , this will give you the following payoff at time :
You can see it as buying the stock for in the forward contract and then selling the stock at market price . The value 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 ) 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 happens to be lower than , 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 . 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 for if , 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 :
with the corresponding payoff-diagram (when ):
With this option, we know that we will not have to pay more than for the stock, and have thus removed the uncertainty as well as eliminating the risk of the future stock price being lower than . The counterpart in the contract is still obligated to sell the stock for 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 , is given as:
Note that the is the (continuously compounded) risk free interest rate, so 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 , so that it is comparable to a cash flow today. Also, 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 . Therefore, we need a model for the stock.
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:
Here is a positive constant, is still the risk free interest rate and the -symbol denotes the differential. The stochastic part enters with the , which is called a standard Brownian Motion, and is the following Gaussian process:
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:
where is today's stock price. We can note that, since everything except are deterministic constants, the price is the exponential of a normal distribution, and thus has a log-normal distribution.
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:
where , and 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 are independent, identically distributed random variables, then:
where is some function satisfying . Inspired by this result, denoting our Monte Carlo estimate using $N$ simulations by , the basic Monte Carlo sampler is given by:
Comparing with the European call option in the standard Black & Scholes model, we can estimate the price using the following Monte Carlo sampler:
Now assuming that the initial stock price is , the so called strike price , the risk free interest rate , the volatility of the stock and that the time to maturity 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 ) gives us the following price estimate and 95% confidence interval for the Monte Carlo estimated price:
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 , 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.
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
Data Scientist