dblbarriersensbyfd
Calculate double barrier option price and sensitivities using finite difference method
Syntax
Description
[
calculates a European or American call or put double barrier option price and
sensitivities of a single underlying asset using the finite difference method.
PriceSens
,PriceGrid
,AssetPrices
,Times
]
= dblbarriersensbyfd(RateSpec
,StockSpec
,OptSpec
,Strike
,Settle
,ExerciseDates
,BarrierSpec
,Barrier
)dblbarrierbyfd
assumes that the barrier is continuously monitored.
Note
Alternatively, you can use the DoubleBarrier
object to calculate price or sensitivities for
double barrier options. For more information, see Get Started with Workflows Using ObjectBased Framework for Pricing Financial Instruments.
[
specifies options using one or more namevalue pair arguments in addition to the
input arguments in the previous syntax.PriceSens
,PriceGrid
,AssetPrices
,Times
]
= dblbarriersensbyfd(___,Name,Value
)
Examples
Calculate Price and Sensitivities for an American Double KnockOut Call Option with Rebate
Compute the price and sensitivities for an American double barrier option for a double knockout (down and outup and out) call option with a rebate using the following data:
Rate = 0.05; Settle = datetime(2018,6,1); Maturity = datetime(2018,12,1); 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; OutSpec = {'price'; 'vega'; 'theta'};
Compute the price and sensitivities for an American option using finite differences.
[Price, Vega, Theta] = dblbarriersensbyfd(RateSpec, StockSpec, OptSpec, Strike, Settle, Maturity, BarrierSpec, Barrier,'Rebate', Rebate, 'AmericanOpt', 1,'Outspec', OutSpec)
Price = 4.0002
Vega = 1.9180e+03
Theta = 6.6509
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
datetime scalar  string scalar  date character vector
Settlement or trade date for the barrier option, specified as a scalar datetime, string, or date character vector.
To support existing code, dblbarriersensbyfd
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 vectors.
For a European option, the option expiry date has only one
ExerciseDates
value.For an American option, use a
1
by2
vector of exercise date boundaries. The option can be exercised on any date between or including the pair of dates. If only one nonNaN
date is listed, the option can be exercised betweenSettle
and the single listed date inExerciseDates
.
To support existing code, dblbarriersensbyfd
also
accepts serial date numbers as inputs, but they are not recommended.
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 KnockinThe
'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 KnockoutThe
'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 Knockin  Standard Call/Put  Worthless 
Call/Put  Double Knockout  Worthless  Standard Call/Put 
Data Types: char
 string
Barrier
— Barrier level
vector
Barrier level, specified as a 1
by2
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
NameValue Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN
, where Name
is
the argument name and Value
is the corresponding value.
Namevalue arguments must appear after other arguments, but the order of the
pairs does not matter.
Before R2021a, use commas to separate each name and value, and enclose
Name
in quotes.
Example: PriceSens =
dblbarriersensbyfd(RateSpec,StockSpec,OptSpec,Strike,Settle,Maturity,BarrierSpec,Barrier,'OutSpec',{'delta','gamma','vega','lambda','rho','theta','price'},'AmericanOpt',1)
OutSpec
— Define outputs
{'Price'}
(default)  character vector with values 'Price'
,
'Delta'
, 'Gamma'
,
'Vega'
, 'Lambda'
,
'Rho'
, 'Theta'
, and
'All'
 cell array of character vectors with values
'Price'
, 'Delta'
,
'Gamma'
, 'Vega'
,
'Lambda'
, 'Rho'
,
'Theta'
, and 'All'
 string array with values "Price"
,
"Delta"
, "Gamma"
,
"Vega"
, "Lambda"
,
"Rho"
, "Theta"
, and
"All"
Define outputs, specified as the commaseparated pair consisting of
'OutSpec'
and a NOUT

by1
or a
1
byNOUT
cell array of
character vectors or a string array with possible values of
'Price'
, 'Delta'
,
'Gamma'
, 'Vega'
,
'Lambda'
, 'Rho'
,
'Theta'
, and 'All'
.
OutSpec = {'All'}
specifies that the output is
Delta
, Gamma
,
Vega
, Lambda
,
Rho
, Theta
, and
Price
, in that order. This is the same as
specifying OutSpec
to include each
sensitivity.
Example: OutSpec =
{'delta','gamma','vega','lambda','rho','theta','price'}
Data Types: char
 cell
 string
Rebate
— Rebate value
[0 0]
for Double Knockout or
0
for Double Knockin (default)  vector  scalar numeric
Rebate value, specified as the commaseparated pair consisting of
'Rebate'
and one of the following:
For a Double Knockout option, use a
1
by2
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 Knockin option, use a scalar rebate value. The rebate is paid at expiry.
Data Types: double
AssetGridSize
— Size of asset grid used for finite difference grid
400
(default)  positive scalar numeric
Size of the asset grid used for the finite difference grid, specified
as the commaseparated 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 commaseparated pair consisting of
'TimeGridSize'
and a positive scalar numeric.
Note
The actual time grid may have a larger size because exercise
and exdividend 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 commaseparated pair consisting of
'AmericanOpt'
and a scalar flag with one of the
following values:
0
— European1
— American
Data Types: logical
Output Arguments
PriceSens
— Expected prices or sensitivities values for double barrier options
matrix
Expected prices or sensitivities (defined using
OutSpec
) for double barrier options, returned as a
1
byNOUT
matrix.
PriceGrid
— Grid containing prices
grid
Grid containing prices calculated by the finite difference method,
returned as a twodimensional grid with the size
AssetGridSize*TimeGridSize
. The number of columns
does not have to be equal to the TimeGridSize
, because
exercise and exdividend 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 the
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 knockout 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 1112, 2000, pp. 1563–1590.
Version History
Introduced in R2019aR2022b: Serial date numbers not recommended
Although dblbarriersensbyfd
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.
MATLABBefehl
Sie haben auf einen Link geklickt, der diesem MATLABBefehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLABBefehlsfenster aus. Webbrowser unterstützen keine MATLABBefehle.
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)