clear; clc; close all;

s0 = 256;
r = 0.01;
v = 0.25;
T = 16 / 365;
X = 260;

N = 10;
path = 1e4;
dt = T / N;

S = zeros(1, N + 1);
S(1) = s0;
p = zeros(1, path);
c = 0;

figure; hold on;
for j = 1 : path
    for i = 2 : length(S)
        S(i) = S(i - 1) * (1 + r * dt + v * sqrt(dt) * randn(1));
    end
    plot(S, '.--'); grid on;
    p(j) = S(end);
    payoff = p(j) - X;
    if payoff > 0
        c = c + payoff;
    end
end
figure; histogram(p, 'binwidth', 10);
c = c / path * exp(-r * T)
