//
// EXERCISE 1: PAYOFFS OF OPTIONS AND OPTION STRATEGIES
//

// -------------------------- 
//   DEFINITIONS OF PAYOFFS
// -------------------------- 

function [cp]=CallPayoff(S,E)
    cp=max(S-E,0);
endfunction;

function [pp]=PutPayoff(S,E)
    pp=max(E-S,0);
endfunction;

figure(1);
// white background of the figure
a=gca();
a.background=color("white");
a=gcf();
a.background=color("white");

s=0:100;
plot(s,CallPayoff(s,50)-5);
legend("call, E=50, price=5");

plot(s,0,'r');

xlabel("stock price]"); ylabel("profit");
title("Profit diagram of a call option");

// -------------------------- 
//   EXERCISE 1: put option
// -------------------------- 
figure(2);
a=gca();
a.background=color("white");
a=gcf();
a.background=color("white");


// ----------------------------- 
//   EXERCISE 2: market prices
// ----------------------------- 
figure(2);
a=gca();
a.background=color("white");
a=gcf();
a.background=color("white");

