Main Content


Compute price for interest-rate instrument with IRTree pricer



[Price,PriceResult] = price(inpPricer,inpInstrument) computes the instrument price and related pricing information based on the pricing object inpPricer and the instrument object inpInstrument.


[Price,PriceResult] = price(___,inpSensitivity) adds an optional argument to specify sensitivities.


collapse all

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

Create FixedBond Instrument Object

Use fininstrument to create a FixedBond instrument object as the underlying bond.

BondInst = fininstrument("FixedBond",'Maturity',datetime(2029,9,15),'CouponRate',0.025,'Period', 1,'Name',"fixed_bond_instrument")
BondInst = 
  FixedBond with properties:

                  CouponRate: 0.0250
                      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 FixedBondOption Instrument Object

Use fininstrument to create a FixedBondOption instrument object.

FixedBOption = fininstrument("FixedBondOption",'ExerciseDate',datetime(2025,9,15),'Strike',98,'Bond',BondInst,'Name',"fixed_bond_option_instrument")
FixedBOption = 
  FixedBondOption with properties:

       OptionType: "call"
    ExerciseStyle: "european"
     ExerciseDate: 15-Sep-2025
           Strike: 98
             Bond: [1x1 fininstrument.FixedBond]
             Name: "fixed_bond_option_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.01,'Sigma',0.05)
HullWhiteModel = 
  HullWhite with properties:

    Alpha: 0.0100
    Sigma: 0.0500

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]

ans = struct with fields:
        tObs: [0 1 1.9973 2.9945 3.9918 4.9918 5.9891 6.9863 7.9836 8.9836]
        dObs: [1x10 datetime]
      CFlowT: {1x10 cell}
       Probs: {1x9 cell}
     Connect: {1x9 cell}
     FwdTree: {1x10 cell}
    RateTree: {1x10 cell}

Price FixedBondOption Instrument

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

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

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

ans=1×4 table
    Price      Vega     Gamma      Delta 
    ______    ______    ______    _______

    11.174    243.09    3667.6    -272.19

Input Arguments

collapse all

Pricer object, specified as a scalar IRTree pricer object. Use finpricer to create the IRTree pricer object.

Data Types: object

Instrument object, specified as scalar or a vector of previously created instrument objects. Create the instrument objects using fininstrument. The following instrument objects are supported:

Data Types: object

(Optional) List of sensitivities to compute, specified as a NOUT-by-1 or a 1-by-NOUT cell array of character vectors or string array with possible values of 'Price', 'Delta', 'Gamma', 'Vega', and 'All'.

inpSensitivity = {'All'} or inpSensitivity = ["All"] specifies that the output is 'Delta', 'Gamma', 'Vega', and 'Price'. This is the same as specifying inpSensitivity to include each sensitivity.

The sensitivities supported depend on the inpInstrument.

inpInstrumentSupported Sensitivities


Sensitivities are calculated based on yield shifts of 1 basis point, where the ShiftValue = 1/10000. All sensitivities are returned as dollar sensitivities. To find the per-dollar sensitivities, divide the sensitivities by their respective instrument price.

Example: inpSensitivity = {'delta','gamma','vega','price'}

Data Types: string | cell

Output Arguments

collapse all

Instrument price, returned as a numeric.

Price result, returned as a PriceResult object. The object has the following fields:

  • PriceResult.Results — Table of results that includes sensitivities (if you specify inpSensitivity)

  • PriceResult.PricerData — Structure for pricer data that depends on the instrument that is being priced

    FixedBond, FloatBond, FixedBondOption, and OptionEmbeddedFixedBond have the following shared fields for PriceResult.PricerData.PriceTree:

    • tObs contains the observation times.

    • Connect contains the connectivity vectors. Each element in the cell array describes how nodes in that level connect to the next. For a given tree level, there are NumNodes elements in the vector, and they contain the index of the node at the next level that the middle branch connects to. Subtracting 1 from that value indicates where the up-branch connects to, and adding 1 indicates where the down branch connects to.

The following additional fields for PriceResult.PricerData.PriceTree depend on the instrument type:

  • PTree contains the clean prices.

  • AITree contains the accrued interest.

  • Probs contains the probability arrays. Each element of the cell array contains the up, middle, and down transition probabilities for each node of the level.

  • dObs contains the date of each level of the tree.

  • CFlowT is a cell array with as many elements as levels of the tree. Each cell array element contains the time factors (tObs) corresponding to its level of the tree and those levels ahead of it.

  • FwdTree contains the forward spot rate from one node to the next. The forward spot rate is defined as the inverse of the discount factor.

  • ExTree contains the exercise indicator arrays. Each element of the cell array is an array containing 1's where an option is exercised and 0's where it isn't.

  • ProbTree contains the probability of reaching each node from root node.

  • ExProbTree contains the exercise probabilities. Each element in the cell array is an array containing 0's where there is no exercise, or the probability of reaching that node where exercise happens.

  • ExProbsByTreeLevel is an array with each row holding the exercise probability for a given option at each tree observation time.

A FixedBond instrument has these additional fields within PriceResult.PricerData.PriceTree:

  • PTree

  • AITree

  • Probs.

A FloatBond instrument has these additional fields within PriceResult.PricerData.PriceTree:

  • dObs

  • CFlowT

  • Probs

  • FwdTree

A FixedBondOption instrument has these additional fields within PriceResult.PricerData.PriceTree:

  • PTree

  • Probs

  • ExTree

A OptionEmbeddedFixedBond instrument has these additional fields within PriceResult.PricerData.PriceTree:

  • PTree

  • ExTree

  • ProbTree

  • ExProbTree

  • ExProbsByTreeLevel

The following table displays the PriceResult.PricerData.PriceTree fields related to each instrument.

PriceResult.PricerData.PriceTree FieldsFixedBondFloatBondFixedBondOptionOptionEmbeddedFixedBond

Introduced in R2020a