S0 = 100;

sigma = 0.2;
rf = 0.05;

T1 = 1;
T2 = 10;

alpha = 0.9;

M = 100000;

Z1 = randn(M,1); % draw M samples from std normal


ST1 = S0 * exp( (rf-0.5*sigma^2)*T1 + sigma*sqrt(T1) * Z1  );


Z3 = randn(M,1);
ST2 = ST1 .* exp( (rf-0.5*sigma^2)*(T2-T1) + sigma*sqrt(T2-T1) * Z3 );


payoff = max( ST2 - ST1*alpha, 0);

m1 = mean(payoff); % estimator of the expected value of payoff under Q measure
err1 = std(payoff) / sqrt(M); % error in the estimator


dp = ( log(1/alpha) + (rf+0.5*sigma^2)*(T2-T1) ) / ( sigma*sqrt(T2-T1));
dm = dp - sigma*sqrt(T2-T1);

eta = normcdf( dp ) - alpha*exp(-rf*(T2-T1))*normcdf(dm);

value_est = exp(-rf*T2) * m1;
value = S0 * eta;


