Barrier
Barrier instrument object
Description
Create and price a Barrier instrument object for one or
more Barrier instruments using this workflow:
Use
fininstrumentto create aBarrierinstrument object for one or more Barrier instruments.Use
finmodelto specify aBlackScholes,Heston,Bates, orMertonmodel for theBarrierinstrument object.Choose a pricing method.
When using a
BlackScholesmodel, usefinpricerto specify aBlackScholes,AssetTree, orVannaVolgapricing method for one or moreBarrierinstruments.When using a
BlackScholes,Heston,Bates, orMertonmodel, usefinpricerto specify anAssetMonteCarloorFiniteDifferencepricing method for one ore moreBarrierinstruments.
For more information on this workflow, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
For more information on the available models and pricing methods for a
Barrier instrument, see Choose Instruments, Models, and Pricers.
Creation
Syntax
Description
creates a BarrierOpt = fininstrument(InstrumentType,'Strike',strike_value,'ExerciseDate',exercise_date,'BarrierValue',barrier_value)Barrier instrument object for one or more
Barrier instruments by specifying InstrumentType and
sets the properties for the
required name-value pair arguments Strike,
ExerciseDate, and
BarrierValue.
sets optional properties using
additional name-value pairs in addition to the required arguments in the
previous syntax. For example, BarrierOpt = fininstrument(___,Name,Value)BarrierOpt =
fininstrument("Barrier",'Strike',100,'ExerciseDate',datetime(2019,1,30),'BarrierValue',110,'OptionType',"put",'ExerciseStyle',"European",'BarrierType',"DO",'Name',"barrier_option")
creates a Barrier put option with an European exercise.
You can specify multiple name-value pair arguments.
Input Arguments
Instrument type, specified as a string with the value of
"Barrier", a character vector with the value of
'Barrier', an
NINST-by-1 string array with
values "Barrier", or an
NINST-by-1 cell array of
character vectors with values of 'Barrier'.
Data Types: char | string | cell
Name-Value Arguments
Specify required
and optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where
Name is the argument name and Value is
the corresponding value. Name-value 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: BarrierOpt =
fininstrument("Barrier",'Strike',100,'ExerciseDate',datetime(2019,1,30),'BarrierValue',110,'OptionType',"put",'ExerciseStyle',"European",'BarrierType',"DO",'Name',"barrier_option")
Required Barrier Name-Value Pair Arguments
Option strike value, specified as the comma-separated pair
consisting of 'Strike' and a scalar nonnegative
value or an NINST-by-1 vector
of nonnegative values.
Data Types: double
Option exercise date, specified as the comma-separated pair
consisting of 'ExerciseDate' and a scalar or an
NINST-by-1 vector using a
datetime array, string array, or date character vectors.
Note
For a European option, there is only one
ExerciseDate on the option expiry
date.
To support existing code, Barrier also
accepts serial date numbers as inputs, but they are not recommended.
If you use date character vectors or strings, the format must be
recognizable by datetime because
the ExerciseDate property is stored as a
datetime.
Barrier level, specified as the comma-separated pair consisting of
'BarrierLevel' and a scalar numeric or an
NINST-by-1 numeric
vector.
Data Types: double
Optional Barrier Name-Value Pair Arguments
Option type, specified as the comma-separated pair consisting of
'OptionType' and a scalar character vector or
string or an NINST-by-1 cell
array of character vectors or string array.
A barrier call option gives the holder the right, but not the obligation, to buy the underlying asset at a predetermined strike price if the barrier condition is met. A barrier put option gives the holder the right, but not the obligation, to sell the underlying asset at a predetermined strike price if the barrier condition is met.
Data Types: char | cell | string
Option exercise style, specified as the comma-separated pair
consisting of 'ExerciseStyle' and a scalar string
or character vector or an
NINST-by-1 cell array of
character vectors or string array.
Note
For a Barrier option, the BlackScholes pricer supports only
"European" exercise and the FiniteDifference pricer supports an
"American" or
"European" exercise.
Data Types: string | char | cell
Barrier option type, specified as the comma-separated pair
consisting of 'BarrierType' and a scalar string
or character vector or an
NINST-by-1 cell array of
character vectors or string array with one of the following values:
"UI"— Up knock-inThis option becomes effective when the price of the underlying asset passes above the barrier level. If the underlying asset goes above the barrier level during the life of the option, the option holder has the right, but not the obligation, to buy or sell (call or put) the underlying security at the strike price.
"UO"— Up knock-outThis option gives the option holder the right, but not the obligation, to buy or sell (call or 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 security passes above the barrier level. If the spot price of the underlying asset reaches or exceeds the barrier level with an up-and-out option, the rebate is paid.
"DI"— Down knock-inThis option becomes effective when the price of the underlying stock passes below the barrier level. If the underlying security goes below the barrier level during the life of the option, the option holder has the right, but not the obligation, to buy or sell (call or put) the underlying security at the strike price. 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 that a
Barrierinstrument using theFiniteDifferencepricer 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 or 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. If the option is worthless when it expires, the option holder receives a rebate amount.
| Option | Barrier Type | Payoff If Barrier Crossed | Payoff If Barrier Not Crossed |
|---|---|---|---|
| Call or Put | Down knock-out | Worthless | Standard Call or Put |
| Call or Put | Down knock-in | Call or Put | Worthless |
| Call or Put | Up knock-out | Worthless | Standard Call or Put |
| Call or Put | Up knock-in | Standard Call or Put | Worthless |
Data Types: char | cell | string
Rebate value, specified as the comma-separated pair consisting of
'Rebate' and a scalar numeric or an
NINST-by-1 numeric vector.
For knock-in options, the
Rebateis paid at expiry.For knock-out options, the
Rebateis paid whenBarrierValueis reached.
Data Types: double
User-defined name for the instrument, specified as the
comma-separated pair consisting of 'Name' and a
scalar string or character vector or an
NINST-by-1 cell array of
character vectors or string array.
Data Types: char | cell | string
Output Arguments
Barrier instrument, returned as a Barrier
object.
Properties
Option strike value, returned as a scalar nonnegative value or an
NINST-by-1 vector of nonnegative
values.
Data Types: double
Option exercise date, returned as a datetime or an
NINST-by-1 vector of
datetimes.
Data Types: datetime
Option type, returned as a scalar string or an
NINST-by-1 string array with the
values of "call" or "put".
Data Types: string
Option exercise style, returned as a scalar string or
NINST-by-1 string array with the
values of "European" or "American".
Data Types: string
Barrier option type, returned as a scalar string or
NINST-by-1 string array with the
values of "UI", "UO",
"DI", or "DO".
Data Types: string
Barrier level, returned as a scalar numeric or an
NINST-by-1 numeric vector.
Data Types: double
Rebate value, returned as a scalar numeric or an
NINST-by-1 numeric vector.
Data Types: double
User-defined name for the instrument, returned as a string or an
NINST-by-1 string array.
Data Types: string
Examples
This example shows the workflow to price an Barrier instrument when you use a BlackScholes model and a FiniteDifference pricing method.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create FiniteDifference Pricer Object
Use finpricer to create a FiniteDifference pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
outPricer = finpricer("FiniteDifference",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',50)
outPricer =
FiniteDifference with properties:
DiscountCurve: [1×1 ratecurve]
Model: [1×1 finmodel.BlackScholes]
SpotPrice: 50
GridProperties: [1×1 struct]
DividendType: "continuous"
DividendValue: 0
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(outPricer,BarrierOpt,["all"])Price = 8.5014
outPR =
priceresult with properties:
Results: [1×7 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×7 table
Price Delta Gamma Lambda Theta Rho Vega
______ _______ _________ ______ _______ ______ ______
8.5014 0.85673 0.0057199 5.0388 -1.8461 26.238 6.1837
This example shows the workflow to price multiple Barrier instruments when you use a BlackScholes model and a FiniteDifference pricing method.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object for three Barrier instruments.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime([2019,1,1; 2019,2,1 ; 2019,3,1]),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue', [40; 30; 20],'Name',"barrier_option")
BarrierOpt=3×1 Barrier array with properties:
OptionType
Strike
BarrierType
BarrierValue
Rebate
ExerciseStyle
ExerciseDate
Name
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create FiniteDifference Pricer Object
Use finpricer to create a FiniteDifference pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
outPricer = finpricer("FiniteDifference",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',50)
outPricer =
FiniteDifference with properties:
DiscountCurve: [1×1 ratecurve]
Model: [1×1 finmodel.BlackScholes]
SpotPrice: 50
GridProperties: [1×1 struct]
DividendType: "continuous"
DividendValue: 0
Price Barrier Instruments
Use price to compute the prices and sensitivities for the Barrier instruments.
[Price, outPR] = price(outPricer,BarrierOpt,["all"])Price = 3×1
8.5014
9.7112
9.9901
outPR=3×1 priceresult array with properties:
Results
PricerData
outPR.Results
ans=1×7 table
Price Delta Gamma Lambda Theta Rho Vega
______ _______ _________ ______ _______ ______ ______
8.5014 0.85673 0.0057199 5.0388 -1.8461 26.238 6.1837
ans=1×7 table
Price Delta Gamma Lambda Theta Rho Vega
______ _______ ________ ______ _______ ______ ______
9.7112 0.73186 0.020793 3.7681 -3.2754 29.014 16.885
ans=1×7 table
Price Delta Gamma Lambda Theta Rho Vega
______ ______ ________ ______ _______ ______ ______
9.9901 0.7296 0.020326 3.6516 -3.2151 30.872 17.803
This example shows the workflow to price an Barrier instrument when you use a BlackScholes model and an AssetTree pricing method using an Equal Probability (EQP) tree.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create AssetTree Pricer Object
Use finpricer to create an AssetTree pricer object with an EQP equity tree and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
NumPeriods = 15; EQPPricer = finpricer("AssetTree",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',1000,'PricingMethod',"EqualProbability",'Maturity',datetime(2019,1,1),'NumPeriods',NumPeriods)
EQPPricer =
EQPTree with properties:
Tree: [1×1 struct]
NumPeriods: 15
Model: [1×1 finmodel.BlackScholes]
DiscountCurve: [1×1 ratecurve]
SpotPrice: 1000
DividendType: "continuous"
DividendValue: 0
TreeDates: [25-Jan-2018 08:00:00 18-Feb-2018 16:00:00 15-Mar-2018 00:00:00 08-Apr-2018 08:00:00 02-May-2018 16:00:00 27-May-2018 00:00:00 20-Jun-2018 08:00:00 14-Jul-2018 16:00:00 … ] (1×15 datetime)
EQPPricer.Tree
ans = struct with fields:
Probs: [2×15 double]
ATree: {1×16 cell}
dObs: [01-Jan-2018 00:00:00 25-Jan-2018 08:00:00 18-Feb-2018 16:00:00 15-Mar-2018 00:00:00 08-Apr-2018 08:00:00 02-May-2018 16:00:00 27-May-2018 00:00:00 20-Jun-2018 08:00:00 14-Jul-2018 16:00:00 … ] (1×16 datetime)
tObs: [0 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1]
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(EQPPricer,BarrierOpt,["all"])Price = 956.5478
outPR =
priceresult with properties:
Results: [1×7 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×7 table
Price Delta Gamma Vega Lambda Rho Theta
______ _____ __________ ___________ ______ _____ _______
956.55 1 9.3133e-18 -6.8212e-09 1.0454 43.45 -1.5208
outPR.PricerData.PriceTree
ans = struct with fields:
PTree: {1×16 cell}
ExTree: {1×16 cell}
tObs: [0 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1]
dObs: [01-Jan-2018 25-Jan-2018 18-Feb-2018 15-Mar-2018 08-Apr-2018 02-May-2018 27-May-2018 20-Jun-2018 14-Jul-2018 08-Aug-2018 01-Sep-2018 25-Sep-2018 20-Oct-2018 13-Nov-2018 07-Dec-2018 01-Jan-2019]
Probs: [2×15 double]
This example shows the workflow to price an Barrier instrument when you use a BlackScholes model and an AssetTree pricing method using a Standard Trinomial (STT) tree.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create AssetTree Pricer Object
Use finpricer to create an AssetTree pricer object with a Standard Trinomial (STT) equity tree and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
NumPeriods = 15; STTPricer = finpricer("AssetTree",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',1000,'PricingMethod',"StandardTrinomial",'Maturity',datetime(2019,1,1),'NumPeriods',NumPeriods)
STTPricer =
STTree with properties:
Tree: [1×1 struct]
NumPeriods: 15
Model: [1×1 finmodel.BlackScholes]
DiscountCurve: [1×1 ratecurve]
SpotPrice: 1000
DividendType: "continuous"
DividendValue: 0
TreeDates: [25-Jan-2018 08:00:00 18-Feb-2018 16:00:00 15-Mar-2018 00:00:00 08-Apr-2018 08:00:00 02-May-2018 16:00:00 27-May-2018 00:00:00 20-Jun-2018 08:00:00 14-Jul-2018 16:00:00 … ] (1×15 datetime)
STTPricer.Tree
ans = struct with fields:
ATree: {1×16 cell}
Probs: {[3×1 double] [3×3 double] [3×5 double] [3×7 double] [3×9 double] [3×11 double] [3×13 double] [3×15 double] [3×17 double] [3×19 double] [3×21 double] [3×23 double] [3×25 double] [3×27 double] [3×29 double]}
dObs: [01-Jan-2018 00:00:00 25-Jan-2018 08:00:00 18-Feb-2018 16:00:00 15-Mar-2018 00:00:00 08-Apr-2018 08:00:00 02-May-2018 16:00:00 27-May-2018 00:00:00 20-Jun-2018 08:00:00 14-Jul-2018 16:00:00 … ] (1×16 datetime)
tObs: [0 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1]
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(STTPricer,BarrierOpt,["all"])Price = 956.5444
outPR =
priceresult with properties:
Results: [1×7 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×7 table
Price Delta Gamma Vega Lambda Rho Theta
______ _____ ___________ ________ ______ ______ ______
956.54 1 -1.9331e-17 -0.20023 1.0454 44.112 -1.514
outPR.PricerData.PriceTree
ans = struct with fields:
PTree: {1×16 cell}
ExTree: {1×16 cell}
tObs: [0 0.0667 0.1333 0.2000 0.2667 0.3333 0.4000 0.4667 0.5333 0.6000 0.6667 0.7333 0.8000 0.8667 0.9333 1]
dObs: [01-Jan-2018 25-Jan-2018 18-Feb-2018 15-Mar-2018 08-Apr-2018 02-May-2018 27-May-2018 20-Jun-2018 14-Jul-2018 08-Aug-2018 01-Sep-2018 25-Sep-2018 20-Oct-2018 13-Nov-2018 07-Dec-2018 01-Jan-2019]
Probs: {[3×1 double] [3×3 double] [3×5 double] [3×7 double] [3×9 double] [3×11 double] [3×13 double] [3×15 double] [3×17 double] [3×19 double] [3×21 double] [3×23 double] [3×25 double] [3×27 double] [3×29 double]}
This example shows the workflow to price an Barrier instrument when you use a BlackScholes model and a AssetMonteCarlo pricing method.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create AssetMonteCarlo Pricer Object
Use finpricer to create an AssetMonteCarlo pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
outPricer = finpricer("AssetMonteCarlo",'DiscountCurve',myRC,"Model",BlackScholesModel,'SpotPrice',200,'simulationDates',datetime(2019,1,1))
outPricer =
GBMMonteCarlo with properties:
DiscountCurve: [1×1 ratecurve]
SpotPrice: 200
SimulationDates: 01-Jan-2019
NumTrials: 1000
RandomNumbers: []
Model: [1×1 finmodel.BlackScholes]
DividendType: "continuous"
DividendValue: 0
MonteCarloMethod: "standard"
BrownianMotionMethod: "standard"
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(outPricer,BarrierOpt,["all"])Price = 156.6270
outPR =
priceresult with properties:
Results: [1×7 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×7 table
Price Delta Gamma Lambda Rho Theta Vega
______ ______ ___________ ______ _____ _____ _______
156.63 1.0004 -7.6028e-12 1.2774 43.45 0 0.67904
This example shows the workflow to price an Barrier instrument when you use a BlackScholes model and a AssetMonteCarlo pricing method with quasi-Monte Carlo simulation.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create BlackScholes Model Object
Use finmodel to create a BlackScholes model object.
BlackScholesModel = finmodel("BlackScholes",'Volatility',0.30)
BlackScholesModel =
BlackScholes with properties:
Volatility: 0.3000
Correlation: 1
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create AssetMonteCarlo Pricer Object
Use finpricer to create an AssetMonteCarlo pricer object and use the ratecurve object for the 'DiscountCurve' name-value argument and use the name-value arguments for MonteCarloMethod and BrownianMotionMethod.
outPricer = finpricer("AssetMonteCarlo",'DiscountCurve',myRC,"Model",BlackScholesModel,'SpotPrice',200,'simulationDates',datetime(2019,1,1),'NumTrials',1e3, ... 'MonteCarloMethod',"quasi",'BrownianMotionMethod',"brownian-bridge")
outPricer =
GBMMonteCarlo with properties:
DiscountCurve: [1×1 ratecurve]
SpotPrice: 200
SimulationDates: 01-Jan-2019
NumTrials: 1000
RandomNumbers: []
Model: [1×1 finmodel.BlackScholes]
DividendType: "continuous"
DividendValue: 0
MonteCarloMethod: "quasi"
BrownianMotionMethod: "brownian-bridge"
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(outPricer,BarrierOpt,["all"])Price = 156.2006
outPR =
priceresult with properties:
Results: [1×7 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×7 table
Price Delta Gamma Lambda Rho Theta Vega
_____ _______ ___________ ______ _____ _____ _______
156.2 0.99826 -4.7606e-13 1.2782 43.45 0 -1.5624
This example shows the workflow to price an Barrier instrument when you use a Heston model and an AssetMonteCarlo pricing method.
Create Barrier Instrument Object
Use fininstrument to create an Barrier instrument object.
BarrierOpt = fininstrument("Barrier",'Strike',45,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt =
Barrier with properties:
OptionType: "call"
Strike: 45
BarrierType: "do"
BarrierValue: 40
Rebate: 0
ExerciseStyle: "american"
ExerciseDate: 01-Jan-2019
Name: "barrier_option"
Create Heston Model Object
Use finmodel to create a Heston model object.
HestonModel = finmodel("Heston",'V0',0.032,'ThetaV',0.1,'Kappa',0.003,'SigmaV',0.2,'RhoSV',0.9)
HestonModel =
Heston with properties:
V0: 0.0320
ThetaV: 0.1000
Kappa: 0.0030
SigmaV: 0.2000
RhoSV: 0.9000
Create ratecurve Object
Create a flat ratecurve object using ratecurve.
Settle = datetime(2018,1,1); Maturity = datetime(2023,1,1); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)
myRC =
ratecurve with properties:
Type: "zero"
Compounding: -1
Basis: 1
Dates: 01-Jan-2023
Rates: 0.0350
Settle: 01-Jan-2018
InterpMethod: "linear"
ShortExtrapMethod: "next"
LongExtrapMethod: "previous"
Create AssetMonteCarlo Pricer Object
Use finpricer to create an AssetMonteCarlo pricer object and use the ratecurve object for the 'DiscountCurve' name-value pair argument.
outPricer = finpricer("AssetMonteCarlo",'DiscountCurve',myRC,"Model",HestonModel,'SpotPrice',200,'simulationDates',datetime(2019,1,1))
outPricer =
HestonMonteCarlo with properties:
DiscountCurve: [1×1 ratecurve]
SpotPrice: 200
SimulationDates: 01-Jan-2019
NumTrials: 1000
RandomNumbers: []
Model: [1×1 finmodel.Heston]
DividendType: "continuous"
DividendValue: 0
MonteCarloMethod: "standard"
BrownianMotionMethod: "standard"
Price Barrier Instrument
Use price to compute the price and sensitivities for the Barrier instrument.
[Price, outPR] = price(outPricer,BarrierOpt,["all"])Price = 156.9962
outPR =
priceresult with properties:
Results: [1×8 table]
PricerData: [1×1 struct]
outPR.Results
ans=1×8 table
Price Delta Gamma Lambda Rho Theta Vega VegaLT
_____ ______ _________ ______ _____ _____ ______ _________
157 1.0022 -1.08e-12 1.2768 43.45 0 2.7882 0.0013677
More About
A barrier option has not only a strike price but also a barrier level and sometimes a rebate.
A barrier option has a predetermined barrier level that is set at a specific price above or below the current price of the underlying asset. The barrier can be either "up and in" or "down and in" for knock-in options, meaning the option becomes active if the price reaches or exceeds the barrier level. Conversely, it can be "up and out" or "down and out" for knock-out options, meaning the option becomes null and void if the price reaches or exceeds the barrier level.
The payoff for this type of option depends on whether the underlying asset crosses
the predetermined trigger value (barrier level), indicated by
BarrierValue, during the life of the option. If the option
cannot be exercised because the barrier level either has or has not been reached, a
fixed rebate amount is paid. For more information, see Barrier Option.
Version History
Introduced in R2020aAlthough Barrier 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
Functions
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.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)