clear; clc; close all;

s0 = 230;
r = 0.05;
v = 0.25;
T = 1;
N = 250;
dt = T / N;

% S = zeros(1, N + 1);
% S(1) = s0;
% for i = 2 : N + 1
%     S(i) = S(i - 1) * (1 + r * dt + v * sqrt(dt) * randn(1));
% end
figure;
f_prices = zeros(1, 10000);
for i = 1 : 10000
    ds = (1 + r * dt + v * sqrt(dt) * randn(1, N));
    S = s0 * cumprod([1, ds]);
    plot(S); hold on;
    f_prices(i) = S(end);
end
grid on;
xlabel('Trading day'); ylabel('Price');
figure;
hist(f_prices, 100); grid on;

X = 250;
c = exp(-r * T) * sum(f_prices(f_prices - X > 0) - X) / 10000








