| fxoptions( S0, X, rd, rf, T, vol, style)
|
function fxoptions( S0, X, rd, rf, T, vol, style)
% fxoptions - valuation of European and American call and put options
% on foreign exchange using Garman-Kohlhagen model.
%
% fxoptions( S0, X, rd, rf, T, vol, style)
%
%*************************************************************************
%
%INPUTS:
%
% S0 - Current spot exchange rate (1 unit of foreign currency per
% domestic currency)
%
% X - Strike (i.e., exercise) price of the option.
%
% rd - Annualized continuously compounded domestic risk-free rate of return
% over the life of the option, expressed as a positive decimal
% number.
%
% rf - Annualized continuously compounded foreign risk-free rate of return
% over the life of the option, expressed as a positive decimal
% number.
%
% T - Time to expiration of the option, expressed in years.
%
% vol - Annualized exchange rate volatility.
%
% style - 'E' or 'e' for a European style call or put option,
% 'A' or 'a' for an American style call or put option.
%
%**************************************************************************
%
% Example: from John Hull's book, 15.25:
% Suppose that the spot price of the Canadian dollar is US $0.85 and
% that the CAD|USD exchange rate has a volatility of 4% per annum. The
% risk-free rates of interest in canada and the United States are 4%
% and 5% per annum, respectively.
% Calculate the value of a European call option to buy one Canadian dollar
% for US$0.85 in nine months.
%
%
% fxoptions( .85, .85, 5/100, 4/100, 9/12, 4/100, 'e')
%
% European Call: $0.014703
% European Put: $0.008540
%
%**************************************************************************
% Rodolphe Sitter - MSFM Student - The University of Chicago
% April 17, 2009
%**************************************************************************
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% EUROPEAN OPTIONS - GARMAN-KOHLHAGEN MODEL
if strcmp(style, 'E')||strcmp(style, 'e')
F=S0*exp((rd-rf).*T);
d1=log(F./X)./(vol.*sqrt(T))+vol.*sqrt(T)/2;
d2=log(F./X)./(vol.*sqrt(T))-vol.*sqrt(T)/2;
European_call = exp(-rd.*T).*(F.*normcdf(d1)-X.*normcdf(d2));
European_put = European_call+(X-F)*exp(-rd.*T);
fprintf('European Call: $%0.5g \n',European_call)
fprintf('European Put: $%0.5g \n\n',European_put)
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% AMERICAN OPTIONS - GARMAN-KOHLHAGEN MODEL
if strcmp(style, 'A')||strcmp(style, 'a')
%TRINOMIAL TREE
N=10^3;
dt=T/N;
dx=vol*sqrt(3*dt);
S=S0*exp((N:-1:-N)*dx)';
American_put=max(X-S,0);
American_call=max(S-X,0);
nu= rd-rf-vol^2/2;
Pu=.5*((vol^2*dt+nu^2*dt^2)/dx^2+nu*dt/dx);
Pd=.5*((vol^2*dt+nu^2*dt^2)/dx^2-nu*dt/dx);
Pm= 1-(vol^2*dt+nu^2*dt^2)/dx^2;
D=exp(-rd*dt);
for t=N-1:-1:0
American_put=max(X-S(N-t+1:N+t+1),D*(Pu*American_put(1:2*t+1)+Pm*American_put(2:2*t+2)+Pd*American_put(3:2*t+3)));
American_call=max(S(N-t+1:N+t+1)-X,D*(Pu*American_call(1:2*t+1)+Pm*American_call(2:2*t+2)+Pd*American_call(3:2*t+3)));
end
% BINOMIAL TREE
u=exp(vol*sqrt(dt)); d=1/u;
p=(exp((rd-rf)*dt)-d)/(u-d);
Up=flipud(cumprod(ones(N+1,1)*u))/u;
Down=cumprod(ones(N+1,1)*d)/d;
ST=S0*(Up.*Down);
American_put_b=max(X-ST,0);
American_call_b=max(ST-X,0);
for i=1:N
Up=flipud(cumprod(ones(N-i+1,1)*u))/u;
Down=cumprod(ones(N-i+1,1)*d)/d;
ST=S0*(Up.*Down);
American_put_b=max(X-ST,D*(p*American_put_b(1:end-1)+(1-p)*American_put_b(2:end)));
American_call_b=max(ST-X,D*(p*American_call_b(1:end-1)+(1-p)*American_call_b(2:end)));
end
fprintf('AMERICAN CALL:\n')
fprintf('$%0.5g (Binomial Tree)\n',American_call_b)
fprintf('$%0.5g (Trinomial Tree)\n',American_call)
fprintf('\nAMERICAN PUT:\n')
fprintf('$%0.5g (Binomial Tree)\n',American_put_b)
fprintf('$%0.5g (Trinomial Tree)\n\n',American_put)
end
|
|