全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 MATLAB等数学软件专版
3020 0
2014-08-29
悬赏 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')

有人知道怎么接着这段代码,算出欧式期权价值,并且画出欧式期权价格变动的图形吗? 拜托了

二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群