function [DeltaCall, DeltaPut, Gamma, Vega] = FormulaBSGreeks( S, K, r, tau, sigma, yield)
% Evaluation of the greeks (delta, gamma, vega) for call and put options
% under the Black-Scholes model.
%
% Input: S: Actual price of the underlying asset (can be a vector);
% K: Strike price;
% r: (continuous) short-time interest rate for the period;
% tau: time to maturity;
% sigma: volatility in the B-S model;
% yield: continuous dividend rate.
%
% Output: DeltaCall: value of the delta for the European call option;
% DeltaPut : value of the delta for the European put option;
% Gamma : value of the gamma for the European call option
% (same value for put option);
% vega : value of the vega for the European call option
% (same value for put option).
%
% N.B.: The time and rate must be on the same scale as the one used for
% estimating sigma. For example, if sigma was estimated with daily
% prices, then tau should be in days, and r should be the interest
% rate for 1 day.
if nargin < 6
yield =0;
end
s = S.*exp( -yield.* tau );
d1 = ( log( s./ K )+ r.* tau + (sigma.^2).* tau / 2 )./ ( sigma.* sqrt( tau ) );
z = normpdf(d1);
DeltaCall = exp( -yield.* tau ).* normcdf(d1);
DeltaPut = DeltaCall - exp( -yield.* tau ); % By put-call parity
Vega = s.*z.* sqrt( tau );
Gamma = exp( -yield.* tau ).*( z./s)./(sigma.*sqrt(tau));