Options Greeks – Matlab Code

In this Matlab code, we provide graphs of options Greeks as functions of the initial stock price. The Greeks provide useful information on the sensitivity of an option’s price over multiple factors. In this example, we include delta, theta, vega, rho and gamma.

function greeks(S1, S2, X, r, sigma, T)
echo off;
S0 = S1 : S2;

% plot delta
subplot(3,2,1);
d1 = (log(S0./X) + (r + 0.5 * (sigma.^2)).*T )./ (sigma.*sqrt(T));
d2 = d1 - sigma.*T;
bsc1 = S0.* normcdf(d1) - X.* exp(-r.* T).* normcdf(d2);
bsc2 = (S0.* normcdf(d1) + 0.01 * normcdf(d1)) - X.* exp(-r.* T).* normcdf(d2);
delta2 = (bsc2 - bsc1) / 0.01;
plot(S0, delta2);
title('Black-Scholes delta');

% plot theta
subplot(3,2,2);
d1=(log(S0./X) + (r + 0.5 * (sigma.^2)).*T )./ (sigma.*sqrt(T));
d2 = d1 - sigma.*T;
c1=0.5*sigma.*S0.*normpdf(d1)./sqrt(T);
c2=X.*r.*exp(-r.*T).*normcdf(d2);
theta = c1 + c2;
plot(S0, theta);
title('Black-Scholes theta');

% plot vega
subplot(3,2,3);
d1=(log(S0./X) + (r + 0.5 * (sigma.^2)).*T )./ (sigma.*sqrt(T));
vega = S0.*normpdf(d1).*sigma.*sqrt(T);
plot(S0,vega);
title('Black-Scholes vega');

% plot rho
subplot(3,2,4);
d1=(log(S0./X) + (r + 0.5 * (sigma.^2)).*T )./ (sigma.*sqrt(T));
d2 = d1 - sigma.*T;
rho = X.*T.*exp(-r.*T).*normcdf(d2);
plot(S0,rho);
title('Black-Scholes rho');

% plot gamma
subplot(3,2,5);
d1=(log(S0./X) + (r + 0.5 * (sigma.^2)).*T )./ (sigma.*sqrt(T));
gamma = normpdf(d1)./(S0.*sigma.*sqrt(T));
plot(S0,gamma);
title('Black-Scholes gamma');

echo on;

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s