## Pricing Equity Derivatives Using Trees

### Computing Instrument Prices

The portfolio pricing functions `crrprice`, `eqpprice`, and `ittprice` calculate the price of any set of supported instruments based on a binary equity price tree, an implied trinomial price tree, or a standard trinomial tree. These functions are capable of pricing the following instrument types:

• Vanilla stock options

• American and European puts and calls

• Exotic options

• Asian

• Barrier

• Compound

• Lookback

• Stock options (Bermuda put and call schedules)

The syntax for calling the function `crrprice` is:

`[Price, PriceTree] = crrprice(CRRTree, InstSet, Options)`

The syntax for `eqpprice` is:

`[Price, PriceTree] = eqpprice(EQPTree, InstSet, Options)`

The syntax for `ittprice` is:

`Price = ittprice(ITTTree, ITTInstSet, Options)`

The syntax for `sttprice` is:

```[Price, PriceTree] = sttprice(STTTree, InstSet, Name, Value)```

These functions require two input arguments: the equity price tree and the set of instruments, `InstSet`, and allow a third optional argument.

#### Required Arguments

`CRRTree` is a CRR equity price tree created using `crrtree`. `EQPTree` is an equal probability equity price tree created using `eqptree`. `ITTTree` is an ITT equity price tree created using `itttree`. `STTTree` is a standard trinomial equity price tree created using `stttree`. See Building Equity Binary Trees and Building Implied Trinomial Trees to learn how to create these structures.

`InstSet` is a structure that represents the set of instruments to be priced independently using the model.

#### Optional Argument

You can enter a third optional argument, `Options`, used when pricing barrier options. For more specific information, see Pricing Options Structure.

These pricing functions internally classify the instruments and call the appropriate individual instrument pricing function for each of the instrument types. The CRR pricing functions are `asianbycrr`, `barrierbycrr`, `compoundbycrr`, `lookbackbycrr`, and `optstockbycrr`. A similar set of functions exists for EQP, ITT, and STT pricing. You can also use these functions directly to calculate the price of sets of instruments of the same type. See the reference pages for these individual functions for further information.

### Computing Prices Using CRR

Consider the following example, which uses the portfolio and stock price data in the MAT-file `deriv.mat` included in the toolbox. Load the data into the MATLAB® workspace.

```load deriv.mat ```

Use the MATLAB `whos` command to display a list of the variables loaded from the MAT-file.

```Name Size Bytes Class Attributes BDTInstSet 1x1 27344 struct BDTTree 1x1 7322 struct BKInstSet 1x1 27334 struct BKTree 1x1 8532 struct CRRInstSet 1x1 21066 struct CRRTree 1x1 7086 struct EQPInstSet 1x1 21066 struct EQPTree 1x1 7086 struct HJMInstSet 1x1 27336 struct HJMTree 1x1 8334 struct HWInstSet 1x1 27334 struct HWTree 1x1 8532 struct ITTInstSet 1x1 21070 struct ITTTree 1x1 12660 struct STTInstSet 1x1 21070 struct STTTree 1x1 7782 struct ZeroInstSet 1x1 17458 struct ZeroRateSpec 1x1 2152 struct ```

`CRRTree` and `CRRInstSet` are the required input arguments to call the function `crrprice`.

Use `instdisp` to examine the set of instruments contained in the variable `CRRInstSet`.

`instdisp(CRRInstSet)`
```Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 1 OptStock call 105 01-Jan-2003 01-Jan-2005 1 Call1 10 2 OptStock put 105 01-Jan-2003 01-Jan-2006 0 Put1 5 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt BarrierSpec Barrier Rebate Name Quantity 3 Barrier call 105 01-Jan-2003 01-Jan-2006 1 ui 102 0 Barrier1 1 Index Type UOptSpec UStrike USettle UExerciseDates UAmericanOpt COptSpec CStrike CSettle CExerciseDates CAmericanOpt Name Quantity 4 Compound call 130 01-Jan-2003 01-Jan-2006 1 put 5 01-Jan-2003 01-Jan-2005 1 Compound1 3 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 5 Lookback call 115 01-Jan-2003 01-Jan-2006 0 Lookback1 7 6 Lookback call 115 01-Jan-2003 01-Jan-2007 0 Lookback2 9 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt AvgType AvgPrice AvgDate Name Quantity 7 Asian put 110 01-Jan-2003 01-Jan-2006 0 arithmetic NaN NaN Asian1 4 8 Asian put 110 01-Jan-2003 01-Jan-2007 0 arithmetic NaN NaN Asian2 6 ```

