Main Content

FixedBond

FixedBond instrument object

Since R2020a

Description

Create and price a FixedBond instrument object for one of more Fixed Bond instruments using this workflow:

  1. Use fininstrument to create a FixedBond instrument object for one of more Fixed Bond instruments.

  2. Use ratecurve to specify a curve model for the FixedBond instrument object or use a HullWhite, BlackKarasinski, BlackDermanToy, BraceGatarekMusiela, SABRBraceGatarekMusiela, CoxIngersollRoss, or LinearGaussian2F model.

  3. Choose a pricing method.

For more detailed information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

For more information on the available models and pricing methods for a FixedBond instrument, see Choose Instruments, Models, and Pricers.

Creation

Description

example

FixedBondObj = fininstrument(InstrumentType,'CouponRate',couponrate_value,'Maturity',maturity_date) creates a FixedBond object for one of more Fixed Bond instruments by specifying InstrumentType and sets the properties for the required name-value pair arguments CouponRate and Maturity.

The FixedBond instrument supports a vanilla bond, a stepped coupon bond, and an amortizing bond. For more information, see More About.

example

FixedBondObj = fininstrument(___,Name,Value) sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, FixedBondObj = fininstrument("FixedBond",'CouponRate',0.34,'Maturity',datetime(2019,1,30),'Period',4,'Basis',1,'Principal',100,'FirstCouponDate',datetime(2016,1,30),'EndMonthRule',true,'Name',"fixedbond_instrument") creates a FixedBond option with a coupon rate of 0.34 and a maturity of January 30, 2019. You can specify multiple name-value pair arguments.

Input Arguments

expand all

Instrument type, specified as a string with the value of "FixedBond", a character vector with the value of 'FixedBond', an NINST-by-1 string array with values of "FixedBond", or an NINST-by-1 cell array of character vectors with values of 'FixedBond'.

Data Types: char | cell | string

Name-Value Arguments

Specify required and optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: FixedBondObj = fininstrument("FixedBond",'CouponRate',0.34,'Maturity',datetime(2019,1,30),'Period',4,'Basis',1,'Principal',100,'FirstCouponDate',datetime(2016,1,30),'EndMonthRule',true,'Name',"fixedbond_instrument")

Required FixedBond Name-Value Pair Arguments

expand all

FixedBond coupon rate, specified as the comma-separated pair consisting of 'CouponRate' and a scalar decimal or an NINST-by-1 vector of decimals for an annual rate or a timetable where the first column is dates and the second column is associated rates. The date indicates the last day that the coupon rate is valid.

Note

If you are creating one or more FixedBond instruments and use a timetable, the timetable specification applies to all of the FixedBond instruments. CouponRate does not accept an NINST-by-1 cell array of timetables as input.

Data Types: double | timetable

FixedBond maturity date, specified as the comma-separated pair consisting of 'Maturity' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

If you use date character vectors or strings, the format must be recognizable by datetime because the Maturity property is stored as a datetime.

Optional FixedBond Name-Value Pair Arguments

expand all

Frequency of payments, specified as the comma-separated pair consisting of 'Period' and a scalar integer or an NINST-by-1 vector of integers. Values for Period are 1, 2, 3, 4, 6, or 12.

Data Types: double

Day count basis, specified as the comma-separated pair consisting of 'Basis' and scalar integer or an NINST-by-1 vector of integers using the following values:

  • 0 — actual/actual

  • 1 — 30/360 (SIA)

  • 2 — actual/360

  • 3 — actual/365

  • 4 — 30/360 (PSA)

  • 5 — 30/360 (ISDA)

  • 6 — 30/360 (European)

  • 7 — actual/365 (Japanese)

  • 8 — actual/actual (ICMA)

  • 9 — actual/360 (ICMA)

  • 10 — actual/365 (ICMA)

  • 11 — 30/360E (ICMA)

  • 12 — actual/365 (ISDA)

  • 13 — BUS/252

For more information, see Basis.

Data Types: double

