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','rend','z');

ops = blsprice(upm, spm, ir, tm(1), 0.3);
s = surf(up, sp, ops);
% colormap(winter)
shading interp
view(-110,30)
makelabels(tml,1)
light('Position',[0 0 1],'Style','infinite');
pause

for k=2:length(tm)
    ops = blsprice(upm, spm, ir, tm(k), 0.3);
    set(s,'zdata',ops)
    makelabels(tml,k)
    if k==1, pause; end
end




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



pause;
set(gcf, 'name', 'Volatility Surface');
ops = blsimpv1(upm, spm , ir, tm(1), 90);
s = surf(up, sp, ops);
set(gca, 'zlim', [0 2.5])
shading interp
makelabels(tml,1)
light('Position',[0 0 1],'Style','infinite');
for k=2:length(tm)
    ops = blsimpv1(upm, spm , ir, tm(k), 90);
    set(s,'zdata',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