Note

Because of space considerations, the compound option above (```Index 4```) has been condensed to fit the page. The `instdisp` command displays all compound option fields on your computer screen.

The instrument set contains eight instruments:

• Two vanilla options (`Call1`, `Put1`)

• One barrier option (`Barrier1`)

• One compound option (`Compound1`)

• Two lookback options (`Lookback1`, `Lookback2`)

• Two Asian options (`Asian1`, `Asian2`)

Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by `crrprice`.

Now use `crrprice` to calculate the price of each instrument in the instrument set.

`Price = crrprice(CRRTree, CRRInstSet)`
```Price = 8.2863 2.5016 12.1272 3.3241 7.6015 11.7772 4.1797 3.4219 ```

### Computing Prices Using EQP

Load the data into the MATLAB workspace.

```load deriv.mat ```

Use the MATLAB `whos` command to display a list of the variables loaded from the MAT-file.

```Name Size Bytes Class Attributes BDTInstSet 1x1 27344 struct BDTTree 1x1 7322 struct BKInstSet 1x1 27334 struct BKTree 1x1 8532 struct CRRInstSet 1x1 21066 struct CRRTree 1x1 7086 struct EQPInstSet 1x1 21066 struct EQPTree 1x1 7086 struct HJMInstSet 1x1 27336 struct HJMTree 1x1 8334 struct HWInstSet 1x1 27334 struct HWTree 1x1 8532 struct ITTInstSet 1x1 21070 struct ITTTree 1x1 12660 struct STTInstSet 1x1 21070 struct STTTree 1x1 7782 struct ZeroInstSet 1x1 17458 struct ZeroRateSpec 1x1 2152 struct ```

`EQPTree` and `EQPInstSet` are the input arguments required to call the function `eqpprice`.

Use the command `instdisp` to examine the set of instruments contained in the variable `EQPInstSet`.

```instdisp(EQPInstSet) ```
```Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 1 OptStock call 105 01-Jan-2003 01-Jan-2005 1 Call1 10 2 OptStock put 105 01-Jan-2003 01-Jan-2006 0 Put1 5 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt BarrierSpec Barrier Rebate Name Quantity 3 Barrier call 105 01-Jan-2003 01-Jan-2006 1 ui 102 0 Barrier1 1 Index Type UOptSpec UStrike USettle UExerciseDates UAmericanOpt COptSpec CStrike CSettle CExerciseDates CAmericanOpt Name Quantity 4 Compound call 130 01-Jan-2003 01-Jan-2006 1 put 5 01-Jan-2003 01-Jan-2005 1 Compound1 3 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 5 Lookback call 115 01-Jan-2003 01-Jan-2006 0 Lookback1 7 6 Lookback call 115 01-Jan-2003 01-Jan-2007 0 Lookback2 9 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt AvgType AvgPrice AvgDate Name Quantity 7 Asian put 110 01-Jan-2003 01-Jan-2006 0 arithmetic NaN NaN Asian1 4 8 Asian put 110 01-Jan-2003 01-Jan-2007 0 arithmetic NaN NaN Asian2 6 >> instdisp(EQPInstSet) Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 1 OptStock call 105 01-Jan-2003 01-Jan-2005 1 Call1 10 2 OptStock put 105 01-Jan-2003 01-Jan-2006 0 Put1 5 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt BarrierSpec Barrier Rebate Name Quantity 3 Barrier call 105 01-Jan-2003 01-Jan-2006 1 ui 102 0 Barrier1 1 Index Type UOptSpec UStrike USettle UExerciseDates UAmericanOpt COptSpec CStrike CSettle CExerciseDates CAmericanOpt Name Quantity 4 Compound call 130 01-Jan-2003 01-Jan-2006 1 put 5 01-Jan-2003 01-Jan-2005 1 Compound1 3 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 5 Lookback call 115 01-Jan-2003 01-Jan-2006 0 Lookback1 7 6 Lookback call 115 01-Jan-2003 01-Jan-2007 0 Lookback2 9 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt AvgType AvgPrice AvgDate Name Quantity 7 Asian put 110 01-Jan-2003 01-Jan-2006 0 arithmetic NaN NaN Asian1 4 8 Asian put 110 01-Jan-2003 01-Jan-2007 0 arithmetic NaN NaN Asian2 6 ```