Principal amount or principal value schedule, specified as the comma-separated pair consisting of 'Principal' and a scalar numeric or an NINST-by-1 numeric vector or a timetable.

Principal accepts a timetable, where the first column is dates and the second column is the associated notional principal value. The date indicates the last day that the principal value is valid.

Note

If you are creating one or more FixedBond instruments and use a timetable, the timetable specification applies to all of the FixedBond instruments. Principal does not accept an NINST-by-1 cell array of timetables as input.

Data Types: double | timetable

Flag indicating whether cash flow is adjusted by day count convention, specified as the comma-separated pair consisting of 'DaycountAdjustedCashFlow' and a scalar logical or an NINST-by-1 vector of logicals with values of true or false.

Data Types: logical

Business day conventions for cash flow dates, specified as the comma-separated pair consisting of 'BusinessDayConvention' and a scalar string or character vector or an NINST-by-1 cell array of character vectors or string array. The selection for business day convention determines how nonbusiness days are treated. Nonbusiness days are defined as weekends plus any other date that businesses are not open (for example, statutory holidays). Values are:

  • "actual" — Nonbusiness days are effectively ignored. Cash flows that fall on nonbusiness days are assumed to be distributed on the actual date.

  • "follow" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day.

  • "modifiedfollow" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the following business day. However, if the following business day is in a different month, the previous business day is adopted instead.

  • "previous" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day.

  • "modifiedprevious" — Cash flows that fall on a nonbusiness day are assumed to be distributed on the previous business day. However, if the previous business day is in a different month, the following business day is adopted instead.

Data Types: char | cell | string

Holidays used in computing business days, specified as the comma-separated pair consisting of 'Holidays' and dates using an NINST-by-1 vector of a datetime array, string array, or date character vectors. For example:

H = holidays(datetime('today'),datetime(2025,12,15));
FixedBondObj = fininstrument("FixedBond",'CouponRate',0.34,'Maturity',datetime(2025,12,15),'Holidays',H)

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

End-of-month rule flag for generating dates when Maturity is an end-of-month date for a month with 30 or fewer days, specified as the comma-separated pair consisting of 'EndMonthRule' and a scalar logical value or an NINST-by-1 vector of logicals with values of true or false.

  • If you set EndMonthRule to false, the software ignores the rule, meaning that a payment date is always the same numerical day of the month.

  • If you set EndMonthRule to true, the software sets the rule on, meaning that a payment date is always the last actual day of the month.

Data Types: logical

Bond issue date, specified as the comma-separated pair consisting of 'IssueDate' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

If you use date character vectors or strings, the format must be recognizable by datetime because the IssueDate property is stored as a datetime.

Irregular first coupon date, specified as the comma-separated pair consisting of 'FirstCouponDate' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

When FirstCouponDate and LastCouponDate are both specified, FirstCouponDate takes precedence in determining the coupon payment structure. If you do not specify FirstCouponDate, the cash flow payment dates are determined from other inputs.

If you use date character vectors or strings, the format must be recognizable by datetime because the FirstCouponDate property is stored as a datetime.

Irregular last coupon date, specified as the comma-separated pair consisting of 'LastCouponDate' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

If you specify LastCouponDate but not FirstCouponDate, LastCouponDate determines the coupon structure of the bond. The coupon structure of a bond is truncated at LastCouponDate, regardless of where it falls, and is followed only by the bond's maturity cash flow date. If you do not specify LastCouponDate, the cash flow payment dates are determined from other inputs.

If you use date character vectors or strings, the format must be recognizable by datetime because the LastCouponDate property is stored as a datetime.

Forward starting date of payments, specified as the comma-separated pair consisting of 'StartDate' and a scalar or an NINST-by-1 vector using a datetime array, string array, or date character vectors.

To support existing code, FixedBond also accepts serial date numbers as inputs, but they are not recommended.

If you use date character vectors or strings, the format must be recognizable by datetime because the StartDate property is stored as a datetime.

User-defined name for one of more instruments, specified as the comma-separated pair consisting of 'Name' and a scalar string or character vector or an NINST-by-1 cell array of character vectors or string array.

