Warning: Matrix is singular to working precision.

1 vue (au cours des 30 derniers jours)
Steven Semeraro
Steven Semeraro le 30 Déc 2020
Modifié(e) : madhan ravi le 30 Déc 2020
I am trying to create a 3D plot of option Vanna. However, I have this error "Warning: Matrix is singular to working precision." What am I doing wrong?
% Black Scholes Vanna
% Steven Semeraro
sigma = ones(100, 100) * 0.2;
stock = ones(100, 100) * 50;
x = 1:100;
y = 0.01:0.01:1;
[strike, time] = meshgrid(x, y);
% The Error is in these lines
d1 = log(stock / strike) + (sigma^2 / 2) * time;
d1 = d1 / sigma * sqrt(time);
d2 = log(stock / strike) + (sigma^2 / 2) * time;
d2 = d2 / sigma * sqrt(time);
vanna = -((exp(-(d1^2/2))) / (sqrt(2 * pi)) ) * d2 * sigma;
surf(strike, time, vanna);
title("S = 50, Vol = 0.2");
xlabel("Strike Price");
ylabel("Time To Expiration");
zlabel("Vanna");
  1 commentaire
Mathieu NOE
Mathieu NOE le 30 Déc 2020
hello
I cannot say if the code is correct , but you are doing multiple matrix divisions, like stock / strike
but you cannot make a reliable inversion of strike because all lines are identical
strike =
Columns 1 through 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14
.....
same comment every time you do these matrix divisions

Connectez-vous pour commenter.

Réponses (1)

madhan ravi
madhan ravi le 30 Déc 2020
Modifié(e) : madhan ravi le 30 Déc 2020
% Black Scholes Vanna
% Steven Semeraro
sigma = ones(100, 100) * 0.2;
stock = ones(100, 100) * 50;
x = 1:100;
y = 0.01:0.01:1;
[strike, time] = meshgrid(x, y);
d1 = log(stock ./ strike) + (sigma.^2 / 2) .* time;
d1 = (d1 ./ sigma) .* sqrt(time);
d2 = log(stock ./ strike) + (sigma.^2 / 2) .* time;
d2 = (d2 ./ sigma) .* sqrt(time);
vanna = -((exp(-(d1.^2/2))) / (sqrt(2 * pi)) ) .* d2 .* sigma;
surf(strike, time, vanna);
title("S = 50, Vol = 0.2");
xlabel("Strike Price");
ylabel("Time To Expiration");
zlabel("Vanna");

Catégories

En savoir plus sur Financial Toolbox dans Help Center et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by