悬赏 30 个论坛币 未解决
% MATH1251: File = stock.m
% Simulate simple stock price process
% and estimate the expected value
clear
format compact
% Model parameters
% r = risk-free interest rate
r = 0.00539;
% volatility
sigma = 0.3081;
% Current stock price
S0 = 57437;
% Time horizon (years)
T = 0.83;
% Print model parameters
fprintf('Initial stock price S0 = %.2f\n', S0);
fprintf('Risk-free rate = %.2f%%, volatility = %.2f%%\n', 100*r, 100*sigma);
fprintf('Time horizon = %.2f years\n', T);
% Time step in years for daily increments
Dt = 1/252;
% All the time points
t = [0:Dt:T];
m = length(t)-1;
fprintf('Number of time steps = %d, time step = %.4f years\n', m, Dt);
% N = number of simulations
N = 8000;
k=55000;
%Model S(t + Dt)=S*exp((r-0.5*sigma^2)*T + sigma*sqrt(T)*Z);
% where wt is a standard normal random variable
Z = randn(m, N);
z = exp((r-0.5*sigma^2)*Dt + sigma*sqrt(Dt)*Z);
S = S0*[ones(1,N); cumprod(z)];
price = sum(S(end,:))/N;
fprintf('For %3d simulations, realassetprice = %.2f\n', N, price);
figure(1)
plot(t, S);
grid on
xlabel('t (years)')ylabel('real asset price S(t)')
title('real asset price')
有人知道怎么接着这段代码,算出欧式期权价值,并且画出欧式期权价格变动的图形吗? 拜托了