%% Price a Cap Using Normal Model for Negative Rates
% Consider an investor who gets into a contract that caps the interest rate on a $100,000 loan at –.08% quarterly compounded for 3 months, starting on January 1, 2009. Assuming that on January 1, 2008 the zero rate is .069394% continuously compounded and the volatility is 20%, use this data to compute the cap price. First, calculate the RateSpec, and then use capbynormal to compute the CapPrice.

ValuationDate = 'Jan-01-2008';
EndDates ='April-01-2010';
Rates = 0.0069394;
Compounding = -1;
Basis = 1;

RateSpec = intenvset('ValuationDate', ValuationDate, ...
'StartDates', ValuationDate,'EndDates', EndDates, ...
'Rates', Rates,'Compounding', Compounding,'Basis', Basis);


Settle = 'Jan-01-2009'; % cap starts in a year
Maturity = 'April-01-2009';
Volatility = 0.20;
CapRate = -0.008;
CapReset = 4;
Principal=100000;

CapPrice = capbynormal(RateSpec,  CapRate, Settle, Maturity, Volatility,...
'Reset',CapReset,'ValuationDate',ValuationDate,'Principal', Principal,...
'Basis', Basis)

% Copyright 2012 The MathWorks, Inc.