% Program which uses the solution of the Black Scholes PDE from MFD pp 48

clear 
clc

r = 0.06;
sigma = 0.7;

S = 40;
E = 30;

T = 30; %days till expiry

t = 0; %current time

t = t/365;
T = T/365;

d1 = (log(S/E) + (r + 0.5*sigma*sigma)*(T - t))/(sigma*sqrt(T-t));

d2 = (log(S/E) + (r - 0.5*sigma*sigma)*(T - t))/(sigma*sqrt(T-t));

C = S.*normcdf(d1) - E*exp(-r*(T-t))*normcdf(d2);

Cdelta = normcdf(d1);

P = E*exp(-r*(T-t))*normcdf(-d2) - S.*normcdf(-d1);

Pdelta = Cdelta - 1;

plot(S,C);