Main Content

cashflows

Computes cash flow for FixedBond, FloatBond, Swap, FRA, or Deposit instrument

Description

example

CF = cashflows(InstrumentObject,Settle) computes cash flow for a Deposit, FRA, ,Swap, FixedBond, or FloatBond instrument.

Examples

collapse all

This example shows the workflow to price a FRA (forward rate agreement) instrument and then use cashflows to determine the cash flow for the FRA instrument.

Create FRA Instrument Object

Use fininstrument to create a FRA instrument object.

FRAObj = fininstrument("FRA",'StartDate',datetime(2020,9,15),'Maturity',datetime(2022,9,15),'Rate',0.175)
FRAObj = 
  FRA with properties:

                     Rate: 0.1750
                    Basis: 2
                StartDate: 15-Sep-2020
                 Maturity: 15-Sep-2022
                Principal: 100
    BusinessDayConvention: "actual"
                 Holidays: NaT
                     Name: ""

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2018,9,15);
Type = "zero";
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
 
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2018
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create Discount Pricer Object

Use finpricer to create a Discount pricer object and use the ratecurve object with the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("Discount", 'DiscountCurve',myRC)
outPricer = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Price FRA Instrument

Use price to compute the price and sensitivities for the FRA instrument.

[Price, outPR] = price(outPricer, FRAObj,["all"])
Price = 34.1757
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

outPR.Results
ans=1×2 table
    Price      DV01  
    ______    _______

    34.176    0.01368

Use cashflows for the FRA instrument with a Settle date of 15-Dec-2021. The specified Settle date must be before the instrument Maturity date.

CF = cashflows(FRAObj,datetime(2021,12,15))
CF= 1×1timetable
       Time         CFA  
    ___________    ______

    15-Sep-2022    35.486

This example shows the workflow to price a FixedBond instrument and then use cashflows to calculate the cash flow for the FixedBond instrument.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

FixB = fininstrument("FixedBond",'Maturity',datetime(2022,9,15),'CouponRate',0.05,'Period',4,'Basis',7,'Principal',1000,'BusinessDayConvention',"follow",'Name',"fixed_bond_instrument")
FixB = 
  FixedBond with properties:

                  CouponRate: 0.0500
                      Period: 4
                       Basis: 7
                EndMonthRule: 1
                   Principal: 1000
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "follow"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 15-Sep-2022
                        Name: "fixed_bond_instrument"

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2018,9,15);
Type = 'zero';
ZeroTimes = [calmonths(6) calyears([1 2 3 4 5 7 10 20 30])]';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
 
myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: -1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 15-Sep-2018
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create Discount Pricer Object

Use finpricer to create a Discount pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.

outPricer = finpricer("Discount",'DiscountCurve',myRC)
outPricer = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Price FixedBond Instrument

Use price to compute the price and sensitivities for the FixedBond instrument.

[Price, outPR] = price(outPricer, FixB,["all"])
Price = 1.1600e+03
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

outPR.Results
ans=1×2 table
    Price     DV01  
    _____    _______

    1160     0.42712

Use cashflows to calculate the cash flow for the FixedBond instrument for any specified Settle date before the instrument Maturity date.

CF = cashflows(FixB,datetime(2021,9,15))
CF=5×1 timetable
       Time         Var1 
    ___________    ______

    15-Sep-2021         0
    15-Dec-2021      12.5
    15-Mar-2022      12.5
    15-Jun-2022      12.5
    15-Sep-2022    1012.5

Input Arguments

collapse all

Instrument object, specified using a previously created instrument object for one of the following: Deposit, FixedBond, FloatBond, Swap, or FRA.

Data Types: object

Settlement date for instrument cash flow, specified as a scalar using a datetime, serial date number, date character vector, or date string.

Note

The Settle date you specify must be before the Maturity date for the Deposit, FixedBond, FloatBond, Swap, or FRA instrument.

Data Types: double | char | datetime | string

Output Arguments

collapse all

Cash flow, returned as a timetable.

Introduced in R2020a