Data Types: char | cell | string

Properties

expand all

FixedBond coupon annual rate, returned as a scalar decimal or an NINST-by-1 vector of decimals or a timetable.

Data Types: double | timetable

FixedBond maturity date, returned as a scalar datetime or NINST-by-1 vector of datetimes.

Data Types: datetime

Frequency of payments per year, returned as a scalar integer or an NINST-by-1 vector of integers.

Data Types: double

Day count basis, returned as a scalar integer or an NINST-by-1 vector of integers.

Data Types: double

Principal amount or principal value schedules, returned as a scalar numeric or an NINST-by-1 numeric vector or a timetable.

Data Types: double

Flag indicating whether cash flow adjusts for day count convention, returned as scalar logical or an NINST-by-1 vector of logicals with values of true or false.

Data Types: logical

Business day conventions, returned as a scalar string or an NINST-by-1 string array.

Data Types: string

Holidays used in computing business days, returned as an NINST-by-1 vector of datetimes.

Data Types: datetime

End-of-month rule flag for generating dates when Maturity is an end-of-month date for a month having 30 or fewer days, returned as a scalar logical or an NINST-by-1 vector of logical values.

Data Types: logical

Bond issue date, returned as a scalar datetime or an NINST-by-1 vector of datetimes.

Data Types: datetime

Irregular first coupon date, returned as a scalar datetime or an NINST-by-1 vector of datetimes.

Data Types: datetime

Irregular last coupon date, returned as a scalar datetime or an NINST-by-1 vector of datetimes.

Data Types: datetime

Forward starting date of payments, returned as a scalar datetime or an NINST-by-1 vector of datetimes.

Data Types: datetime

User-defined name for the instrument, returned as a scalar string or an NINST-by-1 string array.

Data Types: string

Object Functions

cashflowsCompute cash flow for FixedBond, FloatBond, Swap, FRA, STIRFuture, OISFuture, OvernightIndexedSwap, or Deposit instrument

Examples

collapse all

This example shows the workflow to price a vanilla FixedBond instrument when you use a ratecurve and a Discount pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

FixB = fininstrument("FixedBond",'Maturity',datetime(2022,9,15),'CouponRate',0.021,'Period',2,'Basis',1,'Principal',100,'Name',"fixed_bond_instrument")
FixB = 
  FixedBond with properties:

                  CouponRate: 0.0210
                      Period: 2
                       Basis: 1
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    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 with 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 = 104.5679
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

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

    104.57    0.040397

This example shows how to create a FixedBond instrument and then use any of the following Financial Toolbox™ functions to perform bond analytics: bnddurp, bnddury, bndconvp, bndconvy, bndkrdur, cfdur, and cfconv.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

MaturityDate = datetime(2027,12,16);
CouponRate = 0.01;

FixedBondObj = fininstrument('FixedBond','CouponRate',CouponRate,'Maturity',MaturityDate); 

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2022,10,10);   
MarketDates = datetime([2023,9,15 ; 2024,9,15 ; 2025,9,15 ; 2026,9,15 ; 2027,9,15 ; 2028,9,15]);
ZeroDates = datetime([2023,10,15 ; 2024,10,15 ; 2025,10,15 ; 2026,10,15 ; 2027,10,15 ; 2028,10,15]);
ZeroRates = [4.2520 4.1081 3.8801 3.7170 3.6060 3.5250]'/100;
MarketSpreads = [97.9825 97.9825 97.9825 97.9825 97.9825 97.9825]';

RateObjB = ratecurve('zero',Settle,ZeroDates,ZeroRates+MarketSpreads(1)/10000); 

Create Discount Pricer Object

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

Pricer1 = finpricer("Discount",'DiscountCurve',RateObjB); 

Price FixedBond Instrument

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

[Price1, outPR] = price(Pricer1, FixedBondObj,["all"])
Price1 = 83.4210
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

Compute Bond Durations for FixedBond Instrument

Use bnddurp to compute the bond durations given the bond price.

