Financial Toolbox™ Graphics Example 2
This example creates a three-dimensional plot showing how gamma changes relative to price for a Black-Scholes option. Recall that gamma is the second derivative of the option price relative to the underlying security price. The plot shows a three-dimensional surface whose z-value is the gamma of an option as price (x-axis) and time (y-axis) vary. It adds yet a fourth dimension by showing option delta (the first derivative of option price to security price) as the color of the surface.
if ~exist('normpdf') msgbox('The Statistics Toolbox is required to run this example.','Product dependency') return end
% Range of stock prices range = 10:70; span = length(range); j = 1:0.5:12; % Years until option expiration newj = j(ones(span,1),:)'/12; jspan = ones(length(j),1); newrange = range(jspan,:); pad = ones(size(newj));
zval = blsgamma(newrange, 40*pad, 0.1*pad, newj, 0.35*pad); color = blsdelta(newrange, 40*pad, 0.1*pad, newj, 0.35*pad);
Height is gamma (second derivative of option price with respect to stock price)
Color is delta (first derivative of option price with respect to stock price)
% Plotting Sensitivities of an Option figure('NumberTitle', 'off', ... 'Name', 'Call Option Price Sensitivity'); mesh(range, j, zval, color); xlabel('Stock Price ($)'); ylabel('Time (months)'); zlabel('Gamma'); title('Call Option Price Sensitivity'); axis([10 70 1 12 -inf inf]); view(-40,50) cbx = colorbar('horiz'); apos = get(gca,'Position'); cpos = get(cbx,'Position'); set(cbx,'Position',[cpos(1) .075 cpos(3) cpos(4)]) set(gca,'Position',[apos(1) .25 apos(3) .68]) box on