# barrierbycrr

Price barrier option from Cox-Ross-Rubinstein binomial tree

## Syntax

## Description

`[`

calculates prices for barrier options using a
Cox-Ross-Rubinstein binomial tree.`Price`

,`PriceTree`

]
= barrierbycrr(`CRRTree`

,`OptSpec`

,`Strike`

,`Settle`

,`AmericanOpt`

,`ExerciseDates`

,`BarrierSpec`

,`Barrier`

)

**Note**

Alternatively, you can use the `Barrier`

object to price Barrier options.
For more information, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.

## Examples

### Price a Barrier Option Using a CRR Binomial Tree

This example shows how to price a barrier option using a CRR binomial tree by loading the file deriv.mat, which provides CRRTree. The CRRTree structure contains the stock specification and time information needed to price the option.

load deriv.mat; OptSpec = 'Call'; Strike = 105; Settle = datetime(2003,1,1); ExerciseDates = datetime(2006,1,1); AmericanOpt = 1; BarrierSpec = 'UI'; Barrier = 102; Price = barrierbycrr(CRRTree, OptSpec, Strike, Settle, ... ExerciseDates, AmericanOpt, BarrierSpec, Barrier)

Price = 12.1272

## Input Arguments

`CRRTree`

— Stock tree structure

structure

Stock tree structure, specified by using `crrtree`

.

**Data Types: **`struct`

`OptSpec`

— Definition of option

character vector with values `'call'`

or `'put'`

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

or `'put'`

Definition of an option as `'call'`

or `'put'`

,
specified as a `NINST`

-by-`1`

cell
array of character vector values.

**Data Types: **`char`

| `cell`

`Strike`

— Option strike price value

integer

Option strike price value for a European or an American Option, specified as
`NINST`

-by-`1`

matrix of integers. Each row is the schedule for
one option.

**Data Types: **`double`

`Settle`

— Settlement or trade date

datetime array | string array | date character vector

Settlement or trade date for the barrier option, specified as a
`NINST`

-by-`1`

vector using a datetime array, string array, or
date character vectors. The
`Settle`

date for every barrier
is set to the `ValuationDate`

of
the stock tree. The barrier argument
`Settle`

is ignored.

To support existing code, `barrierbycrr`

also
accepts serial date numbers as inputs, but they are not recommended.

`ExerciseDates`

— Option exercise dates

datetime array | string array | date character vector

Option exercise dates, specified as a datetime array, string array, or date character vector:

For a European option, use a

`1`

-by-`1`

matrix of dates. Each row is the schedule for one option. For a European option, there is only one`ExerciseDates`

on the option expiry date which is the maturity of the instrument.For an American option, use a

`1`

-by-`2`

vector of exercise date boundaries. The option can be exercised on any date between or including the pair of dates on that row. If only one non-`NaN`

date is listed, or if`ExerciseDates`

is a`NINST`

-by-`1`

, the option can be exercised between`ValuationDate`

of the stock tree and the single listed date in`ExerciseDates`

.

To support existing code, `barrierbycrr`

also
accepts serial date numbers as inputs, but they are not recommended.

`AmericanOpt`

— Option type

Option type values `0`

or
`1`

Option type, specified as `NINST`

-by-`1`

matrix of integer
flags with values:

`0`

— European`1`

— American

**Data Types: **`double`

`BarrierSpec`

— Barrier option type

character vector with values: `'UI'`

, `'UO'`

, `'DI'`

, `'DO'`

| cell array of character vectors with values: `'UI'`

, `'UO'`

, `'DI'`

, `'DO'`

Barrier option type, specified as a character vector or an
`NINST`

-by-`1`

cell array of character vectors with the following
values:

`'UI'`

— Up Knock-inThis option becomes effective when the price of the underlying asset passes above the barrier level. It gives the option holder the right, but not the obligation, to buy or sell (call/put) the underlying security at the strike price if the underlying asset goes above the barrier level during the life of the option.

`'UO'`

— Up Knock-outThis option gives the option holder the right, but not the obligation, to buy/sell (call/put) the underlying security at the strike price as long as the underlying asset does not go above the barrier level during the life of the option. This option terminates when the price of the underlying asset passes above the barrier level. Usually, with an up-and-out option, the rebate is paid if the spot price of the underlying reaches or exceeds the barrier level.