[ModDuration, YearDuration, PerDuration] = bnddurp(Price1,FixedBondObj.CouponRate, Settle, FixedBondObj.Maturity,Period=FixedBondObj.Period) 
ModDuration = 4.9169
YearDuration = 5.0308
PerDuration = 10.0616

Compute Key Rate Durations for FixedBond Instrument

Use bndkrdur to compute the FixedBond instrument key rate duration given a zero curve.

ZeroData1 = [datenum(RateObjB.Dates) RateObjB.Rates]; 
KeyRateDuration = bndkrdur(ZeroData1,FixedBondObj.CouponRate,Settle,FixedBondObj.Maturity) 
KeyRateDuration = 1×6

    0.0133    0.0212    0.0304    0.0389    4.0226    0.8164

This example shows the workflow to price multiple vanilla FixedBond instruments when you use a ratecurve and a Discount pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object for three Fixed Bond instruments.

FixB = fininstrument("FixedBond",'Maturity',datetime([2022,9,15 ; 2022,10,15 ; 2022,11,15]),'CouponRate',0.021,'Period',2,'Basis',1,'Principal',[100 ; 250 ; 500],'Name',"fixed_bond_instrument")
FixB=3×1 FixedBond array with properties:
    CouponRate
    Period
    Basis
    EndMonthRule
    Principal
    DaycountAdjustedCashFlow
    BusinessDayConvention
    Holidays
    IssueDate
    FirstCouponDate
    LastCouponDate
    StartDate
    Maturity
    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 FixedBond Instruments

Use price to compute the prices and sensitivities for the FixedBond instruments.

[Price, outPR] = price(outPricer, FixB,["all"])
Price = 3×1

  104.5679
  261.4498
  522.9174

outPR=1×3 priceresult array with properties:
    Results
    PricerData

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

    104.57    0.040397

ans=1×2 table
    Price     DV01 
    ______    _____

    261.45    0.103

ans=1×2 table
    Price      DV01  
    ______    _______

    522.92    0.21013

This example shows the workflow to price a stepped FixedBond instrument when you use a ratecurve and a Discount pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a stepped FixedBond instrument object.

Maturity = datetime(2024,1,1);
Period = 1;
CDates = datetime([2020,1,1 ; 2024,1,1]);
CRates = [.025; .03];
CouponRate = timetable(CDates,CRates);

SBond = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',CouponRate,'Period',Period) 
SBond = 
  FixedBond with properties:

                  CouponRate: [2x1 timetable]
                      Period: 1
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 01-Jan-2024
                        Name: ""

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2018,1,1);
ZeroTimes = calyears(1:10)';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
Compounding = 1;
ZeroCurve = ratecurve("zero",Settle,ZeroDates,ZeroRates, "Compounding",Compounding)
ZeroCurve = 
  ratecurve with properties:

                 Type: "zero"
          Compounding: 1
                Basis: 0
                Dates: [10x1 datetime]
                Rates: [10x1 double]
               Settle: 01-Jan-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',ZeroCurve)
outPricer = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Price FixedBond Instrument

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

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

       Results: [1x2 table]
    PricerData: []

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

    109.62    0.061108

This example shows the workflow to price a amortizing FixedBond instrument when you use a ratecurve and a Discount pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a amortizing FixedBond instrument object.

Maturity = datetime(2024,1,1);
Period = 1;
ADates = datetime([2020,1,1 ; 2024,1,1]);
APrincipal = [100; 85];
Principal = timetable(ADates,APrincipal);
Bondamort = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',0.025,'Period',Period,'Principal',Principal)  
Bondamort = 
  FixedBond with properties:

                  CouponRate: 0.0250
                      Period: 1
                       Basis: 0
                EndMonthRule: 1
                   Principal: [2x1 timetable]
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 01-Jan-2024
                        Name: ""

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2018,1,1);
ZeroTimes = calyears(1:10)';
ZeroRates = [0.0052 0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307]';
ZeroDates = Settle + ZeroTimes;
Compounding = 1;
ZeroCurve = ratecurve("zero",Settle,ZeroDates,ZeroRates, "Compounding",Compounding);

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',ZeroCurve)
outPricer = 
  Discount with properties:

    DiscountCurve: [1x1 ratecurve]

