# dblbarrierbyfd

Calculate double barrier option price using finite difference method

## Syntax

## Description

`[`

calculates a European or American call or put double barrier option price on a
single underlying asset using the finite difference method.
`Price`

,`PriceGrid`

,`AssetPrices`

,`Times`

]
= dblbarrierbyfd(`RateSpec`

,`StockSpec`

,`OptSpec`

,`Strike`

,`Settle`

,`ExerciseDates`

,`BarrierSpec`

,`Barrier`

)`dblbarrierbyfd`

assumes that the barrier is continuously
monitored.

`[`

specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntax.`Price`

,`PriceGrid`

,`AssetPrices`

,`Times`

]
= dblbarrierbyfd(___,`Name,Value`

)

## Examples

### Price an American Double Knock-Out Call Option with Rebate

Compute the price of an American double barrier option for a double knock-out (down and out-up and out) call option with a rebate using the following data:

Rate = 0.05; Settle = '01-Jun-2018'; Maturity = '01-Dec-2018'; Basis = 1;

Define a `RateSpec`

.

RateSpec = intenvset('ValuationDate', Settle, 'StartDates', Settle, 'EndDates', Maturity,'Rates', Rate, 'Compounding', -1, 'Basis', Basis);

Define a `StockSpec`

.

AssetPrice = 100; Volatility = 0.25; StockSpec = stockspec(Volatility, AssetPrice);

Define the double barrier option.

LBarrier = 80; UBarrier = 130; Barrier = [UBarrier LBarrier]; BarrierSpec = 'DKO'; OptSpec = 'Call'; Strike = 110; Rebate = 1;

Compute the price of an American option using finite differences.

Price = dblbarrierbyfd(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, BarrierSpec, Barrier,'Rebate', Rebate, 'AmericanOpt', 1)

Price = 4.0002

## Input Arguments

`StockSpec`

— Stock specification for underlying asset

structure

Stock specification for the underlying asset, specified by the
`StockSpec`

obtained from `stockspec`

.

`stockspec`

handles several
types of underlying assets. For example, for physical commodities the price
is `StockSpec.Asset`

, the volatility is
`StockSpec.Sigma`

, and the convenience yield is
`StockSpec.DividendAmounts`

.

**Data Types: **`struct`

`OptSpec`

— Definition of option

character vector with values `'call'`

or
`'put'`

| string scalar with values `"call"`

or
`"put"`

Definition of an option, specified as a character vector with a value of
`'call'`

or `'put'`

, or a string
scalar with values `"call"`

or
`"put"`

.

**Data Types: **`char`

| `string`

`Strike`

— Option strike price value

scalar numeric

Option strike price value, specified as a scalar numeric.

**Data Types: **`double`

`Settle`

— Settlement or trade date

date character vector | serial date number | datetime object

Settlement or trade date for the barrier option, specified as a serial date number, a date character vector, or a datetime object.

**Data Types: **`double`

| `char`

| `datetime`

`ExerciseDates`

— Option exercise dates

date character vector | serial date number | datetime object

Option exercise dates, specified as a date character vector, a serial date number, or datetime object.

For a European option, the option expiry date has only one

`ExerciseDates`

value.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. If only one non-`NaN`

date is listed, the option can be exercised between`Settle`

and the single listed date in`ExerciseDates`

.

**Data Types: **`double`

| `char`

| `cell`

| `datetime`

`BarrierSpec`

— Double barrier option type

character vector with value of `'DKI'`

or
`'DKO'`

| scalar string with value of `"DKI"`

or
`"DKO"`

Double barrier option type, specified as a character vector or string with one of the following values:

`'DKI'`

— Double Knock-inThe

`'DKI'`

option becomes effective when the price of the underlying asset reaches one of the barriers. It gives the option holder the right but not the obligation to buy or sell the underlying security at the strike price, if the underlying asset goes above or below the barrier levels during the life of the option.`'DKO'`

— Double Knock-outThe

`'DKO'`

option gives the option holder the right but not the obligation to buy or sell the underlying security at the strike price, as long as the underlying asset remains between the barrier levels during the life of the option. This option terminates when the price of the underlying asset passes one of the barriers.

Option | Barrier Type | Payoff If Any Barrier Crossed | Payoff If Barriers Not Crossed |
---|---|---|---|

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

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

**Data Types: **`char`

| `string`

`Barrier`

— Barrier level

vector

