Main Content


Compute price for interest-rate instrument with Discount 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 Swap instrument when using a ratecurve and a Discount pricing method.

Create ratecurve Object

Create a ratecurve object using ratecurve for the underlying interest-rate curve for the Swap instrument.

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

Create Swap Instrument Object

Use fininstrument to create a Swap instrument object.

SwapOpt = fininstrument("Swap",'Maturity',datetime(2027,1,15),'LegRate',[0.024 0.015],'LegType',["fixed","float"],'ProjectionCurve',myRC,'Name',"swap_instrument")
SwapOpt = 
  Swap with properties:

                     LegRate: [0.0240 0.0150]
                     LegType: ["fixed"    "float"]
                       Reset: [2 2]
                       Basis: [0 0]
                    Notional: 100
          LatestFloatingRate: [NaN NaN]
                 ResetOffset: [0 0]
    DaycountAdjustedCashFlow: [0 0]
             ProjectionCurve: [1x2 ratecurve]
       BusinessDayConvention: ["actual"    "actual"]
                    Holidays: NaT
                EndMonthRule: [1 1]
                   StartDate: NaT
                    Maturity: 15-Jan-2027
                        Name: "swap_instrument"

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 Swap Instrument

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

[Price, outPR] = price(outPricer, SwapOpt,["all"])
Price = -1.3834
outPR = 
  priceresult with properties:

       Results: [1x2 table]
    PricerData: []

ans=1×2 table
     Price       DV01  
    _______    ________

    -1.3834    0.023765

Input Arguments

collapse all

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

Data Types: object

Instrument object, specified as a scalar Deposit, FixedBond, FloatBond, FRA, or Swap instrument object. Use fininstrument to create the Deposit, FixedBond, FloatBond, FRA, or Swap instrument object.

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' and 'DV01'.

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

The sensitivities supported depend on the inpInstrument.

inpInstrumentSupported Sensitivities

Example: inpSensitivity = {'DV01','price'}

Data Types: cell | string

Output Arguments

collapse all

Instrument price, returned as a numeric.

Price result, returned as an 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

Introduced in R2020a