Main Content

Barrier

Barrier instrument object

Since R2020a

Description

Create and price a Barrier instrument object for one or more Barrier instruments using this workflow:

  1. Use fininstrument to create a Barrier instrument object for one or more Barrier instruments.

  2. Use finmodel to specify a BlackScholes, Heston, Bates, or Merton model for the Barrier instrument object.

  3. Choose a pricing method.

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

Description

BarrierOpt = fininstrument(InstrumentType,'Strike',strike_value,'ExerciseDate',exercise_date,'BarrierValue',barrier_value) creates a 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.

example

BarrierOpt = fininstrument(___,Name,Value) sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, 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.

example

Input Arguments

expand all

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

expand all

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

expand all

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-in

    This 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-out

    This 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-in

    This 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 Barrier instrument using the FiniteDifference pricer does not support American knock-in barrier options.

  • "DO" — Down knock-up

    This 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.

OptionBarrier TypePayoff If Barrier CrossedPayoff If Barrier Not Crossed
Call or PutDown knock-outWorthlessStandard Call or Put
Call or PutDown knock-inCall or PutWorthless
Call or PutUp knock-outWorthlessStandard Call or Put
Call or PutUp knock-inStandard Call or PutWorthless

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 Rebate is paid at expiry.

  • For knock-out options, the Rebate is paid when BarrierValue is 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

Properties

expand all

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

collapse all

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: [1x1 ratecurve]
             Model: [1x1 finmodel.BlackScholes]
         SpotPrice: 50
    GridProperties: [1x1 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: [1x7 table]
    PricerData: [1x1 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: [1x1 ratecurve]
             Model: [1x1 finmodel.BlackScholes]
         SpotPrice: 50
    GridProperties: [1x1 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: [1x1 struct]
       NumPeriods: 15
            Model: [1x1 finmodel.BlackScholes]
    DiscountCurve: [1x1 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    ...    ] (1x15 datetime)

EQPPricer.Tree
ans = struct with fields:
    Probs: [2x15 double]
    ATree: {1x16 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    ...    ] (1x16 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: [1x7 table]
    PricerData: [1x1 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: {1x16 cell}
    ExTree: {1x16 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: [2x15 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: [1x1 struct]
       NumPeriods: 15
            Model: [1x1 finmodel.BlackScholes]
    DiscountCurve: [1x1 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    ...    ] (1x15 datetime)

STTPricer.Tree
ans = struct with fields:
    ATree: {1x16 cell}
    Probs: {[3x1 double]  [3x3 double]  [3x5 double]  [3x7 double]  [3x9 double]  [3x11 double]  [3x13 double]  [3x15 double]  [3x17 double]  [3x19 double]  [3x21 double]  [3x23 double]  [3x25 double]  [3x27 double]  [3x29 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    ...    ] (1x16 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: [1x7 table]
    PricerData: [1x1 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: {1x16 cell}
    ExTree: {1x16 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: {[3x1 double]  [3x3 double]  [3x5 double]  [3x7 double]  [3x9 double]  [3x11 double]  [3x13 double]  [3x15 double]  [3x17 double]  [3x19 double]  [3x21 double]  [3x23 double]  [3x25 double]  [3x27 double]  [3x29 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: [1x1 ratecurve]
               SpotPrice: 200
         SimulationDates: 01-Jan-2019
               NumTrials: 1000
           RandomNumbers: []
                   Model: [1x1 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: [1x7 table]
    PricerData: [1x1 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: [1x1 ratecurve]
               SpotPrice: 200
         SimulationDates: 01-Jan-2019
               NumTrials: 1000
           RandomNumbers: []
                   Model: [1x1 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: [1x7 table]
    PricerData: [1x1 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: [1x1 ratecurve]
               SpotPrice: 200
         SimulationDates: 01-Jan-2019
               NumTrials: 1000
           RandomNumbers: []
                   Model: [1x1 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: [1x8 table]
    PricerData: [1x1 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

expand all

Version History

Introduced in R2020a

expand all