Financial Toolbox | ![]() ![]() |
Portfolio form of cash flow amounts
Syntax
Arguments
Description
[CFBondDate, AllDates, AllTF, IndByBond] = cfport(CFlowAmounts,
CFlowDates, TFactors)
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.
CFBondDate
is a NUMBONDS
by number of dates (NUMDATES
) matrix of cash flows indexed by bond and by date in AllDates
. Each row contains a bond's cash flow values at the indices corresponding to entries in AllDates
. Other indices in the row contain zeros.
AllDates
is a NUMDATES
-by-1 list of all dates that have any cash flow from the bond portfolio.
AllTF
is a NUMDATES
-by-1 list of time factors corresponding to the dates in AllDates
. If TFactors
is not entered, AllTF
contains the number of days from the first date in AllDates
.
IndByBond
is a NUMBONDS
-by-NUMCFS
matrix of indices. 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 NaN
s.
Examples
Use cfamounts
to calculate the cash flow amounts, cash flow dates, and time factors for each of two bonds. Then use cfplot
to plot the cash flow diagram.
Settle = '03-Aug-1999'; Maturity = ['15-Aug-2000';'15-Dec-2000']; CouponRate= [0.06; 0.05]; Period = [3;2]; Basis = [1;0]; [CFlowAmounts, CFlowDates, TFactors] = cfamounts(CouponRate,... Settle, Maturity, Period, Basis); cfplot(CFlowDates,CFlowAmounts) xlabel('Numeric Cash Flow Dates') ylabel('Bonds') title('Cash Flow Diagram')
Finally, call cfport
to map the cash flow amounts to the cash flow dates.
Each row in the resultant CFBondDate
matrix represents a bond. Each column represents a date on which one or more of the bonds has a cash flow. A 0 means the bond did not have a cash flow on that date. The dates associated with the columns are listed in AllDates
. For example, the first bond had a cash flow of 2.000
on 730347
. The second bond had no cash flow on this date.
For each bond, IndByBond
indicates the columns of CFBondDate,
or dates in AllDates
, for which a bond has a cash flow.
[CFBondDate, AllDates, AllTF, IndByBond] = ... cfport(CFlowAmounts, CFlowDates, TFactors) CFBondDate = -1.8000 2.0000 2.0000 2.0000 0 102.0000 0 -0.6694 0 2.5000 0 2.5000 0 102.5000 AllDates = 730335 730347 730469 730591 730652 730713 730835 AllTF = 0 0.0663 0.7322 1.3989 1.7322 2.0663 2.7322 IndByBond = 1 2 3 4 6 1 3 5 7 NaN
See Also
![]() | cfdur | cftimes | ![]() |