How can I make my Binomial Option Pricing, work for lists of variables, not just single variables?
3 views (last 30 days)
Show older comments
% 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 Comments
Answers (0)
See Also
Categories
Find more on Price and Analyze Financial Instruments in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!