Note

Because of space considerations, the compound option above (```Index 4```) has been condensed to fit the page. The `instdisp` command displays all compound option fields on your computer screen.

The instrument set contains eight instruments:

• Two vanilla options (`Call1`, `Put1`)

• One barrier option (`Barrier1`)

• One compound option (`Compound1`)

• Two lookback options (`Lookback1`, `Lookback2`)

• Two Asian options (`Asian1`, `Asian2`)

Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by `eqpprice`.

Now use `eqpprice` to calculate the price of each instrument in the instrument set.

`Price = eqpprice(EQPTree, EQPInstSet)`
```Price = 8.4791 2.6375 12.2632 3.5091 8.7941 12.9577 4.7444 3.9178```

### Computing Prices Using ITT

Consider the following example, which uses the portfolio and stock price data in the MAT-file `deriv.mat` included in the toolbox. Load the data into the MATLAB workspace.

```load deriv.mat ```

Use the MATLAB `whos` command to display a list of the variables loaded from the MAT-file.

```Name Size Bytes Class Attributes BDTInstSet 1x1 27344 struct BDTTree 1x1 7322 struct BKInstSet 1x1 27334 struct BKTree 1x1 8532 struct CRRInstSet 1x1 21066 struct CRRTree 1x1 7086 struct EQPInstSet 1x1 21066 struct EQPTree 1x1 7086 struct HJMInstSet 1x1 27336 struct HJMTree 1x1 8334 struct HWInstSet 1x1 27334 struct HWTree 1x1 8532 struct ITTInstSet 1x1 21070 struct ITTTree 1x1 12660 struct STTInstSet 1x1 21070 struct STTTree 1x1 7782 struct ZeroInstSet 1x1 17458 struct ZeroRateSpec 1x1 2152 struct ```

`ITTTree` and `ITTInstSet` are the input arguments required to call the function `ittprice`. Use the command `instdisp` to examine the set of instruments contained in the variable `ITTInstSet`.

```instdisp(ITTInstSet) ```
```Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 1 OptStock call 95 01-Jan-2006 31-Dec-2008 1 Call1 10 2 OptStock put 80 01-Jan-2006 01-Jan-2010 0 Put1 4 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt BarrierSpec Barrier Rebate Name Quantity 3 Barrier call 85 01-Jan-2006 31-Dec-2008 1 ui 115 0 Barrier1 1 Index Type UOptSpec UStrike USettle UExerciseDates UAmericanOpt COptSpec CStrike CSettle CExerciseDates CAmericanOpt Name Quantity 4 Compound call 99 01-Jan-2006 01-Jan-2010 1 put 5 01-Jan-2006 01-Jan-2010 1 Compound1 3 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 5 Lookback call 85 01-Jan-2006 01-Jan-2008 0 Lookback1 7 6 Lookback call 85 01-Jan-2006 01-Jan-2010 0 Lookback2 9 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt AvgType AvgPrice AvgDate Name Quantity 7 Asian call 55 01-Jan-2006 01-Jan-2008 0 arithmetic NaN NaN Asian1 5 8 Asian call 55 01-Jan-2006 01-Jan-2010 0 arithmetic NaN NaN Asian2 7 ```

The instrument set contains eight instruments:

• Two vanilla options (`Call1`, `Put1`)

• One barrier option (`Barrier1`)

• One compound option (`Compound1`)

• Two lookback options (`Lookback1`, `Lookback2`)

• Two Asian options (`Asian1`, `Asian2`)

Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by `ittprice`.

Now use `ittprice` to calculate the price of each instrument in the instrument set.

`Price = ittprice(ITTTree, ITTInstSet)`
```Price = 1.6506 10.6832 2.4074 3.2294 0.5426 6.1845 3.2052 6.6074```

### Computing Prices Using STT

