%% Price a Cap Using a Linear Gaussian Two-Factor Model
% Define the ZeroCurve, a, b, sigma, eta, and rho parameters to price the cap.

Settle = datenum('15-Dec-2007');
  
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);
  
a = .07;
b = .5;
sigma = .01;
eta = .006;
rho = -.7;
  
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]';
  
Price = capbylg2f(irdc,a,b,sigma,eta,rho,Strike,CapMaturity)

% Copyright 2015 The MathWorks, Inc.