# price

## 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

### Use `IRTree`

Pricer and `HullWhite`

Model to Price `FixedBondOption`

Instrument

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]

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 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]

outPR.Results

`ans=`*1×4 table*
Price Delta Gamma Vega
______ _______ ______ ______
11.174 -272.19 3667.6 243.09

## Input Arguments

`inpInstrument`

— Instrument object

`Cap`

object | `Floor`

object | `Swaption`

object | `FixedBond`

object | `OptionEmbeddedFixedBond`

object | `OptionEmbeddedFloatBond`

object | `FixedBondOption`

object | `FloatBond`

object | `FloatBondOption`

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`

`inpSensitivity`

— List of sensitivities to compute

`[ ]`

(default) | string array with values `"Price"`

, `"Delta"`

,
`"Gamma"`

, `"Vega"`

, and
`"All"`

| cell array of character vectors with values `'Price'`

,
`'Delta'`

, `'Gamma'`

, `'Vega'`

, and
`'All'`

(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

`Price`

— Instrument price

numeric

Instrument price, returned as a numeric.

`PriceResult`

— Price result

`PriceResult`

object

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` 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

### Delta

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.

### Gamma

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.

### Vega

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)