% Copyright (c) 2001-2009 by Ales Cerny %************************************************************************% % chapter6sect2b.m - supplementary program to % % Ales Cerny (2009) Mathematical Techniques in Finance (2nd ed.) % % Princeton University Press http://press.princeton.edu/titles/9079.html % %************************************************************************% % This code is provided 'as-is', without any express or implied warranty. % % Permission is granted to anyone to use this code for any purpose, % subject to the following restrictions: % % 1. The origin of this code must not be misrepresented; you must not % claim that you wrote the original code. % 2. Modified code versions must be plainly marked as such, and must not % be misrepresented as being the original code. % 3. This notice may not be removed from any source distribution. % NOTICE TO STUDENTS: To avoid accusations of plagiarism, if you use this % code or its modifications in assessed work you should prepend it with a % note stating: % "This is the original/modified version of the code chapter6sect2b.m by % Ales Cerny (2009), Mathematical Techniques in Finance (2nd ed.), % Princeton University Press. The original version is available from % http://www.martingales.info/mtfweb2". % A similar acknowledgement should appear prominently inside your written % report. % This program compares binomial option prices with the Black-Scholes limit clear; % clear the workspace clc; % clear screen %***************************% % trading time % % parameters % %***************************% Minute = 1; Hour = 60; HoursInDay = 8; DaysInWeek = 5; DaysInMonth = 21; Day = HoursInDay*Hour; Week = DaysInWeek*Day; Month = DaysInMonth*Day; Year = 12*Month; %***************************% % Hedging Parameters % %***************************% T = 3*Month; % Time to maturity RehedgeInterval = 60 * Minute; % Trading period S0 = 5100; % Initial stock price strike = 5355; %***************************% % Transformation of % % log returns % %***************************% UnitTime = Month; R1safe = 1.0033; % monthly safe return R1 = [1.053 0.965]; % monthly return PDistr = [0.5 0.5]; % prob. density of monthly returns lnR1 = log(R1); % monthly log return mu1 = lnR1 * PDistr'; % expected monthly log return sig1= sqrt(((lnR1-mu1).^2)*PDistr'); % volatility of monthly log return dt = RehedgeInterval/UnitTime; lnRdt = mu1*dt+(lnR1-mu1)*sqrt(dt); % log return over rehedging interval Rdt= exp(lnRdt); Rdtsafe=R1safe^dt; %************************% % Risk-neutral % % probabilities % %************************% QDistr=[Rdtsafe-Rdt(2) Rdt(1)-Rdtsafe]./(Rdt(1)-Rdt(2)); %************************% % grid indexation % %************************% Tidx=ceil(T/RehedgeInterval)+1; % Number of trading dates dlnS=lnRdt(1)-lnRdt(2); % increment on log price grid highlnRdt=lnRdt(1); % the highest return over one period % there are tt live cells at time tt, highest stock price at the top % log price at cell 1 at time tt is ln(S0)+(tt-1)*highlnRdt % log price at cell ii at time tt is ln(S0)+(tt-1)*highlnRdt-(ii-1)*dlnS %************************% % option payoff % %************************% S_T = log(S0)+(Tidx-1)*highlnRdt-(0:(Tidx-1))*dlnS; % log price at maturity S_T = exp(S_T'); % stock price at maturity C = max([(S_T-strike)';zeros(1,length(S_T))]); % option payoff at maturity %************************% % main loop % %************************% tic; % start of computation for tt= Tidx-1:-1:1 Cnext = C; % option value in next period for ii = 1:1:tt C(ii)=(QDistr*Cnext(ii:ii+1)')/Rdtsafe; % risk-neutral pricing end end elapsedtime = toc; disp('___________________________________________________'); disp(' '); % format /rd 12,0; disp(sprintf(' trading frequency in minutes %12.0f ', RehedgeInterval)); disp(' '); % format /rd 12,4; disp(sprintf(' binomial price %12.5f ', C(1,1))); disp(sprintf(' Black-Scholes price %12.5f ', BSCall(S0,strike,log(R1safe),T/UnitTime,sig1))); disp(' '); %format /rd 12,6; disp(sprintf(' binomial delta %12.6f ', (Cnext(1)-Cnext(2))/S0/(Rdt(1)-Rdt(2)))); disp(sprintf(' Black-Scholes delta %12.6f ', normcdf((log(S0/strike)+(sig1^2/2+log(R1safe))*T/UnitTime)/(sig1*sqrt(T/UnitTime))))); disp(' '); % format /rd 12,2; disp(sprintf(' required time in seconds %12.1f ', elapsedtime)); disp('___________________________________________________'); disp(' ');