Code covered by the BSD License  

Highlights from
Financial Seminar Demos

from Financial Seminar Demos by Michael Weidman
Demos commonly used at The MathWorks financial modeling seminars.

oprice
function oprice

close all
ir = 0.03;
sp = linspace(660, 780, 15);
up = linspace(670, 740, 15);
[upm, spm] = meshgrid(up, sp);
tm = linspace(50/252, 10/252, 50);
tml = linspace(50, 10, 50);

% [upm, tmm] = meshgrid(up, tm);
% 
% cpm = blsgamma(upm, 700, ir, tmm, 0.3);
% surf(up, tm, cpm)
% 
% return

figure('doublebuffer','on','numbertitle','off',...
    'name', 'Call Option Price');

for k=1:length(tm)
    ops = blsprice(upm, spm, ir, tm(k), 0.3);
    surf(up, sp, ops)
    view(-110,30)
    makelabels(tml,k)
    if k==1, pause; end
end

pause;
set(gcf, 'name', 'Call Option Gamma');
for k=1:length(tm)
    ops = blsgamma(upm, spm, ir, tm(k), 0.3);
    surf(up, sp, ops)
    set(gca, 'zlim', [0 0.01])
    makelabels(tml,k)
end



pause;
set(gcf, 'name', 'Volatility Surface');
for k=1:length(tm)
    ops = blsimpv1(upm, spm , ir, tm(k), 90);
    surf(up, sp, ops)
    set(gca, 'zlim', [0 2.5])
    makelabels(tml,k)
end


function makelabels(tml,k)

h = title(['Time to maturity: ', num2str(round(tml(k))), ' days']);
set(h, 'fontsize', 12, 'fontweight', 'demi');
xlabel('Underlying Price');
ylabel('Strike Price');
drawnow

Contact us at files@mathworks.com