`'DI'`

— Down Knock-inThis option becomes effective when the price of the underlying stock passes below the barrier level. It gives the option holder the right, but not the obligation, to buy or sell (call/put) the underlying security at the strike price if the underlying security goes below the barrier level during the life of the option. With a down-and-in option, the rebate is paid if the spot price of the underlying does not reach the barrier level during the life of the option. Note,

`barrierbyfd`

does not support American knock-in barrier options.`'DO'`

— Down Knock-upThis option gives the option holder the right, but not the obligation, to buy or sell (call/put) the underlying asset at the strike price as long as the underlying asset does not go below the barrier level during the life of the option. This option terminates when the price of the underlying security passes below the barrier level. Usually the option holder receives a rebate amount if the option expires worthless.

Option | Barrier Type | Payoff if Barrier Crossed | Payoff if Barrier not Crossed |
---|---|---|---|

Call/Put | Down Knock-out | Worthless | Standard Call/Put |

Call/Put | Down Knock-in | Call/Put | Worthless |

Call/Put | Up Knock-out | Worthless | Standard Call/Put |

Call/Put | Up Knock-in | Standard Call/Put | Worthless |

**Data Types: **`char`

| `cell`

`Barrier`

— Barrier level

numeric

Barrier level, specified as a
`NINST`

-by-`1`

matrix of numeric values.

**Data Types: **`double`

`Rebate`

— Rebate value

`0`

(default) | numeric

(Optional) Rebate value, specified as a `NINST`

-by-`1`

matrix of numeric values. For Knock-in options,
the `Rebate`

is paid at expiry.
For Knock-out options, the
`Rebate`

is paid when the
`Barrier`

is reached.

**Data Types: **`double`

`Options`

— Derivatives pricing options

structure

(Optional) Derivatives pricing options, specified as structure
that is created with `derivset`

.

**Data Types: **`struct`

## Output Arguments

`Price`

— Expected prices for barrier options at time 0

matrix

Expected prices for barrier options at time 0, returned as a
`NINST`

-by-`1`

matrix.

`PriceTree`

— Structure with vector of barrier option prices at each node

tree structure

Structure with a vector of barrier option prices at each node, returned as a tree structure.

`PriceTree`

is a MATLAB^{®} structure of trees
containing vectors of instrument prices and a vector of observation
times for each node.

`PriceTree.PTree`

contains the prices.

`PriceTree.tObs`

contains the observation times.

`PriceTree.dObs`

contains the observation dates.

## More About

### Barrier Option

A *Barrier option* has
not only a strike price but also a barrier level and sometimes a rebate.

A rebate is a fixed amount that is paid if the option cannot be exercised because the barrier
level has been reached or not reached. The payoff for this
type of option depends on whether the underlying asset
crosses the predetermined trigger value (barrier level),
indicated by `Barrier`

, during the life
of the option. For more information, see Barrier Option.

## References

[1] Derman, E., I. Kani, D. Ergener and I. Bardhan. “Enhanced
Numerical Methods for Options with Barriers.” *Financial
Analysts Journal.* (Nov.-Dec.), 1995, pp. 65–74.

## Version History

**Introduced before R2006a**

### R2022b: Serial date numbers not recommended

Although `barrierbycrr`

supports serial date numbers,
`datetime`

values are recommended instead. The
`datetime`

data type provides flexible date and time
formats, storage out to nanosecond precision, and properties to account for time
zones and daylight saving time.

To convert serial date numbers or text to `datetime`

values, use the `datetime`

function. For example:

t = datetime(738427.656845093,"ConvertFrom","datenum"); y = year(t)

y = 2021

There are no plans to remove support for serial date number inputs.

## See Also

`crrtree`

| `instbarrier`

| `Barrier`

### Topics

- Computing Prices Using CRR
- Graphical Representation of Equity Derivative Trees
- Pricing European Call Options Using Different Equity Models
- Calibrate Option Pricing Model Using Heston Model
- Barrier Option
- Pricing Options Structure
- Supported Equity Derivative Functions
- Mapping Financial Instruments Toolbox Functions for Equity, Commodity, FX Instrument Objects

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