Price FixedBond Instrument

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

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

       Results: [1x2 table]
    PricerData: []

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

    107.13    0.054279

This example shows the workflow to price a FixedBond instrument when using a HullWhite model and an IRMonteCarlo pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

FixB = fininstrument("FixedBond","Maturity",datetime(2022,9,15),"CouponRate",0.05,'Name',"fixed_bond")
FixB = 
  FixedBond with properties:

                  CouponRate: 0.0500
                      Period: 2
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 15-Sep-2022
                        Name: "fixed_bond"

Create HullWhite Model Object

Use finmodel to create a HullWhite model object.

HullWhiteModel = finmodel("HullWhite",'Alpha',0.32,'Sigma',0.49)
HullWhiteModel = 
  HullWhite with properties:

    Alpha: 0.3200
    Sigma: 0.4900

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,1,1);
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: 01-Jan-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create IRMonteCarlo Pricer Object

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

outPricer = finpricer("IRMonteCarlo",'Model',HullWhiteModel,'DiscountCurve',myRC,'SimulationDates',ZeroDates)
outPricer = 
  HWMonteCarlo with properties:

          NumTrials: 1000
      RandomNumbers: []
      DiscountCurve: [1x1 ratecurve]
    SimulationDates: [01-Jul-2019    01-Jan-2020    01-Jan-2021    01-Jan-2022    01-Jan-2023    01-Jan-2024    01-Jan-2026    01-Jan-2029    01-Jan-2039    01-Jan-2049]
              Model: [1x1 finmodel.HullWhite]

Price FixedBond Instrument

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

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

       Results: [1x4 table]
    PricerData: [1x1 struct]

outPR.Results
ans=1×4 table
    Price      Delta     Gamma     Vega
    ______    _______    ______    ____

    115.03    -397.13    1430.4     0  

This example shows the workflow to price a FixedBond instrument when using a HullWhite model and a IRTree pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

FixB = fininstrument("FixedBond","Maturity",datetime(2029,9,15),"CouponRate",.05,"Period",1,"Name","fixed_bond_instrument")
FixB = 
  FixedBond with properties:

                  CouponRate: 0.0500
                      Period: 1
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 15-Sep-2029
                        Name: "fixed_bond_instrument"

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2019,9,15);
Type = "zero";
ZeroTimes = [calyears([1:10])]';
ZeroRates = [0.0055 0.0061 0.0073 0.0094 0.0119 0.0168 0.0222 0.0293 0.0307 0.0310]';
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-2019
         InterpMethod: "linear"
    ShortExtrapMethod: "next"
     LongExtrapMethod: "previous"

Create HullWhite Model Object

Use finmodel to create a HullWhite model object.

HullWhiteModel = finmodel("hullwhite",'Alpha',0.052,'Sigma',0.34)
HullWhiteModel = 
  HullWhite with properties:

    Alpha: 0.0520
    Sigma: 0.3400

Create IRTree Pricer Object

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

HWTreePricer = finpricer("irtree","model",HullWhiteModel,"DiscountCurve",myRC,"TreeDates",ZeroDates)
HWTreePricer = 
  HWBKTree with properties:

             Tree: [1x1 struct]
        TreeDates: [10x1 datetime]
            Model: [1x1 finmodel.HullWhite]
    DiscountCurve: [1x1 ratecurve]

