cfport

Portfolio form of cash flow amounts

Description

example

[CFBondDate,AllDates,AllTF,IndByBond] = cfport(CFlowAmounts,CFlowDates) computes a vector of all cash flow dates of a bond portfolio, and a matrix mapping the cash flows of each bond to those dates. Use the matrix for pricing the bonds against a curve of discount factors.

example

[CFBondDate,AllDates,AllTF,IndByBond] = cfport(___,TFactors) specifies options using one or more optional arguments in addition to the input arguments in the previous syntax.

Examples

collapse all

Use cfprice to compute the price for a cash flow given yield to maturity.

Define data for the yield curve.

Settle = datenum('01-Jul-2003');
Yield = .05;
CFAmounts = [30;40;30];
CFDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'});

Compute the Price.

Price = cfprice(CFAmounts, CFDates, Yield, Settle)
Price = 3×1

   28.4999
   36.1689
   25.8195

Use cfprice to compute the price for a cash flow given yield to maturity using datetime inputs.

Settle = datenum('01-Jul-2003');
Yield = .05;
CFAmounts = [30;40;30];
CFDates = datenum({'15-Jul-2004', '15-Jul-2005', '15-Jul-2006'});

CFDates = datetime(CFDates,'ConvertFrom','datenum','Locale','en_US');
Settle = datetime(Settle,'ConvertFrom','datenum','Locale','en_US');
Price = cfprice(CFAmounts, CFDates, Yield, Settle)
Price = 3×1

   28.4999
   36.1689
   25.8195

Input Arguments

collapse all

Cash flow amounts, specified as number of bonds (NUMBONDS) by number of cash flows (NUMCFS) matrix with entries listing cash flow amounts corresponding to each date in CFlowDates.

Data Types: double

Cash flow dates, specified as an NUMBONDS-by-NUMCFS matrix with rows listing cash flow dates using a serial date number, date character vector, or datetime array, for each bond and padded with NaNs. If CFlowDates is a serial date number or a date character vector, AllDates is returned as an array of serial date numbers. If CFlowDates is a datetime array, then AllDates is returned as a datetime array.

Data Types: double

(Optional) Time between settlement and the cash flow date, specified as an NUMBONDS-by-NUMCFS matrix with entries listing the time between settlement and the cash flow date measured in semiannual coupon periods.

Data Types: double

Output Arguments

collapse all

Cash flows indexed by bond and by date, returned as an NUMBONDS by number of dates (NUMDATES) matrix. Each row contains a bond's cash flow values at the indices corresponding to entries in AllDates. Other indices in the row contain zeros.

List of all dates that have any cash flow from the bond portfolio, returned as an NUMDATES-by-1 matrix. The AllDates matrix is expressed in serial date format (default) or datetime format (if CFlowDates is in datetime format).

Time factors corresponding to the dates in AllDates, returned as an NUMDATES-by-1 matrix. If TFactors is not entered, AllTF contains the number of days from the first date in AllDates.

Indices by bond, returned as an NUMBONDS-by-NUMCFS matrix. The ith row contains a list of indices into AllDates where the ith bond has cash flows. Since some bonds have more cash flows than others, the matrix is padded with NaNs.

Introduced before R2006a