function [c,p]=ucoption(S,X,sigma,r,T,M)
sig2=sigma^2;
srT=sqrt(T);
srTa=sigma*srT;
c=0;
p=0;
for i=1:M
ST=S*exp((r-0.5*sig2)*T+srTa*randn);
c=c+max(ST-X,0);
p=p+max(X-ST,0);
end
c=c/M;
p=p/M;
[Call,Put] = blsprice(S, X, r, T, sigma);
error=[c,p]-[Call,Put]
%可以试试 [c,p]=ucoption(10,10,0.3,0.05,0.5,10^4*100); |