Barrier level, specified as a `1`

-by-`2`

vector of numeric values, where the first column is the upper barrier
(1)(UB) and the second column is the lower barrier (2)(LB). Barrier(1) must
be greater than Barrier(2).

**Data Types: **`double`

### Name-Value Arguments

Specify optional
comma-separated pairs of `Name,Value`

arguments. `Name`

is
the argument name and `Value`

is the corresponding value.
`Name`

must appear inside quotes. You can specify several name and value
pair arguments in any order as
`Name1,Value1,...,NameN,ValueN`

.

**Example:**

```
Price =
dblbarrierbyfd(RateSpec,StockSpec,OptSpec,Strike,Settle,Maturity,BarrierSpec,Barrier,'Rebate',[100,100])
```

`Rebate`

— Rebate value

`[0 0]`

for Double Knock-out or
`0`

for Double Knock-in (default) | vector | scalar numeric

Rebate value, specified as the comma-separated pair consisting of
`'Rebate'`

and one of the following:

For a Double Knock-out option, use a

`1`

-by-`2`

vector of rebate values where the first column is the payout if the upper barrier(1)(UB) is hit and the second column is payout if the lower barrier(2)(LB) is hit. The rebate is paid when the barrier is reached.For a Double Knock-in option, use a scalar rebate value. The rebate is paid at expiry.

**Data Types: **`double`

`AssetGridSize`

— Size of asset grid used for a finite difference grid

`400`

(default) | positive scalar numeric

Size of the asset grid used for the finite difference grid, specified
as the comma-separated pair consisting of
`'AssetGridSize'`

and a positive scalar
numeric.

**Data Types: **`double`

`TimeGridSize`

— Size of time grid used for finite difference grid

`100`

(default) | positive scalar numeric

Size of the time grid used for the finite difference grid, specified
as the comma-separated pair consisting of
`'TimeGridSize'`

and a positive scalar numeric.

**Note**

The actual time grid may have a larger size because exercise
and ex-dividend dates might be added to the grid from
`StockSpec`

.

**Data Types: **`double`

`AmericanOpt`

— Option type

`0`

European (default) | integer with values `0`

or
`1`

Option type, specified as the comma-separated pair consisting of
`'AmericanOpt'`

and a scalar flag with one of the
following values:

`0`

— European`1`

— American

**Data Types: **`logical`

## Output Arguments

`Price`

— Expected prices for double barrier options

matrix

Expected prices for double barrier options, returned as a
`1`

-by-`1`

matrix.

`PriceGrid`

— Grid containing prices

grid

Grid containing prices calculated by the finite difference method,
returned as a two-dimensional grid with the size
`AssetGridSize*TimeGridSize`

. The number of columns
does not have to be equal to the `TimeGridSize`

, because
exercise and ex-dividend dates in `StockSpec`

are added
to the time grid. `PriceGrid(:, end)`

contains the price
for `t = 0`

.

`Times`

— Times corresponding to second dimension of `PriceGrid`

vector

Times corresponding to the second dimension of
`PriceGrid`

, returned as a vector.

## More About

### Double Barrier Option

A *double barrier* option is similar to the
standard single barrier option except that it has two barrier levels: a lower
barrier (`LB`

) and an upper barrier (`UB`

).

The payoff for a double barrier option depends on whether the underlying asset remains between the barrier levels during the life of the option. Double barrier options are less expensive than single barrier options as they have a higher knock-out probability. Because of this, double barrier options allow investors to reduce option premiums and match an investor’s belief about the future movement of the underlying price process.

## References

[1] Boyle, P., and Y. Tian.
“An Explicit Finite Difference Approach to the Pricing of Barrier
Options.” *Applied Mathematical Finance.* Vol. 5, Number 1,
1998, pp. 17–43.

[2] Hull, J. *Options, Futures, and Other Derivatives.* Fourth
Edition. Upper Saddle River, NJ: Prentice Hall, 2000, pp. 646–649.

[3] Rubinstein, M., and E. Reiner. “Breaking Down the Barriers.”
*Risk.* Vol. 4, Number 8, 1991, pp. 28–35.

[4] Zvan, R., P. A. Forsyth and K. R. Vetzal. “PDE Methods for Pricing
Barrier Options.” *Journal of Economic Dynamics and
Control.* Vol. 24, Number 11-12, 2000, pp. 1563–1590.

## See Also

**Introduced in R2019a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

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