HWTreePricer.Tree
ans = struct with fields:
        tObs: [0 1 1.9973 2.9945 3.9918 4.9918 5.9891 6.9863 7.9836 8.9836]
        dObs: [15-Sep-2019    15-Sep-2020    15-Sep-2021    15-Sep-2022    15-Sep-2023    15-Sep-2024    15-Sep-2025    15-Sep-2026    15-Sep-2027    15-Sep-2028]
      CFlowT: {[10x1 double]  [9x1 double]  [8x1 double]  [7x1 double]  [6x1 double]  [5x1 double]  [4x1 double]  [3x1 double]  [2x1 double]  [9.9809]}
       Probs: {[3x1 double]  [3x3 double]  [3x5 double]  [3x7 double]  [3x9 double]  [3x11 double]  [3x13 double]  [3x15 double]  [3x17 double]}
     Connect: {[2]  [2 3 4]  [2 3 4 5 6]  [2 3 4 5 6 7 8]  [2 3 4 5 6 7 8 9 10]  [2 3 4 5 6 7 8 9 10 11 12]  [2 3 4 5 6 7 8 9 10 11 12 13 14]  [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16]  [2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18]}
     FwdTree: {1x10 cell}
    RateTree: {1x10 cell}

Price FixedBond Instrument

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

[Price, outPR] = price(HWTreePricer, FixB,["all"])
Price = 117.9440
outPR = 
  priceresult with properties:

       Results: [1x4 table]
    PricerData: [1x1 struct]

outPR.Results
ans=1×4 table
    Price      Delta     Gamma        Vega    
    ______    _______    ______    ___________

    117.94    -964.01    8868.6    -4.2633e-10

This example shows the workflow to price a FixedBond instrument when you use a CoxIngersollRoss model and an IRTree pricing method.

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object.

Period = 1;
Maturity = datetime(2027,1,1); 
CouponRate = 0.035;
FixedBond = fininstrument("FixedBond",'Maturity',Maturity,'CouponRate',CouponRate,'Period',Period,Name="fixed_bond")
FixedBond = 
  FixedBond with properties:

                  CouponRate: 0.0350
                      Period: 1
                       Basis: 0
                EndMonthRule: 1
                   Principal: 100
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                   IssueDate: NaT
             FirstCouponDate: NaT
              LastCouponDate: NaT
                   StartDate: NaT
                    Maturity: 01-Jan-2027
                        Name: "fixed_bond"

Create CoxIngersollRoss Model Object

Use finmodel to create a CoxIngersollRoss model object.

alpha = 0.03; 
theta = 0.02; 
sigma = 0.1; 
CIRModel = finmodel("CoxIngersollRoss",Sigma=sigma,Alpha=alpha,Theta=theta)
CIRModel = 
  CoxIngersollRoss with properties:

    Sigma: 0.1000
    Alpha: 0.0300
    Theta: 0.0200

Create ratecurve Object

Create a ratecurve object using ratecurve.

Times= [calyears([1 2 3 4 ])]';
Settle = datetime(2023,1,1);
ZRates = [0.035; 0.042147; 0.047345; 0.052707]';
ZDates = Settle + Times;
Compounding = -1; 
Basis = 1;
ZeroCurve = ratecurve("zero",Settle,ZDates,ZRates,Compounding = Compounding, Basis = Basis);

Create IRTree Pricer Object

Use finpricer to create an IRTree pricer object for the CoxIngersollRoss model and use the ratecurve object for the 'DiscountCurve' name-value argument.

CIRPricer = finpricer("irtree",Model=CIRModel,DiscountCurve=ZeroCurve,Maturity=ZDates(end),NumPeriods=length(ZDates))
CIRPricer = 
  CIRTree with properties:

             Tree: [1x1 struct]
        TreeDates: [4x1 datetime]
            Model: [1x1 finmodel.CoxIngersollRoss]
    DiscountCurve: [1x1 ratecurve]

Price FixedBond Instrument

Use price to compute the price for the FixedBond instrument.

[Price,outPR] = price(CIRPricer,FixedBond,"all")
Price = 93.4593
outPR = 
  priceresult with properties:

       Results: [1x4 table]
    PricerData: [1x1 struct]

outPR.Results
ans=1×4 table
    Price      Delta     Gamma        Vega    
    ______    _______    ______    ___________

    93.459    -354.23    1384.8    -1.4211e-10

More About

expand all

Version History

Introduced in R2020a

expand all