%% 
% Exercise session 1. Ari-Pekka Perkkiö

%% 
% Exercise 2.2.1

type('europeancall.m');
type('europeanput.m');

%% 
% Exercise 2.2.2

% Plot European call as a function of the asset price


K1 = 50; % strike
K2 = 80; % another strike

sgrid=linspace(0,200,1000);



legendstrings = {append('Strike =', num2str(K1,2)), append('Strike =', num2str(K2,2))}; %num2str transforms numerical values into text (strings)

figure(1); plot(sgrid,europeancall(sgrid,K1),sgrid,europeancall(sgrid,K2));
legend(legendstrings{:});

%%
% Exercise 2.2.3

xgrid=linspace(0,100,100);
ygrid=linspace(0,100,100);
[xmesh,ymesh]=meshgrid(xgrid,ygrid);

K=20;
figure(2);
%surf(xgrid,ygrid,spreadcall(xmesh,ymesh,K));
mesh(xmesh,ymesh,spreadcall(xmesh,ymesh,K));
%%
% Publishing:
%
% Lines starting with "%% Section title" are sections.
%
% Lines following %% with % show in the published file (even when showCode
% below is set to false).
%
% Type the following to the command line:
%
% options.format = 'pdf';
%
% options.showCode = false;
%
% publish('solution1.m',options)

%%
% Do not execute publish() within the .m-file you want to publish!