price
Compute price for interest-rate instrument with IRTree
pricer
Syntax
Description
[
computes the instrument price and related pricing information based on the pricing object
Price,PriceResult] = price(inpPricer,inpInstrument)inpPricer and the instrument object
inpInstrument.
[
adds an optional argument to specify sensitivities.Price,PriceResult] = price(___,inpSensitivity)
Examples
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: [1×1 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: [10×1 datetime]
Rates: [10×1 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: [1×1 struct]
TreeDates: [10×1 datetime]
Model: [1×1 finmodel.HullWhite]
DiscountCurve: [1×1 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: {[10×1 double] [9×1 double] [8×1 double] [7×1 double] [6×1 double] [5×1 double] [4×1 double] [3×1 double] [2×1 double] [9.9809]}
Probs: {[3×1 double] [3×3 double] [3×5 double] [3×7 double] [3×9 double] [3×11 double] [3×13 double] [3×15 double] [3×17 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: {1×10 cell}
RateTree: {1×10 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: [1×4 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×4 table
Price Delta Gamma Vega
______ _______ ______ ______
11.174 -272.19 3667.6 243.09
Input Arguments
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.
| inpInstrument | Supported Sensitivities |
|---|---|
Cap | {'delta','gamma','vega','price'} |
Floor | {'delta','gamma','vega','price'} |
Swaption | {'delta','gamma','vega','price'} |
FixedBond | {'delta','gamma','vega','price'} |
OptionEmbeddedFixedBond | {'delta','gamma','vega','price'} |
FixedBondOption | {'delta','gamma','vega','price'} |
FloatBond | {'delta','gamma','vega','price'} |
FloatBondOption | {'delta','gamma','vega','price'} |
OptionEmbeddedFloatBond | {'delta','gamma','vega','price'} |
Note
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
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 specifyinpSensitivity)PriceResult.PricerData— Structure for pricer data that depends on the instrument that is being pricedFixedBond,FloatBond,FixedBondOption, andOptionEmbeddedFixedBondhave the following shared fields forPriceResult.PricerData.PriceTree:tObscontains the observation times.Connectcontains 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 areNumNodeselements 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:
PTreecontains the clean prices.AITreecontains the accrued interest.Probscontains the probability arrays. Each element of the cell array contains the up, middle, and down transition probabilities for each node of the level.dObscontains the date of each level of the tree.CFlowTis 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.FwdTreecontains the forward spot rate from one node to the next. The forward spot rate is defined as the inverse of the discount factor.ExTreecontains the exercise indicator arrays. Each element of the cell array is an array containing1's where an option is exercised and0's where it isn't.ProbTreecontains the probability of reaching each node from root node.ExProbTreecontains the exercise probabilities. Each element in the cell array is an array containing0's where there is no exercise, or the probability of reaching that node where exercise happens.ExProbsByTreeLevelis 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:
PTreeAITreeProbs.
A FloatBond instrument has
these additional fields within PriceResult.PricerData.PriceTree:
dObsCFlowTProbsFwdTree
A FixedBondOption
instrument has these additional fields within
PriceResult.PricerData.PriceTree:
PTreeProbsExTree
A OptionEmbeddedFixedBond instrument has these additional fields within
PriceResult.PricerData.PriceTree:
PTreeExTreeProbTreeExProbTreeExProbsByTreeLevel
The following table displays the PriceResult.PricerData.PriceTree
fields related to each instrument.
PriceResult.PricerData.PriceTree Fields | FixedBond | FloatBond | FixedBondOption | OptionEmbeddedFixedBond |
|---|---|---|---|---|
tObs | ✓ | ✓ | ✓ | ✓ |
Connect | ✓ | ✓ | ✓ | ✓ |
PTree | ✓ | No | ✓ | ✓ |
AITree | ✓ | No | No | No |
Probs | ✓ | ✓ | ✓ | No |
dObs | No | ✓ | No | No |
CFlowT | No | ✓ | No | No |
FwdTree | No | ✓ | ✓ | ✓ |
ExTree | No | No | ✓ | ✓ |
ProbTree | No | No | No | ✓ |
ExProbTree | No | No | No | ✓ |
ExProbsByTreeLevel | No | No | No | ✓ |
More About
A delta sensitivity measures the rate at which the price of an option is expected to change relative to a $1 change in the price of the underlying asset.
Delta is not a static measure; it changes as the price of the underlying asset changes (a concept known as gamma sensitivity), and as time passes. Options that are near the money or have longer until expiration are more sensitive to changes in delta.
A gamma sensitivity measures the rate of change of an option's delta in response to a change in the price of the underlying asset.
In other words, while delta tells you how much the price of an option might move, gamma tells you how fast the option's delta itself will change as the price of the underlying asset moves. This is important because this helps you understand the convexity of an option's value in relation to the underlying asset's price.
A vega sensitivity measures the sensitivity of an option's price to changes in the volatility of the underlying asset.
Vega represents the amount by which the price of an option would be expected to change for a 1% change in the implied volatility of the underlying asset. Vega is expressed as the amount of money per underlying share that the option's value will gain or lose as volatility rises or falls.
Version History
Introduced in R2020a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)