Stimulation of stock price using Brownian movement

st gives the value of stock price at time t.

% single path brownian movement stimulation
% stimulation of stock price using brownian movement
clear;clc;
mu = 0.07;
sig = 0.25;
t = 0.25;
m = 1000; % no of stimulations
z = randn(m,1);
s0 = 100; % initial stock price 
st = s0*exp((mu-sig^2/2)*t+sig*sqrt(t)*z);
plot(st);

call option and put option price

% single path brownian movement stimulation
% stimulation of stock price using brownian movement
% pricing call and put option 
clear;clc;
mu = 0.07;
sig = 0.25;
t = 0.25;
m = 1000; % no of stimulations
z = randn(m,1);
s0 = 100;
st = s0*exp((mu-sig^2/2)*t+sig*sqrt(t)*z);
plot(st);

k = 100; % strike price
call_payoff = max(0,st-k);
put_payoff = max(0,k-st);

% mean of payoff is expected payoff
mean_call = mean(call_payoff);
mean_put = mean(put_payoff);

%call option price today
call = exp(-mu*t)*mean_call;
%put option price today
put = exp(-mu*t)*mean_put;

When current price depends on previous stock price

% single path brownian movement stimulation
%when current price of a stock is dependent on its previous price
clear;clc;
mu = 0.05;
sig = 0.15;
t1 = 0.25;
n = 200; % no of steps in one path
t = t1/200; % dividing time period in 200 no of steps or parts
s(1) = 100; % initial stock price

%use a for loop to insert the dependency
for i = 2:n
    s(i) = s(i-1)*exp((mu-sig^2/2)*t+sig*sqrt(t)*randn);
end

% s is a column matrix so transpose it to row matrix
plot(s');

Multiple path brownian movement

% multiple path brownian movement
clear;clc;
mu = 0.05;
sig = 0.15;
t1 = 0.25;
n = 20;
t = t1/n;
m=1000;
z = randn(m,n);
st = zeros(m,n);
st(:,1) = 100;

% use nested for loop to store each path in 'st'
for j=1:m
    for i = 2:n
        st(j,i) = st(j,i-1)*exp((mu-sig^2/2)*t+sig*sqrt(t)*z(j,i-1));
    end
end
plot(st')

results matching ""

    No results matching ""