Error with Difference line
Ältere Kommentare anzeigen
% PlotBLS with varying dS
S = 0:1:10;
S0 = 60;
K = 62;
r = 0.09
sigma = 0.5
for T=3:-0.5:0
C1 = blsprice(S0+S,K,r,T,sigma);
C0 = blsprice(S0,K,r,T,sigma);
delta = blsdelta(S0,K,r,T,sigma);
gamma = blsgamma(S0,K,r,T,sigma);
Difference = (C1[T]-(C0+(delta*S)+(0.5*gamma*(S^2))));
plot(S,Difference);
hold on;
end
axis ([0 10 -10 50]);
grid on
Antworten (1)
Geoff Hayes
am 12 Okt. 2016
Manish - is the error message Unbalanced or unexpected parenthesis or bracket.? If so, look closely at this line of code
Difference = (C1[T]-(C0+(delta*S)+(0.5*gamma*(S^2))));
Since C1 is an array, you need to use the round brackets to access elements within it. Just change the above line to
Difference = (C1(T)-(C0+(delta*S)+(0.5*gamma*(S^2))));
and try again.
4 Kommentare
Manish Abbi
am 12 Okt. 2016
Bearbeitet: Walter Roberson
am 12 Okt. 2016
Walter Roberson
am 12 Okt. 2016
What error message are you seeing? Please post everything that shows up in red.
Manish Abbi
am 12 Okt. 2016
Walter Roberson
am 12 Okt. 2016
Does it say something about an unknown function or variable "blsdelta"? Does it say something about it being the wrong phase of the moon? Does it say that the weasel made the rich programmer do it?
Kategorien
Mehr zu Time Series Events finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!