Consider the following example, which uses the portfolio and stock price data in the MAT-file `deriv.mat` included in the toolbox. Load the data into the MATLAB workspace.

```load deriv.mat ```

Use the MATLAB `whos` command to display a list of the variables loaded from the MAT-file.

``` Name Size Bytes Class Attributes BDTInstSet 1x1 27344 struct BDTTree 1x1 7322 struct BKInstSet 1x1 27334 struct BKTree 1x1 8532 struct CRRInstSet 1x1 21066 struct CRRTree 1x1 7086 struct EQPInstSet 1x1 21066 struct EQPTree 1x1 7086 struct HJMInstSet 1x1 27336 struct HJMTree 1x1 8334 struct HWInstSet 1x1 27334 struct HWTree 1x1 8532 struct ITTInstSet 1x1 21070 struct ITTTree 1x1 12660 struct STTInstSet 1x1 21070 struct STTTree 1x1 7782 struct ZeroInstSet 1x1 17458 struct ZeroRateSpec 1x1 2152 struct ```

`STTTree` and `STTInstSet` are the input arguments required to call the function `sttprice`. Use the command `instdisp` to examine the set of instruments contained in the variable `STTInstSet`.

```instdisp(STTInstSet) ```
```Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 1 OptStock call 100 01-Jan-2009 01-Jan-2011 1 Call1 10 2 OptStock put 80 01-Jan-2009 01-Jan-2012 0 Put1 5 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt BarrierSpec Barrier Rebate Name Quantity 3 Barrier call 105 01-Jan-2009 01-Jan-2012 1 ui 115 0 Barrier1 1 Index Type UOptSpec UStrike USettle UExerciseDates UAmericanOpt COptSpec CStrike CSettle CExerciseDates CAmericanOpt Name Quantity 4 Compound call 95 01-Jan-2009 01-Jan-2012 1 put 5 01-Jan-2009 01-Jan-2011 1 Compound1 3 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt Name Quantity 5 Lookback call 90 01-Jan-2009 01-Jan-2012 0 Lookback1 7 6 Lookback call 95 01-Jan-2009 01-Jan-2013 0 Lookback2 9 Index Type OptSpec Strike Settle ExerciseDates AmericanOpt AvgType AvgPrice AvgDate Name Quantity 7 Asian call 100 01-Jan-2009 01-Jan-2012 0 arithmetic NaN NaN Asian1 4 8 Asian call 100 01-Jan-2009 01-Jan-2013 0 arithmetic NaN NaN Asian2 6 ```

The instrument set contains eight instruments:

• Two vanilla options (`Call1`, `Put1`)

• One barrier option (`Barrier1`)

• One compound option (`Compound1`)

• Two lookback options (`Lookback1`, `Lookback2`)

• Two Asian options (`Asian1`, `Asian2`)

Each instrument has a corresponding index that identifies the instrument prices in the price vector returned by `sttprice`.

Now use `sttprice` to calculate the price of each instrument in the instrument set.

`Price = sttprice(STTTree, STTInstSet)`
```Price = 4.5025 3.0603 3.7977 1.7090 11.7296 12.9120 1.6905 2.6203```

### Examining Output from the Pricing Functions

The prices in the output vector `Price` correspond to the prices at observation time zero (`tObs = 0`), which is defined as the valuation date of the equity tree. The instrument indexing within `Price` is the same as the indexing within `InstSet`.

In the CRR example, the prices in the `Price` vector correspond to the instruments in this order.

`InstNames = instget(CRRInstSet, 'FieldName','Name')`
```InstNames = Call1 Put1 Barrier1 Compound1 Lookback1 Lookback2 Asian1 Asian2 ```

So, in the `Price` vector, the fourth element, `3.3241`, represents the price of the fourth instrument (`Compound1`), and the sixth element, `11.7772`, represents the price of the sixth instrument (`Lookback2`).

In the ITT example, the prices in the `Price` vector correspond to the instruments in this order.

`InstNames = instget(ITTInstSet, 'FieldName','Name')`
```InstNames = Call1 Put1 Barrier1 Compound1 Lookback1 Lookback2 Asian1 Asian2 ```

