%% Assignment 2, problem 1(a),(b)

%% Problem 1(a)
format compact
rho=.2; u = 1.5; d = .5;

beta = 1/(1+rho)
q = (1+rho-d)/(u-d)

% option prices for t2:
V21 = beta*(q*0+(1-q)*0)
V22 = beta*(q*1+(1-q)*4)
V23 = beta*(q*3+(1-q)*4)
V24 = beta*(q*5+(1-q)*6)

% option prices for t1:
V11 =  beta*(q*V21+(1-q)*V22)
V12 =  beta*(q*V23+(1-q)*V24)

% option price for t0:
V0 = beta*(q*V11+(1-q)*V12)

%% Problem 1(b): Find x-values
% We use Delta-hedging:

% at time t2 change the number of stocks in portfolio to:
x21 = (0-0)/(27-9)
x22 = (1-4)/(9-3)
x23 = (3-4)/(9-3)
x24 = (5-6)/(3-1)

% at time t1 change the number of stocks in portfolio to:
x11 = (V21-V22)/(18-6)
x12 = (V23-V24)/(6-2)

% at time t0 the number of of stocks in portfolio is
x0 = (V11-V12)/(12-4)

%% Problem 1(b): For stock price path (8,4,2,1) find y-values
S0 = 8; S1=4; S2=2; S3=1;

% time t0:
U0 = V0           % initial fortune
y0 = U0 - x0*S0   % buy x0 stocks, remaining amount goes into bank account

% time t1:
U1 = (1+rho)*y0 + x0*S1  % fortune at time t1, same as V12
y1 = U1 - x12*S1   % now: x1=x12 stocks, remaining amount goes into bank account

% time t2:
U2 = (1+rho)*y1 + x12*S2  % fortune at time t1, same as V24
y2 = U2 - x24*S2   % now: x2=x24 stocks, remaining amount goes into bank account

% time t3:
U3 = (1+rho)*y2 + x24*S3  % fortune at time t1, same as V3=6



