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 个)

类别

Help CenterFile 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!

Translated by