VaR with Monte Carlo

Felipe Cezar
3 min readDec 27, 2020

--

In 1946 Stanislaw Ulam was going through a difficult period in his life. He was stuck at home convalescing from an illness and the only thing he had to do was playing a lot of solitaire. That was when he first came up with an idea that later became the Monte-Carlo method.

The original question he was trying to answer was what are the chances that a Canfield solitaire laid out with 52 cards will come out successfully?

He tried to estimate it by pure combinatorial calculations at first, but when the math became too complicated he decided to try a different approach: instead of calculating the actual combinatorial math, he could try out several games at random, and from that sample estimate the odds he was looking for.

If he had had this idea some years earlier, he might have never been able to develop it to its full potential. But thankfully 1946 computing power was powerful enough for him to use a machine to simulate more random games than a person ever would be able to using only pen and paper.

With the help from his friend John von Neumann, Ulam implemented the idea and the rest is history. The Monte-Carlo method is used to this day to simulate all types of data, with applications in physics, biology and quantitative finance.

What is the Monte-Carlo Method?

Basically, Monte-Carlo is an application of repeated random sampling processes to obtain numerical results that would otherwise be too complicated to calculate directly. A good example is what we are trying to do here: calculating the probabilities associated with the returns of an asset.

Why it works

It works because of something called the Law of Large Numbers. The more times you try an experiment, say flipping a coin, the more your results will reflect the actual underlying probabilities of the events. If you flip a coin 10 times and record the results, your data might show you that the odds of getting heads is 50%, but it could also show odds of 60%. However, if you run the experiment 10,000,000 times, you are much more likely to get a result that is very close to 50%.

Calculating Var using Monte-Carlo

In my previous post, we talked about how the Value at Risk is a threshold level of return that represent the x-percentile worst case scenario for a given asset or portfolio of assets. If you haven't read it yet, check it out here.

As discussed before, the VaR is predicated on a given distribution of returns: you can use a parametric distribution (Gaussian), a historical distribution (past returns for a given timeframe), or you could even simulate a certain distribution using the Monte-Carlo Method. That is the example application we will be discussing here.

Why it is useful

With the Monte-Carlo approach you can use the mean and standard deviation observed from historical data and extrapolate it to a set of thousands or even millions of simulated outcomes that will provide good insight into return probabilities.

How it is done

The first step is to get a sample of the population. In our case, this would be a set of returns for a given timeframe. The more samples you have, the better.

The second step is to calculate the statistics associated with you sample. In our case, we want to know the mean and the standard deviation.

The third step is to simulate random returns using a assumed distribution that reflects the sampled statistics. The Normal Distribution is the standard for this.

The forth and final step is to gather all the simulated results and find the n-th worst one. That is your VaR.

Unlisted

--

--