Code covered by the BSD License  

Highlights from
Exercises in Advanced Risk and Portfolio Management

from Exercises in Advanced Risk and Portfolio Management by Attilio Meucci
text and comments on solutions available at http://symmys.com/node/170

BlackScholesCall(spot,K,r,vol,T)
function [c,delta,cash] = BlackScholesCall(spot,K,r,vol,T)
% Black-Scholes price of a European call
% Inputs:
%   spot = spot price of underlying
%   K = strike of the call optioon
%   r = risk free rate
%   vol = volatility of the underlying as a fraction
%   T = time to maturity in years
% Outputs:
%   c = price of European call(s)
%   delta = delta of the call(s)
%   cash = cash to be held in a replicating portfolio
%
d1 = (log(spot./K) + (r + vol.*vol/2).*T)./(vol.*sqrt(T));
d2 = d1 - vol.*sqrt(T);
delta = normcdf(d1);
cash =  -K.*exp(-r.*T).*normcdf(d2);
c = spot.*delta + cash;

Contact us at files@mathworks.com