The Monte Carlo Method for pricing financial derivatives John Sonchack

What is a “Monte Carlo” Method? The phrase “Monte Carlo method” is very general. It describes a method of investigating a problem that uses random numbers and probability statistics to estimate some non-random value. Monte Carlo methods appear in many math related fields: physics, engineering, economics, etc.

A general algorithm for any Monte Carlo method Draw a bunch of random numbers Process each of these random numbers in some way, i.e. plug them into an equation or use them in some way Analyze the results to find an estimation for a non random value

More about Monte Carlo methods Monte Carlo methods can help us solve problems that are too complicated to solve using equations, or problems for which no equations exist. They are useful for problems which have lots of uncertainty They can also be used as an alternate way to solve problems that have equation solutions. However, they have drawbacks: Monte Carlo methods are often slower and less accurate than solutions via equations.

Basically, a Monte Carlo method is a way of solving complex problems through approximation using many random numbers. They are very versatile, but are often slower and less accurate than other available methods.

An example: Monte Carlo approximation of Pi If one point was drawn at every possible point on this square, then: Thus, a simple Monte Carlo method to approximate Pi would be to simply generate lots of random coordinates on this square and then do:number of points not in the circle / number of points total. This should come increasingly close to Pi. (example)

A Monte Carlo Method for Financial Derivatives We don’t know what a stock wil do in the future over time T. Blackscholes assumes a Brownian motion to figure out what is most likely to happen to the price of a stock after time T. if we figure out a way to approximate a possible brownian walk of a stock over some period of time T, we can approximate the blackscholes value by: 1) doing many sample walks of the stock 2) computing the value of a derivative for each sample walk 3) averaging the trial derivative values together to come up with an expected value for the derivative

If we do many random sample walks of a stock over time T, we can use that data to gain information about what the stock is most likely to do over time T.

Recal ing the beginning of the semester… We need some way of coming up with these sample walks for the stock. We know that ds= µ*dt + σ *dx Where: ds= change in stock price ( in percentage) µ = “drift” (which we assume to be r, the riskless interest rate, in order to match with black scholes assumptions) dt = change in time σ = the volatility of the stock dx = a random normally distributed variable with mean 0 and standard deviation SQRT(dt)

Applying the Monte Carlo method to financial derivatives, continued Since ds = the percent change of stock price from time a to b, we can replace ds with (S – b S )/S a a We can then take this formula and solve for S , b the value of the stock at some time in the future, as a function of a bunch of stuff that we know:(S -S )/S = µ*dt + σ *dx so, b a a (S -S ) = S * µ*dt + S * σ *dx b a a a S =S + S * µ*dt + S * σ *dx b a a a

Applying the Monte Carlo method to financial derivatives, continued We can use this formula: S =S + S * µ*dt + S * σ *dx 2 1 1 1 To come up with subsequent values of S in a sample random walk of a stock.

A sample run of a stock can be generated by using the formula (S2=S1+ S1* µ*dt + S1* σ *dx) to generate subsequent points in the path of a stock. We can take the values of a financial derivative (like a call, or a put) over many such sample paths and average them together to get an expected value for the financial derivative. S1=S0+ S0* µ*dt + S0* σ *dxS2=S1+ S1* µ*dt + S1* σ *dx…S =S +S * µ*dt + S * σ *dx N N-1 N-1 N-1

A tangent: Maple programming Most Monte Carlo Methods are implemented via a computer program rather than solved by hand or with a calculator. It is impractical to do the number of trial runs needed to get accurate results by hand. As we know, Maple is not only a very advanced calculator, but a programming language geared towards mathematical programming. This makes it a good language to implement this method in.

Basics about Maple Programming: Variables In Maple, we can assign numbers or more complicated functions to variables for later use by using the assignment operator. We can type things like x:=2; m:=18; b:=54.2352; y:=m*x+b; Then, if we ever want to use these values again, we can simply type in the name. If we typed in everything in the previous few lines, we could type y; and get a number result.

Basics about Maple Programming: Arrays Suppose we had the heights of al of the people in the class, and we wanted to do stuff to these values in maple. We could assign each value to a separate variable, but this would be inconvenient for a number of reasons: (time consuming to enter, even more time consuming to access, etc) Maple ( and nearly every other programming language ) has a special kind of variable cal ed an array that solves this problem.

Arrays, continued An array is a like variable that can hold many values. We can create an array in maple by using the array command. Heights:= array([74, 60, 65]); we can then access these variables by using an index; i.e. we can say things like: 45.3*Heights[1]; Heights[2]:=38; or even Heights[i];etc. Maple also lets us make empty arrays that we can fil at a later time by typing: Heights := array(1..N); Where N is the number of elements we want the array to contain.

