%% Price a Portfolio Containing Two Cash Flow Instruments
% Price a portfolio containing two cash flow instruments paying interest annually over the four-year period from January 1, 2017 to June 1, 2020.
% Load the file deriv.mat, which provides CIRTree. The CIRTree structure contains the time and interest-rate information required to price the instruments.

load deriv.mat;

% The valuation date (settle date) specified in the CIRTree is January 1, 2017 (serial date number 736696).

CIRTree.RateSpec.ValuationDate 

% Provide values for the other required arguments.

CFlowAmounts =[5 NaN 5.5 105; 5 0 6 105];
CFlowDates = [736847,NaN,737061,737212; 
              737426,737577,737791,737943];

% Compute the prices of the two cash flow instruments using cfbycir.

[Price,PriceTree] = cfbycir(CIRTree, CFlowAmounts, CFlowDates,... 
CIRTree.RateSpec.ValuationDate)

% Copyright 2012 The MathWorks, Inc.