How to plot a monte carlo simulation
조회 수: 10 (최근 30일)
이전 댓글 표시
I am trying to price a call option using a monte carlo simulation and I have priced it, but I want to plot how it changes given the number of steps. My code is as follows:
function Value=cw2q6(S,E,T,r,sigma,A,M)
S=100;
E=90;
T=2;
r=0.03;
sigma=0.2;
A=110;
M=10000;
C = zeros(1,M);
for i=1:M
psi=randn;
ST = S*exp((r-0.5*sigma^2)*T+sigma*psi*sqrt(T));
if ST>E
payoff = A;
elseif ST==E
payoff = A/2;
elseif ST<E
payoff = 0;
end
C(1,i)=payoff*exp(-r*T);
end
Value = sum(C)/M;
end
I know that as I increase the number of steps the answer gets more accurate, I just want to show how the accuracy changes as we increase the number of steps. Any help is appreciated.
댓글 수: 0
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Graphics Performance에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!