2013年3月12日 星期二
Matlab 模擬股價 以及 選擇權價格 Simulate Stock Price and Option Value
S_0 = 100
sigma = 0.4;
r = 0.012;
dividend = 0.05;%股利
Start_t = 0;
Maturity_T = 5;
Tday = 360;
dt = 1;
StrikePrice = 80;
t_i = (0:dt:Maturity_T*Tday)/Tday;
PathM = 10000; %路徑
SizeM = size(t_i,2);
S(1:PathM,1) = S_0;
h = dt/Tday;
for j=2:SizeM
S(1:PathM,j)=S(1:PathM,j-1)+r*S(1:PathM,j-1).*repmat((t_i(1,j)-t_i(1,j-1)),PathM,1)+sigma*S(1:PathM,j-1).*repmat(sqrt(h),PathM,1).*randn(PathM,1);
end
%模擬的值
CallValue=mean(max((S(:,SizeM)-StrikePrice),0))*exp(-r*Maturity_T)
PutValue=mean(max((StrikePrice-S(:,SizeM)),0))*exp(-r*Maturity_T)
%Matlab內建的公式值
[Call, Put] = blsprice(S_0, StrikePrice, r, Maturity_T, sigma, 0)
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言