===================================================
Math 451
Laboratory 5: Monte Carlo methods and Option Pricing
Date: 2013-04-19
Due: 2013-04-24
===================================================
As seen and discussed previously, Monte Carlo methods can
be used for quadrature as well as more general integration
problems. One relatively recent widely used application of
this idea is financial option pricing.
In this lab, you'll learn how Monte Carlo integration is used
to estimate prices for some simple financial options.
Goals
----------------------------
- Learn the basics of random walks
- Learn the basic idea of a European call option
- Learn one way to price a European call option
===================================================
Random walks
---------------------------------------------------
A random walk is walk where the direction of each step the
take is chosen randomly. As a simple example, 12 random
steps forward or backward can be generated in Matlab with
N = 12;
S = sign(rand(1,N)-0.5)
To see where you end up after taking these steps, we have to
add them all together. This can be done with the cumsum
function for cumulative sums.
W = cumsum([0,S])
1-a) Plot S and W in a figure as examples of random steps and
the walk they generate.
Often, the size of the steps is also chosen randomly.
For example,
S = randn(1,N)
W = cumsum([0,S])
1-b) Plot S and W in a figure as examples of random steps and
the walk they generate.
Random walks are often used as examples of possible future
outcomes, so we might generate an ensemble of them and study the
distribution of the results. A simple way to do this is.
M = 10; % number of trials
N = 12;
S = randn(N,M);
W = cumsum([zeros(1,M); S]);
1-c) Plot the ensemble of random walks in W.
One of the very useful features of random walks is that the
details of how the individual steps happen usually don't
matter very much. You can generate random walks in may
different ways, but still get the same result at the end.
1-d) Run the following script and interpret the figures generated
at the end. (plot, axes labels, meaning)
M = 800;
N = 50;
walks_A = cumsum([zeros(1,M); sign(rand(N,M)-0.5)/sqrt(N)]);
walks_B = cumsum([zeros(1,M); (rand(N,M)*2-1)*1.73205/sqrt(N)]);
walks_C = cumsum([zeros(1,M); randn(N,M)/sqrt(N)]);
figure(1); clf;
t=linspace(0,1,N+1);
subplot(3,1,1); plot(t,walks_A,'k-');
subplot(3,1,2); plot(t,walks_B,'k-');
subplot(3,1,3); plot(t,walks_C,'k-');
figure(2);
t=1:M;
plot(t,sort(walks_A(end,:)),'o-',t, sort(walks_B(end,:)),'+-', t, sort(walks_C(end,:)),'x-');
1-e) If we increase N to 800, the plot in figure 2 does not change much. Why?
Introduction to financial options
------------------------------------
A financial option is an contract/agreement like
"""
We agree that on September 1st, I will sell you 1 share
of Apple stock for $100 if you want to buy it.
"""
This specific case is an example of a European call option.
The share of Apple stock is called the "asset" of the
option, the $100 is the "strike price", and September 1st is
the "expiration date". The question before us today is how
much would you pay for this option.
Suppose we know the price of Apple stock will be $200 a
share on September 1st. Then if you owned this option, you
could buy stock for $100, sell it for $200, and make a
profit of $100 almost instantly. So this option would be
worth about $100 dollars to you, and if it was sold to you
at any price smaller than that, you should buy it. (For
simplicity, we assume there is no inflation over the time
from now to then.)
On the other hand, if you know the price of Apple shares
will be only $50 dollars on September 1st, then it would be
cheaper for you to buy shares from the market directly
rather than through this European call option, so it would
be worthless to you.
This final price of the stock on the expiration date is
called the "spot price". So the formula for the value
of a European call option is
max( 0, price_spot - price_call );
If the value of the call option is $20, and you can buy it
for $10, then you'll make a profit of $10.
Now, in practice, we don't usually know what the spot price
of the stock will be in the future. We know what it is
right now, and there's a chance it may go up, and a chance
it may go down. If we can predicted the expected future
value of the stock, we can determine the value of the
financial option to us, and thus, whether or not we should
buy it.
Pricing a European call option using a random walk
----------------------------------------------------
One way of predicting what wil happen to the stock is to use
a random walk. People often use random walks because real
stock prices _look_like_ random walks. For example, see
http://images.thetruthaboutcars.com/2011/04/gmstockprice.jpg
The following script uses random walks of various
resolutions N to calculate the value of a call option
on a stock. Run it and study it's results.
figure(1); clf;
p_current = 100.;
p_strike = 95.;
Ti = 0; % current date
Tf = 6; % expiration date, 6 months from today
v = 30.; % monthly rate of variation in price
m = 0.0; % expected monthly rate of change in price
M = 50;
for N=[5,10,20,100,900]
t = linspace(Ti,Tf,N+1);
h = (Tf-Ti)/N;
sigma_sq = v*sqrt(h);
mu = m*h;
walks = p_current+cumsum([zeros(1,M); randn(N,M)*sigma_sq+mu]);
p_spot = sort(walks(end,:));
values = sort(max(0,walks(end,:)-p_strike));
subplot(3,1,1);
plot(t,walks,'-');
subplot(3,1,2);
hist(p_spot);
subplot(3,1,3);
plot(1:M,values,'-');
hold on;
% mean and standard deviation of the final values
expectations = [ sum(values)/M, sqrt(sum((values-sum(values)/M).^2)/M) ];
disp([N,expectations]);
pause(2);
end
subplot(3,1,1);
xlabel('Time (months)');
ylabel('Stock Price');
subplot(3,1,2);
xlabel('Spot Price');
ylabel('Frequency');
subplot(3,1,3);
xlabel('Order in Sequence');
ylabel('Value');
3-a) If you expect that instead of being stable, on average
the stock will increase by a dollar each month, what would
be the expected value of the option then?
In this simple case, there is actually an analytic solution
that is much faster than the Monte Carlo random walk
approach. However, when drift and volatility are functions
of time, the problem is much harder and Monte Carlo methods
are needed.
3-b) Change the script so the monthly rate of expected
change varies like a sine function starting from 0 with a
maximum of 4 and period of 12 months.
3-c) Write a Matlab function file meeting the following
specification. Submit this matlab script online through
angel for grading.
function [Ev,Eo] = european_call_option_value(T,p0,V,M,n,m,p_strike)
% Ev is the expected value of the option
% Eo is the standard deviation in expected option value
%
% T is a vector of times between the current time and
% the expiration time of the call.
% p0 is the initial price of the stock
% V a vector of the expected variations in price at
% each of the times in T.
% M is a vector of the expected changes/drifts in price
% at each of the times in T.
% n is the number of steps to use in valuing the option.
% m is the number of trials to use in the ensemble wi
% p_strike is the strike price
%
%-------------------------------------------------------
%
% Random walks are generated using randn
%
% Linear interpolation of V and M over T is used to
% determine sigma_sq and mu at each of the n steps.
%
% Your submitted function should not generate any output
% other than returning the results Ev and Eo.