Main Content

price

Compute price for interest-rate instrument with IRMonteCarlo pricer

Since R2021b

Description

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

example

[Price,PriceResult] = price(___,inpSensitivity) adds an optional argument to specify sensitivities. Use this syntax with the input argument combination in the previous syntax.

example

Examples

collapse all

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: [10×1 datetime]
                Rates: [10×1 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: [1×1 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: [1×1 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: [1×4 table]
    PricerData: [1×1 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 RangeAccrualNote instrument when you use a HullWhite model and an IRMonteCarlo pricing method.

Create RangeAccrualNote Instrument Object

Use fininstrument to create a RangeAccrualNote instrument object.

Maturity = datetime(2026,9,15);
RangeAccrualNoteInstrument = fininstrument("RangeAccrualNote",Maturity=Maturity,ReferenceType="cms",ReferenceTenor=10,CouponRate=0.4,TargetRange=[0,3.25/100],Principal=1000,Name="rangeaccrualnote_instrument")
RangeAccrualNoteInstrument = 
  RangeAccrualNote with properties:

               ReferenceType: "cms"
                      Period: 2
                       Basis: 0
                   Principal: 1000
           CMSReferenceReset: 2
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                EndMonthRule: 1
              ReferenceTenor: 10
                    Maturity: 15-Sep-2026
                  CouponRate: 0.4000
                 TargetRange: [0 0.0325]
                   StartDate: NaT
                        Name: "rangeaccrualnote_instrument"

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2024,9,15);
Type = 'zero';
ZeroTimes = [calyears(1:3)]';
ZeroRates = [0.0055 0.0061 0.0073]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

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

Create a HullWhite Model Object

Use finmodel to create a HullWhite model object.

HullWhiteModel = finmodel("HullWhite",Alpha=0.02,Sigma=0.03)
HullWhiteModel = 
  HullWhite with properties:

    Alpha: 0.0200
    Sigma: 0.0300

Create IRMonteCarlo Pricer Object

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

SimulationDates = Settle:caldays(1):Maturity;
SimulationDates = busdate(SimulationDates,"follow",RangeAccrualNoteInstrument.Holidays);
outPricer = finpricer("IRMonteCarlo",Model=HullWhiteModel,DiscountCurve=myRC,SimulationDates=SimulationDates)
outPricer = 
  HWMonteCarlo with properties:

          NumTrials: 1000
      RandomNumbers: []
      DiscountCurve: [1×1 ratecurve]
    SimulationDates: [16-Sep-2024    17-Sep-2024    18-Sep-2024    19-Sep-2024    20-Sep-2024    23-Sep-2024    24-Sep-2024    25-Sep-2024    26-Sep-2024    27-Sep-2024    30-Sep-2024    01-Oct-2024    02-Oct-2024    03-Oct-2024    …    ] (1×523 datetime)
              Model: [1×1 finmodel.HullWhite]

Price RangeAccrualNote Instrument

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

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

       Results: [1×4 table]
    PricerData: [1×1 struct]

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

    1511.1    8244.1    5.9468e+06    -4760.4

This example shows the workflow to price a OptionEmbeddedangeAccrualNote instrument when you use a LinearGaussian2F model and an IRMonteCarlo pricing method.

Create OptionEmbeddedRangeAccrualNote Instrument Object

Use fininstrument to create a OptionEmbeddedRangeAccrualNote instrument object.

Maturity = datetime(2026,9,15);

Strike = [1000; 1000 ];
ExerciseDates = [datetime(2025,12,1); datetime(2026,12,1)];
CallSchedule =  timetable(ExerciseDates,Strike,'VariableNames',{'Strike Schedule'});

OptionEmbeddedRangeAccrualNoteInstrument = fininstrument("OptionEmbeddedRangeAccrualNote",Maturity=Maturity,ReferenceType="cms",ReferenceTenor=10,CouponRate=0.4, ...
    TargetRange=[0,3.25/100],Principal=1000,CallSchedule=CallSchedule,Name="optionembedded_rangeaccrualnote_instrument")
OptionEmbeddedRangeAccrualNoteInstrument = 
  OptionEmbeddedRangeAccrualNote with properties:

               ReferenceType: "cms"
                      Period: 2
                       Basis: 0
                   Principal: 1000
           CMSReferenceReset: 2
    DaycountAdjustedCashFlow: 0
       BusinessDayConvention: "actual"
                    Holidays: NaT
                EndMonthRule: 1
              ReferenceTenor: 10
                    Maturity: 15-Sep-2026
                  CouponRate: 0.4000
                 TargetRange: [0 0.0325]
                CallSchedule: [1×1 timetable]
                   StartDate: NaT
                        Name: "optionembedded_rangeaccrualnote_instrument"

Create ratecurve Object

Create a ratecurve object using ratecurve.

Settle = datetime(2024,9,15);
Type = 'zero';
ZeroTimes = [calyears(1:3)]';
ZeroRates = [0.0055 0.0061 0.0073]';
ZeroDates = Settle + ZeroTimes;

myRC = ratecurve('zero',Settle,ZeroDates,ZeroRates)
myRC = 
  ratecurve with properties:

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

Create LinearGaussian2F Model Object

Use finmodel to create a LinearGaussian2F model object.

LinearGaussian2FModel = finmodel("LinearGaussian2F",Alpha1=0.07,Sigma1=0.01,Alpha2=0.5,Sigma2=0.006,Correlation=-0.7)
LinearGaussian2FModel = 
  LinearGaussian2F with properties:

         Alpha1: 0.0700
         Sigma1: 0.0100
         Alpha2: 0.5000
         Sigma2: 0.0060
    Correlation: -0.7000

Create IRMonteCarlo Pricer Object

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

SimulationDates = Settle:caldays(1):Maturity;
SimulationDates = busdate(SimulationDates,"follow",OptionEmbeddedRangeAccrualNoteInstrument.Holidays);
outPricer = finpricer("IRMonteCarlo",Model=LinearGaussian2FModel,DiscountCurve=myRC,SimulationDates=SimulationDates,NumTrials=1e3)
outPricer = 
  G2PPMonteCarlo with properties:

          NumTrials: 1000
      RandomNumbers: []
      DiscountCurve: [1×1 ratecurve]
    SimulationDates: [16-Sep-2024    17-Sep-2024    18-Sep-2024    19-Sep-2024    20-Sep-2024    23-Sep-2024    24-Sep-2024    25-Sep-2024    26-Sep-2024    27-Sep-2024    30-Sep-2024    01-Oct-2024    02-Oct-2024    03-Oct-2024    …    ] (1×523 datetime)
              Model: [1×1 finmodel.LinearGaussian2F]

Price OptionEmbeddedRangeAccrualNote Instrument

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

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

       Results: [1×4 table]
    PricerData: [1×1 struct]

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

    1375.4    5374.4    -2.8115e+06    -5334.9     5964.5

Input Arguments

collapse all

Pricer object, specified as a previously created IRMonteCarlo pricer object. Create the pricer object using finpricer.

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 an NOUT-by-1 or 1-by-NOUT cell array of character vectors or string array.

The supported sensitivities depend on the pricing method.

inpInstrumentSupported Sensitivities
Cap{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
Floor{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
Swap{'delta','gamma','vega','price'}
Swaption{'delta','gamma','vega','price'}
FixedBond{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
OptionEmbeddedFixedBond{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
FixedBondOption{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
FloatBond{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
FloatBondOption{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
OptionEmbeddedFloatBond{'delta','gamma','vega','price'} ('vega' not supported when using SABRBraceGatarekMusiela model with the IRMonteCarlo pricer.)
RangeAccrualNote{'delta','gamma','vega','price'} ('vega' not supported when using HullWhite or LinearGaussian2F models with the IRMonteCarlo pricer.)
OptionEmbeddedRangeAccrualNote{'delta','gamma','vega','price'} ('vega' not supported when using HullWhite or LinearGaussian2F models with the IRMonteCarlo pricer.)

inpSensitivity = 'All' or inpSensitivity = "All" specifies that all sensitivities for the pricing method are returned. This is the same as specifying inpSensitivity to include each sensitivity.

Example: inpSensitivity = ["delta","gamma","vega","price"]

Data Types: cell | string

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

More About

collapse all

Version History

Introduced in R2021b

expand all