%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%% %%% Convolution quadrature option pricer for European option under %%% Black-Scholes-Merton model %%% %%% Copyright (C) 2008 Vladimir Surkov %%% %%% %%% This program is free software: you can redistribute it and/or modify %%% it under the terms of the GNU General Public License as published by %%% the Free Software Foundation, either version 3 of the License, or %%% (at your option) any later version. %%% %%% This program is distributed in the hope that it will be useful, %%% but WITHOUT ANY WARRANTY; without even the implied warranty of %%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the %%% GNU General Public License for more details. %%% %%% You should have received a copy of the GNU General Public License %%% along with this program. If not, see . %%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% function [values_call, values_put, time] = ConvolutionQuadrature_European_BlackScholesMerton(S, K, T, sigma, r, q) values_call = zeros(length(S), length(K)); values_put = zeros(length(S), length(K)); time = cputime; payoff_call = @(x,k)(max(exp(x)-k,0)); payoff_put = @(x,k)(max(k-exp(x),0)); pdf = @(x)normpdf(x, (r-q-sigma^2/2)*T, sigma*sqrt(T)); for iter_s = 1:length(S) x = log(S(iter_s)); for iter_k = 1:length(K) integrand = @(y)(payoff_call(x+y, K(iter_k)).*pdf(y)); values_call(iter_s, iter_k) = exp(-r*T)*quad(integrand, -5, 5); integrand = @(y)(payoff_put(x+y, K(iter_k)).*pdf(y)); values_put(iter_s, iter_k) = exp(-r*T)*quad(integrand, -5, 5); end end time = cputime - time;