In this blog post we will dive into the world of finance. We will however still make use of mathematical statistics and programming - two central building blocks of Machine Learning. We are going to have a look at how we can price financial options 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.
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 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.
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:
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, you can 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.
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:
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 numbers, then:
where is some function satisfying . Inspired by this result, denoting our Monte Carlo estimate using 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:
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:
This gives us that , which we see lies in the confidence interval for our Monte Carlo estimatad 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.
So this was the first part of this blog post about pricing financial options using Monte Carlo simulations. So far we have:
In the second part of this post, we are going to look at two other examples. They are both a bit more mathematically challenging, 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.