%% Big binomial tree with different choices of u and d

S0 = 100; E = 105; tau = 5; r = 0.02; mu = 0.07; sigma = 0.2; 
depth = 10;  dt = tau / depth;

% From notes
u = 1 + mu*dt + sigma*sqrt(dt);
d = 1 + mu*dt - sigma*sqrt(dt);
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

% From notes --- WRONG POWER
u = 1 + mu*dt + sigma*dt^0.3;
d = 1 + mu*dt - sigma*dt^0.3;
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

% Alt from notes
u = exp((mu-sigma^2/2)*dt + sigma*sqrt(dt));
d = exp((mu-sigma^2/2)*dt - sigma*sqrt(dt));
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

% Cox - Ross - Rubinstein
u = exp(sigma*sqrt(dt));
d = exp(-sigma*sqrt(dt));
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

% McDonald
u = exp(r*dt + sigma*sqrt(dt));
d = exp(r*dt - sigma*sqrt(dt));
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

% q=1/2
u = exp(r*dt)*(1 + sigma*sqrt(dt));
d = exp(r*dt)*(1 - sigma*sqrt(dt));
BinomialTree(S0, @(S) max(S-E,0), 0, r, tau, u, d, depth, 1);

fprintf('\n');

%% Result using the BSM formula

[C,Cdelta] = BSMcall(S0,E,r,sigma,tau);
fprintf('BSM value is %.6f with Delta %.2f\n', C, Cdelta);
