## Transcribed Text

Mathematics of Finance
Background
The script MonteCarlo2.m on Blackboard generates 10,000 year long daily price paths for a stock with initial price
$100, expected annual return r = 10% (=0.1) and annual volatility σ = 30%. The matrix C of size 10,000 x 252 stores
all those paths in its rows. The script then calculates an approximation to E[ln(ST )] where ST is the final price of
the stock. It does so by simply taking the mean of the last column of C:
LogLastPrice = log(C(:, 252)); ←− C(:, 252) is the 252nd column; “:” stands for “any row”
The Task
Use the above script as a template (if you’re not working with Matlab) or modify its code to
1. Generate 100 (ideally 10,000 or more) 3 month long price paths for a stock with initial price $50, expected annual
return r = 10% (=0.1) and annual volatility σ = 30%. Assume that there are 21 trading days in a month.
2. Suppose that you want to sell a put option on the stock in part 1 with the strike price K = $50 and expiration
date in 3 months. You need to find how much to charge your customers for the option. You could proceed in
two steps
• Find the expected payoff of the put option
E[|K − ST |
+]
where ST is the stock’s price in 3 months (i.e., in 63 days). You would use here the same method MonteCarlo2.m uses to find E[ln(ST )].
• Finde the price by discounting the expected payoff obtained above to the present, i.e., with the factor1
e
−r(T −t)
.
• In order to make the obtained price robust, run your script several times and take the average of the results.
How much would you charge for the option?
1
It seems improbable that using the same discount rate as the expected return of the stock would lead to a correct result; surprisingly,
we will learn later that it does.
MonteCarlo2.m script
s = 100; %Stock's price now
mu = 0.1; %Annual return rate
dt = 1/252; %Time increment in years
sigma = 0.3; %Annual volatility (risk)
C = []; %The matrix in which each row will hold a price path
for q=1:10000
M =[];
M = normrnd(1+mu*dt, sigma*sqrt(dt), 1, 252); %252 (i.e. the whole year)
%of draws from normal
%distribution with expected
%value=1+mu*dt and std=
% sigma*sqrt(dt)
DP = cumprod(M); %Consecutive cumulative products of the above draws
TS = s*DP; %To obtain the time series of price we need to multiply
%by the initial price
C = [C;TS];
end
%Set the range on the plot and plot
%plot(C'); ...
%set(gca,'YLim',[50, 150]); set(gca,'XLim',[0, 253]);
LogLastPrice = log(C(:, 252));
mean(LogLastPrice) %This line will print the simulated expected value
%of the log of the price S_T

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

function Solution()

%Q1

Npath= 100; % number of simulated paths

mu=0.1;%annual return for stock

sigma=0.3;

S0=50;

dt=1/(21*12); %time increment in years

T=1/4;

Nt=21*3;

t=0:dt:T;

DW=zeros(Npath,Nt+1); %initialize the increments of brownian motions to zero

%every row contains values for the a path and is of size Nt+1

% DW(q,i)= W((i+1)*dt)-W(i*dt) where q is the path

%since W((i+1)*dt)-W(i*dt) ~ N(0,dt)=sqrt(dt)*N(0,1) and they are

%independent

DW(:,2:Nt+1)=normrnd(0,1,Npath,Nt)*sqrt(dt);

W=cumsum(DW,2); % cumulative sum of each row

S=S0*exp((mu-sigma^2/2)*repmat(t,Npath,1)+W);...