Warning: Matrix is singular to working precision.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Mathieu NOE
2020-12-30
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
回答(1 个)
madhan ravi
2020-12-30
编辑:madhan ravi
2020-12-30
% 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");
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Financial Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!