%% Price an Amortizing Cap Using a Linear Gaussian Two-Factor Model
% Define the ZeroCurve, a, b, sigma, eta, rho, and Notional parameters for the amortizing cap.
%

Settle = datenum('15-Dec-2007');
% Define ZeroCurve
ZeroTimes = [3/12 6/12 1 5 7 10 20 30]';
ZeroRates = [0.033 0.034 0.035 0.040 0.042 0.044 0.048 0.0475]';
CurveDates = daysadd(Settle,360*ZeroTimes);

irdc = IRDataCurve('Zero',Settle,CurveDates,ZeroRates);

% Define a, b, sigma, eta, and rho
a = .07;
b = .5;
sigma = .01;
eta = .006;
rho = -.7;

% Define the amortizing caps
CapMaturity = daysadd(Settle,360*[1:5 7 10 15 20 25 30],1);
Strike = [0.035 0.037 0.038 0.039 0.040 0.042 0.044 0.046 0.047 0.047 0.047]';
Notional = {{'15-Dec-2010' 100;'15-Dec-2014' 70;'15-Dec-2022' 40;'15-Dec-2037' 10}};

% Price the amortizing caps
Price = capbylg2f(irdc,a,b,sigma,eta,rho,Strike,CapMaturity, 'Notional', Notional)

% Copyright 2015 The MathWorks, Inc.