How can I make my Binomial Option Pricing, work for lists of variables, not just single variables?
1 次查看(过去 30 天)
显示 更早的评论
% S: spot price
% K: exercice price
% r: interest rate
% sig: volatility
% T: time to maturity
% N: number of steps in binomial tree
R = exp(r*(T/N));
Rinv = 1.0/R;
u = exp(sig*sqrt(T/N));
d = 1/u;
p_up = (R-d)/(u-d);
p_down = 1-p_up;
prices = zeros(N+1);
prices(1) = S*(d^N);
uu = u*u;
for i=2:N+1
prices(i) = uu*prices(i-1);
end
call_values = max(0, (prices-K));
for step=N:-1:1
for i=1:N+1
call_values(i) = (p_up*call_values(i+1)+p_down*call_values(i))*Rinv;
prices(i) = d*prices(i+1);
call_values(i) = max(call_values(i),prices(i)-K);
end
end
CallPrice=call_values(1);
%I attached the lists from a table %using S=data(:,1); attaching it to the first colum of data
Any help would be greatly appreciated, Thanks, Misha.
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Price and Analyze Financial Instruments 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!