Basics about Maple Programming: for loops Maple (and most other programming languages) have what is cal ed a for loop that al ows us to repeat some lines of code a number of times while incrementing a variable. Suppose we have an empty array cal ed values. (values:=Array(1..10); And we wanted to fil it with the squares of the first 10 integers. We could type: For i from 1 to 10 dovalues[i]:=i^2;Od; These three lines of code would make maple fil the entire array with the value of each index squared.

For loop syntax A for loop always fol ows this syntax in Maple: For {variable name} from {start value} to {end value} do {commands} Od; (curly brackets and stuff inside should be replaced with values that you want)

Basics about Maple Programming: Procedures A procedure is basical y a bunch of lines of code that achieves one common purpose. Maple has many build in procedures that we’ve al used like: blackscholes(S, K, r, T, volatility);, plot([xvalues], [yvalues]);, histogram([numbers]);, etc We can often pass either numbers or variables to procedures. For example, the blackscholes function takes 5 such parameters, S, K, r, T, and sigma. The answer that the procedure returns depends entirely on the values of these parameters.

Basics about Maple Programming: Writing your own procedure Maple also allows us to write our own procedure. We can write procedures using the proc() command. procedurename:=proc(x, y) z:=x+y; End proc; We would call this procedure like this: procedurename(5,1542.6); Here, x and y represent the values that the user gives the procedure. They are known as local variables, because they apply to the procedure only. Ex: if we type procedurename(2, 5); then inside of the procedure x:=2 and y:=5. This is for inside the procedure only; x does not equal 2 outside of the procedure.

Basics about Maple Programming: Misc stuff If you type in x:= 5+3y; (with a semicolon at the end) maple will evaluate what you wrote, and also print out the new value of x. If you type x:= 5+3y: (with a colon, not a semicolon) maple wil suppress output. Using a colon is useful when you’re writing procedures, because you don’t want the user to see the output from every line of code. If you just want to enter text and don’t want maple to evaluate a line of code, put a # in front of it. (maple will not evaluate ##Hello!) The function evalf, when passed % wil evaluate the last line of maple code entered. (Type evalf(%); to get a decimal approximation when you just entered a complicated equation)

Basics about Maple Programming: Misc stuff Maple provides us with a convenient way to get random numbers from any distribution. If we type randomnumber:=stats[random, normald[mean, stdev]]: Then if we type randomnumber() anywhere, we get a random number from a normal distribution with mean mean and standard deviation stdev. What maple generates is actually a procedure, thus we must remember to put ()’s after randomnumber.

Implementing the Monte Carlo Method for pricing financial derivatives… Final y! Remember that what we want to do is: 1) generate lots of random walks of the stock using the formula S =S +S * µ*dt + S * σ *dx N N-1 N-1 N-1 2) compute the value of our financial derivative for each of these random walks by using a payoff formula. 3) average these values together to get an expected value

One possible implementatio n for call options S =S +S * µ*dt + S * σ *dx N N-1 N-1 N-1

An example trial run of a stock with This line creates an 5 steps empty array that will hold call payoff values, each based off of a separate random run like this. This line creates an empty array that will hold stock values at steps in one run. This line determines how much time is between each value in the array S. If, in the example to the right, time = 5 months, then timestep would equal 1.

Basically, whats going on in this double for loop is the following: 1)Calculate a series of S values 2) Use these values to calculate a value for trialarray[1] based on the payoff function of a call discounted to present. 3) Calculate another series of S values, overwriting the old ones. 4) Use these values to calculate a value for trialarray[2] etc

Final y, when al values of trialarray have been computed, their mean can be taken to come up with an approximation for the expected value of the financial derivative (a cal , in our case).

Accuracy of this Implementation We would expect that as the number of trial runs increases, the accuracy of the final result does as well. In order to test this, we need to asses how far our mean is from the true mean. We need to figure out a way to find the standard deviation of our mean in the distribution of means. the Central Limit Theorem guarantees that if N is large enough, the sample mean will be normally distributed in the distribution of all means with a standard deviation of s/sqrt(N), where s is the standard deviation of the sample. (no matter what the distribution of the sample is!)

An example of the central limit theorem As an example, if we take the st. dev of a trial with N runs, we get some value s. If we take the mean of 100 such evaluations and then take the standard deviation of those means, we get a value that is always about s/10. This shows that the distribution of means of size 100 has a standard deviation of stdev(trial)/10. Thus, basical y, to assess accuracy, we can use stdev /SQRT(N) where N is the sample size. sample

What does the standard deviation represent again, anyway? A standard deviation of 1, in this case, means that there is a 68.1% or so chance that the mean which we computed is within +-.5 of the real mean. There is a 95% or so chance that the mean which we computed is within 2 *+-.5 of the real mean. We could calculate confidence intervals, however for a rough estimation of accuracy we can just look at the standard deviation of the mean in the distribution of means.

Summary of accuracy concerns In order to figure out accurate our sample mean is with respect to the true mean, we use:Standard deviation of sample/ SQRT(Sample size)

Steps vs. Trials and the cost of accuracy Increasing the number of steps creates more accurate depictions of a random walk. A more accurate random walk is only beneficial up to a certain point. For now, we can just use steps = 20. Increasing the number of trials, however, does bring with it huge benefits, at the cost of an increasingly large time cost

Time vs. number of trials Time increases at a rate of Number of Time Standard number of steps * number of trials. Thus, for path Trials (in Deviation independent variables, it is seconds) linear. Standard deviation is not 100 ~.3 ~1 linear, however. After a certain point, it becomes impractical to try for more 1,000 ~3 ~.3 accuracy due to time constraints. 10,000 ~30 ~.1 The run time can be improved by programming 100,000 ~300 ( 5 in a more optimized programming language, or minutes) even optimizing the Maple code to use the quickest procedures available.

The actual uses of the Monte Carlo Method Although we can use a Monte Carlo Method to price cal s and puts, there isn’t real y that much of a point since we could use BlackScholes. With slight modifications, the code today can be made to evaluate option prices for path dependent options for which equations either do not exist, or are very difficult to solve. Useful for derivatives like: lookback options, asian options, other exotic options.

Sources http://www.chem.unl.edu/zeng/joy/mclab/mcintro.html http://www.cargo.wlu.ca/introMaple.html http://ems.calumet.purdue.edu/mcss/kraftrl/mfmm/pdf/Worksheet13.pdf http://www.finweb.com/investing/exotic-options.html http://en.wikipedia.org/wiki/Monte_Carlo_methods_in_finance http://statistical-engineering.com/central_limit_theorem_fineprint.htm http://www.mapleprimes.com/forum/bughistogram http://el erbruch.nmu.edu/Maple/Array.html The Concepts and practice of mathematical finance, Mark Suresh Joshi (google books link)