Main Content

FiniteDifference

Create FiniteDifference pricer object for Barrier, DoubleBarrier, or Vanilla instrument using a BlackScholes, Heston, Merton, or Bates model

Since R2020a

Description

Create and price a Vanilla, Barrier, or DoubleBarrier instrument object with a BlackScholes, Heston, Bates, Merton, or Dupire model and a FiniteDifference pricing method using this workflow:

  1. Use fininstrument to create the Barrier, DoubleBarrier, or Vanilla instrument object.

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

  3. Use finpricer to specify the FiniteDifference pricer object for the Barrier, DoubleBarrier, or Vanilla instrument object.

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 pricing methods for a Vanilla, Barrier, or DoubleBarrier instrument, see Choose Instruments, Models, and Pricers.

Creation

Description

example

FiniteDifferencePricerObj = finpricer(PricerType,'Model',model,'DiscountCurve',ratecurve_obj,'SpotPrice',spotprice_value) creates a FiniteDifference pricer object by specifying PricerType and sets the properties for the required name-value pair arguments Model, DiscountCurve, and SpotPrice.

example

FiniteDifferencePricerObj = finpricer(___,Name,Value) sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, FiniteDifferencePricerObj = finpricer("FiniteDifference",'Model',BSModel,'DiscountCurve',ratecurve_obj,'SpotPrice',100,'DividendValue',.025,'DividendType',"cash") creates a FiniteDifference pricer object. You can specify multiple name-value pair arguments.

Input Arguments

expand all

Pricer type, specified as a string with the value of "FiniteDifference" or the character vector with a value of 'FiniteDifference'.

Data Types: char | string

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: FiniteDifferencePricerObj = finpricer("FiniteDifference",'Model',BSModel,'DiscountCurve',ratecurve_obj,'SpotPrice',100,'DividendValue',.025,'DividendType',"cash")

Required FiniteDifference Name-Value Pair Arguments

expand all

Model object, specified as the comma-separated pair consisting of 'Model' and the name of the previously created Merton, Bates, or Heston model object using finmodel.

Data Types: object

This property is read-only.

ratecurve object for discounting cash flows, specified as the comma-separated pair consisting of 'DiscountCurve' and the name of the ratecurve object.

Note

Specify a flat ratecurve object for DiscountCurve. If you use a nonflat ratecurve object, the software uses the rate in the ratecurve object at Maturity and assumes that the value is constant for the life of the equity option.

Data Types: object

Current price of the underlying asset, specified as the comma-separated pair consisting of 'SpotPrice' and a scalar nonnegative numeric.

Data Types: double

Optional FiniteDifference Name-Value Pair Arguments

expand all

Dividend yield or dividend schedule, specified as the comma-separated pair consisting of 'DividendValue' and a scalar for a dividend yield or a timetable for a dividend schedule.

Data Types: double | timetable

Dividend type, specified as the comma-separated pair consisting of 'DividendType' and a character vector or string. DividendType must be "cash" for actual dollar dividends or "continuous" for a continuous dividend yield.

Note

When you use a Barrier instrument, you must set DividendType to "cash".

Data Types: char | string

Size of the spot grid for the finite difference grid, specified as the comma-separated pair consisting of 'SpotGridSize' and a scalar numeric.

Data Types: double

Maximum price for the price grid boundary, specified as the comma-separated pair consisting of 'SpotPriceMax' and a positive scalar.

Data Types: single | double

Number of nodes of the variance grid for the finite difference grid, specified as the comma-separated pair consisting of 'VarianceGridSize' and a scalar numeric.

Note

VarianceGridSize is supported only when you use a Heston or Bates model.

Data Types: double

Maximum variance for the variance grid boundary, specified as the comma-separated pair consisting of 'VarianceMax' as a scalar numeric.

Note

VarianceMax is supported only when you use a Heston or Bates model.

Data Types: double

Number of nodes of the time grid for the finite difference grid, specified as the comma-separated pair consisting of 'TimeGridSize' and a positive numeric scalar.

Data Types: double

Method of interpolation for estimating the implied volatility surface from ImpliedVolData for use only with a Dupire model, specified as the comma-separated pair consisting of 'InterpMethod' and a string or character vector with one of the following values:

  • 'linear' — Linear interpolation

  • 'makima' — Modified Akima cubic Hermite interpolation

  • 'spline' — Cubic spline interpolation

  • 'tpaps' — Thin-plate smoothing spline interpolation

Note

The 'tpaps' method uses the thin-plate smoothing spline functionality from Curve Fitting Toolbox™.

The 'makima' and 'spline' methods work only for gridded data. For scattered data, use the 'linear' or 'tpaps' methods.

For more information on gridded or scattered data and details on interpolation methods, see Gridded and Scattered Sample Data and Interpolating Gridded Data.

Data Types: char | string

Properties

expand all

Model, returned as a model object.

Data Types: object

This property is read-only.

ratecurve object for discounting cash flows, returned as the ratecurve object.

Data Types: object

Current price of the underlying asset, returned as a scalar nonnegative numeric.

Data Types: double

Dividend yield or dividend schedule, returned as a scalar for a dividend yield or a timetable for a dividend schedule.

Data Types: double | timetable

This property is read-only.

Dividend type, returned as a string. The DividendType is either "cash" for actual dollar dividends or "continuous" for a continuous dividend yield.

Data Types: string

Grid properties, returned as a struct.

For a Dupire model, GridProperties contains the following fields:

  • SpotGridSize — Size of the spot grid for the finite difference grid, returned as a scalar numeric.

  • SpotPriceMax — Maximum price for price grid boundary, returned as a positive scalar.

  • TimeGridSize — Number of nodes of the time grid for the finite difference grid, returned as a positive numeric scalar.

  • InterpMethod — Method of interpolation for estimating the implied volatility surface, returned as a string.

For a Heston or Bates model, GridProperties contains the following fields:

  • VarianceGridSize — Size of the variance grid for the finite difference grid, returned as a scalar numeric.

  • VarianceMax — Maximum variance for the variance grid boundary, returned as a scalar numeric.

Data Types: struct

Object Functions

priceCompute price for equity instrument with FiniteDifference pricer

Examples

collapse all

This example shows the workflow to price a Barrier instrument when you use a BlackScholes model and a FiniteDifference pricing method.

Create Barrier Instrument Object

Use fininstrument to create a Barrier instrument object.

BarrierOpt = fininstrument("Barrier",'Strike',105,'ExerciseDate',datetime(2019,1,1),'OptionType',"call",'ExerciseStyle',"american",'BarrierType',"DO",'BarrierValue',40,'Name',"barrier_option")
BarrierOpt = 
  Barrier with properties:

       OptionType: "call"
           Strike: 105
      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',100)
outPricer = 
  FiniteDifference with properties:

     DiscountCurve: [1x1 ratecurve]
             Model: [1x1 finmodel.BlackScholes]
         SpotPrice: 100
    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 = 11.3230
outPR = 
  priceresult with properties:

       Results: [1x7 table]
    PricerData: [1x1 struct]

outPR.Results
ans=1×7 table
    Price      Delta     Gamma     Lambda     Theta      Rho       Vega 
    ______    _______    ______    ______    _______    ______    ______

    11.323    0.54126    0.0132    4.7802    -7.4408    42.766    39.627

Version History

Introduced in R2020a