So, in the `Price` vector, the first element, 1.650, represents the price of the first instrument (`Call1`), and the eighth elements, 6.607, represents the price of the eighth instrument (`Asian2`).

#### Price Tree Output for CRR

If you call a pricing function with two output arguments, for example:

```[Price, PriceTree] = crrprice(CRRTree, CRRInstSet) ```

you generate a price tree structure along with the price information.

This price tree structure `PriceTree` holds all pricing information.

```PriceTree = FinObj: 'BinPriceTree' PTree: {[8x1 double] [8x2 double] [8x3 double] [8x4 double] [8x5 double]} tObs: [0 1 2 3 4] dObs: [731582 731947 732313 732678 733043]```

The first field of this structure, `FinObj`, indicates that this structure represents a price tree. The second field, `PTree`, is the tree holding the prices of the instruments in each node of the tree. Finally, the third and fourth fields, `tObs` and `dObs`, represent the observation time and date of each level of `PTree`, with `tObs` using units in terms of compounding periods.

Using the command-line interface, you can directly examine `PriceTree.PTree`, the field within the `PriceTree` structure that contains the price tree with the price vectors at every state. The first node represents `tObs = 0`, corresponding to the valuation date.

`PriceTree.PTree{1}`
```ans = 8.2863 2.5016 12.1272 3.3241 7.6015 11.7772 4.1797 3.4219```

With this interface, you can observe the prices for all instruments in the portfolio at a specific time.

The function `eqpprice` also returns a price tree that you can examine in the same way.

#### Price Tree Output for ITT

If you call a pricing function with two output arguments, for example:

```[Price, PriceTree] = ittprice(ITTTree, ITTInstSet) ```

you generate a price tree structure along with the price information.

This price tree structure `PriceTree` holds all pricing information.

```PriceTree = FinObj: 'TrinPriceTree' PTree: {[8x1 double] [8x3 double] [8x5 double] [8x7 double] [8x9 double]} tObs: [0 1 2 3 4] dObs: [732678 733043 733408 733773 734139]```

The first field of this structure, `FinObj`, indicates that this structure represents a trinomial price tree. The second field, `PTree` is the tree holding the prices of the instruments in each node of the tree. Finally, the third and fourth fields, `tObs` and `dObs`, represent the observation time and date of each level of `PTree`, with `tObs` using units in terms of compounding periods.

Using the command-line interface, you can directly examine `PriceTree.PTree`, the field within the `PriceTree` structure that contains the price tree with the price vectors at every state. The first node represents `tObs = 0`, corresponding to the valuation date.

`PriceTree.PTree{1}`
```ans = 1.6506 10.6832 2.4074 3.2294 0.5426 6.1845 3.2052 6.6074```

With this interface, you can observe the prices for all instruments in the portfolio at a specific time.

#### Prices for Lookback and Asian Options for Equity Trees

Lookback options and Asian options are path-dependent, and, as such, there are no unique prices for any node except the root node. So, the corresponding values for lookback and Asian options in the price tree are set to `NaN`, the only exception being the root node. This becomes apparent if you examine the prices in the second node (`tobs = 1`) of the CRR price tree:

`PriceTree.PTree{2}`
```ans = 11.9176 0 0.9508 7.1914 16.4600 2.6672 2.5896 5.0000 NaN NaN NaN NaN NaN NaN NaN NaN ```

Examining the prices in the second node (`tobs = 1`) of the ITT price tree displays:

`PriceTree.PTree{2} `
``` ans = 3.9022 0 0 6.3736 13.3743 22.1915 5.6914 0 0 2.7663 3.8594 5.0000 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN```

### Graphical Representation of Equity Derivative Trees

You can use the function `treeviewer` to display a graphical representation of a tree, allowing you to examine interactively the prices and rates on the nodes of the tree until maturity. The graphical representations of CRR, EQP, and LR trees are equivalent to Black-Derman-Toy (BDT) trees, given that they are all binary recombining trees. The graphical representations of ITT and STT trees are equivalent to Hull-White (HW) trees, given that they are all trinomial recombining trees. See Graphical Representation of Trees for an overview on the use of `treeviewer` with CRR trees, EQP trees, LR trees, ITT trees, and STT trees and their corresponding option price trees. Follow the instructions for BDT trees.