# Vanilla

`Vanilla` instrument object

## Description

Create and price a `Vanilla` instrument object using this workflow:

1. Use `fininstrument` to create a `Vanilla` instrument object.

2. Use `finmodel` to specify a `BlackScholes`, `Bachelier`, `Heston`, `Bates`, `Merton`, or `Dupire` model for the `Vanilla` instrument.

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 `Vanilla` instrument, see Choose Instruments, Models, and Pricers.

## Creation

### Syntax

``VanillaObj = fininstrument(InstrumentType,'Strike',strike_value,'ExerciseDate',exercise_date)``
``VanillaObj = fininstrument(___,Name,Value)``

### Description

example

````VanillaObj = fininstrument(InstrumentType,'Strike',strike_value,'ExerciseDate',exercise_date)` creates a `Vanilla` object by specifying `InstrumentType` and sets the properties for the required name-value pair arguments `Strike` and `ExerciseDate`. For more information on a `Vanilla` instrument, see More About.```

example

````VanillaObj = fininstrument(___,Name,Value)` sets optional properties using additional name-value pairs in addition to the required arguments in the previous syntax. For example, ```VanillaObj = fininstrument("Vanilla",'Strike',100,'ExerciseDate',datetime(2019,1,30),'OptionType',"put",'ExerciseStyle',"American",'Name',"vanilla_instrument")``` creates a `Vanilla` put option with an American exercise. You can specify multiple name-value pair arguments.```

### Input Arguments

expand all

Instrument type, specified as a string with the value of `"Vanilla"` or a character vector with the value of `'Vanilla'`.

Data Types: `char` | `string`

`Vanilla` Name-Value Pair Arguments

Specify required and 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: ```VanillaObj = fininstrument("Vanilla",'Strike',100,'ExerciseDate',datetime(2019,1,30),'OptionType',"put",'ExerciseStyle',"American",'Name',"vanilla_instrument")```
Required `Vanilla` Name-Value Pair Arguments

expand all

Option strike price value, specified as the comma-separated pair consisting of `'Strike'` and a scalar nonnegative numeric value.

Note

When using a `"Bermudan"` `ExerciseStyle` with a `FiniteDifference` pricer, the `Strike` is a vector.

Data Types: `double`

Option exercise date, specified as the comma-separated pair consisting of `'ExerciseDate'` and a scalar datetime, serial date number, date character vector, or date string.

Note

For a European option, there is only one `ExerciseDate` on the option expiry date.

When using a `"Bermudan"` `ExerciseStyle` with a `FiniteDifference` pricer, the `ExerciseDate` is a vector.

If you use a date character vector or date string, the format must be recognizable by `datetime` because the `ExerciseDate` property is stored as a datetime.

Data Types: `double` | `char` | `string` | `datetime`

Optional `Vanilla` Name-Value Pair Arguments

expand all

Option type, specified as the comma-separated pair consisting of `'OptionType'` and a scalar string or character vector.

Note

When you use a `RollGeskeWhaley` pricer with a `Vanilla` option, `OptionType` must be `'call'`.

Data Types: `char` | `string`

Option exercise style, specified as the comma-separated pair consisting of `'ExerciseStyle'` and a scalar string or character vector.

Note

For more information on `ExerciseStyle`, see Supported Exercise Styles.

Data Types: `string` | `char`

User-defined name for the instrument, specified as the comma-separated pair consisting of `'Name'` and a scalar string or character vector.

Data Types: `char` | `string`

## Properties

expand all

Option strike price value, returned as a scalar nonnegative numeric value.

Data Types: `double`

Option exercise date, returned as a datetime.

Data Types: `datetime`

Option type, returned as a string with a value of `"call"` or `"put"`.

Data Types: `string`

Option exercise style, returned as a string with a value of `"European"`, `"American"`, or `"Bermudan"`.

Data Types: `string`

User-defined name for the instrument, returned as a string.

Data Types: `string`

## Object Functions

 `setExercisePolicy` Set exercise policy for `FixedBondOption`, `FloatBondOption`, or `Vanilla` instrument

## Examples

collapse all

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

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2018,5,1),'Strike',29,'OptionType',"put",'ExerciseStyle',"european",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "put" ExerciseStyle: "european" ExerciseDate: 01-May-2018 Strike: 29 Name: "vanilla_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

`BlackScholesModel = finmodel("BlackScholes",'Volatility',0.25)`
```BlackScholesModel = BlackScholes with properties: Volatility: 0.2500 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,1,1); Maturity = datetime(2019,1,1); Rate = 0.05; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 1 Dates: 01-Jan-2019 Rates: 0.0500 Settle: 01-Jan-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `BlackScholes` Pricer Object

Use `finpricer` to create a `BlackScholes` pricer object and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument.

`outPricer = finpricer("analytic",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',30,'DividendValue',0.045)`
```outPricer = BlackScholes with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.BlackScholes] SpotPrice: 30 DividendValue: 0.0450 DividendType: "continuous" ```

Price `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 1.2046 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Lambda Vega Rho Theta ______ ________ ________ _______ ______ _______ _______ 1.2046 -0.36943 0.086269 -9.3396 6.4702 -4.0959 -2.3107 ```

This example shows the workflow to price a `Vanilla` instrument when you use a `BlackScholes` model and an `AssetTree` pricing method.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2018,5,1),'Strike',29,'OptionType',"put",'ExerciseStyle',"european",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "put" ExerciseStyle: "european" ExerciseDate: 01-May-2018 Strike: 29 Name: "vanilla_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

`BlackScholesModel = finmodel("BlackScholes",'Volatility',0.25)`
```BlackScholesModel = BlackScholes with properties: Volatility: 0.2500 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,1,1); Maturity = datetime(2019,1,1); Rate = 0.05; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',1)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 1 Dates: 01-Jan-2019 Rates: 0.0500 Settle: 01-Jan-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `AssetTree` Pricer Object

Use `finpricer` to create an `AssetTree` pricer object for a LR equity tree and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument.

```NumPeriods = 15; LRPricer = finpricer("AssetTree",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',50,'PricingMethod',"LeisenReimer",'Maturity',datetime(2018,5,1),'NumPeriods',NumPeriods)```
```LRPricer = LRTree with properties: InversionMethod: PP1 Strike: 50 Tree: [1x1 struct] NumPeriods: 15 Model: [1x1 finmodel.BlackScholes] DiscountCurve: [1x1 ratecurve] SpotPrice: 50 DividendType: "continuous" DividendValue: 0 TreeDates: [1x15 datetime] ```
`LRPricer.Tree`
```ans = struct with fields: Probs: [2x15 double] ATree: {1x16 cell} dObs: [1x16 datetime] tObs: [1x16 double] ```

Price `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(LRPricer,VanillaOpt,["all"])`
```Price = 3.5022e-06 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Vega Lambda Rho Theta __________ ___________ __________ _________ _______ ___________ ___________ 3.5022e-06 -1.9331e-06 1.1068e-06 0.0016243 -30.496 -3.6747e-05 -0.00060106 ```
`outPR.PricerData.PriceTree`
```ans = struct with fields: PTree: {1x16 cell} ExTree: {1x16 cell} tObs: [1x16 double] dObs: [1x16 datetime] Probs: [2x15 double] ```
`outPR.PricerData.PriceTree.ExTree`
```ans=1×16 cell array Columns 1 through 5 {[0]} {[0 0]} {[0 0 0]} {[0 0 0 0]} {[0 0 0 0 0]} Columns 6 through 8 {[0 0 0 0 0 0]} {[0 0 0 0 0 0 0]} {[0 0 0 0 0 0 0 0]} Columns 9 through 11 {[0 0 0 0 0 0 0 0 0]} {[0 0 0 0 0 0 0 0 0 0]} {1x11 logical} Columns 12 through 15 {1x12 logical} {1x13 logical} {1x14 logical} {1x15 logical} Column 16 {1x16 logical} ```

This example shows the workflow to price an American option for a `Vanilla` instrument when you use a `BlackScholes` model and a `RollGeskeWhaley` pricing method.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'Strike',105,'ExerciseDate',datetime(2022,9,15),'OptionType',"call",'ExerciseStyle',"american",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "call" ExerciseStyle: "american" ExerciseDate: 15-Sep-2022 Strike: 105 Name: "vanilla_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

`BlackScholesModel = finmodel("BlackScholes","Volatility",0.2)`
```BlackScholesModel = BlackScholes with properties: Volatility: 0.2000 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); Maturity = datetime(2023,9,15); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 12 Dates: 15-Sep-2023 Rates: 0.0350 Settle: 15-Sep-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `RollGeskeWhaley` Pricer Object

Use `finpricer` to create a `RollGeskeWhaley` pricer object and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument.

`outPricer = finpricer("analytic",'Model',BlackScholesModel,'DiscountCurve',myRC,'SpotPrice',100,'DividendValue',timetable(datetime(2021,6,15),0.25),'PricingMethod',"RollGeskeWhaley")`
```outPricer = RollGeskeWhaley with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.BlackScholes] SpotPrice: 100 DividendValue: [1x1 timetable] DividendType: "cash" ```

Price `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 19.9066 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Lambda Vega Theta Rho ______ _______ _________ ______ ______ _______ ______ 19.907 0.66568 0.0090971 3.344 72.804 -3.4537 186.68 ```

This example shows the workflow to price a `Vanilla` instrument for foreign exchange (FX) when you use a `BlackScholes` model and a `BlackScholes` pricing method. Assume that the current exchange rate is \$0.52 and has a volatility of 12% per annum. The annualized continuously compounded foreign risk-free rate is 8% per annum.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2022,9,15),'Strike',.50,'OptionType',"put",'ExerciseStyle',"european",'Name',"vanilla_fx_option")`
```VanillaOpt = Vanilla with properties: OptionType: "put" ExerciseStyle: "european" ExerciseDate: 15-Sep-2022 Strike: 0.5000 Name: "vanilla_fx_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

```Sigma = .12; BlackScholesModel = finmodel("BlackScholes","Volatility",Sigma)```
```BlackScholesModel = BlackScholes with properties: Volatility: 0.1200 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); Maturity = datetime(2023,9,15); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 12 Dates: 15-Sep-2023 Rates: 0.0350 Settle: 15-Sep-2018 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous" ```

Create `BlackScholes` Pricer Object

Use `finpricer` to create a `BlackScholes` pricer object and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument. When pricing currencies using a `Vanilla` instrument, the `DividendType` must be `'continuous'` and `DividendValue` is the annualized risk-free interest rate in the foreign country.

```ForeignRate = 0.08; outPricer = finpricer("analytic",'DiscountCurve',myRC,'Model',BlackScholesModel,'SpotPrice',.52,'DividendType',"continuous",'DividendValue',ForeignRate)```
```outPricer = BlackScholes with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.BlackScholes] SpotPrice: 0.5200 DividendValue: 0.0800 DividendType: "continuous" ```

Price `Vanilla` FX Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` FX instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 0.0738 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Lambda Vega Rho Theta ________ ________ ______ _______ _______ _______ _________ 0.073778 -0.49349 2.0818 -4.7899 0.27021 -1.3216 -0.013019 ```

This example shows the workflow to price an American option for a `Vanilla` instrument when you use a `BlackScholes` model and an `AssetMonteCarlo` pricing method.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'Strike',105,'ExerciseDate',datetime(2022,9,15),'OptionType',"call",'ExerciseStyle',"american",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "call" ExerciseStyle: "american" ExerciseDate: 15-Sep-2022 Strike: 105 Name: "vanilla_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

`BlackScholesModel = finmodel("BlackScholes","Volatility",0.2)`
```BlackScholesModel = BlackScholes with properties: Volatility: 0.2000 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); Maturity = datetime(2023,9,15); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 12 Dates: 15-Sep-2023 Rates: 0.0350 Settle: 15-Sep-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',150,'simulationDates',datetime(2022,9,15))`
```outPricer = GBMMonteCarlo with properties: DiscountCurve: [1x1 ratecurve] SpotPrice: 150 SimulationDates: 15-Sep-2022 NumTrials: 1000 RandomNumbers: [] Model: [1x1 finmodel.BlackScholes] DividendType: "continuous" DividendValue: 0 ```

Price `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 61.2010 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Lambda Rho Theta Vega ______ _______ _________ ______ ______ _______ ______ 61.201 0.93074 0.0027813 2.2812 313.95 -3.7909 41.626 ```

This example shows the workflow to price an American option for a `Vanilla` instrument when you use a `Heston` model and an `AssetMonteCarlo` pricing method.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'Strike',105,'ExerciseDate',datetime(2022,9,15),'OptionType',"call",'ExerciseStyle',"american",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "call" ExerciseStyle: "american" ExerciseDate: 15-Sep-2022 Strike: 105 Name: "vanilla_option" ```

Create `Heston` Model Object

Use `finmodel` to create a `Heston` model object.

`HestonModel = finmodel("Heston",'V0',0.032,'ThetaV',0.07,'Kappa',0.003,'SigmaV',0.02,'RhoSV',0.09)`
```HestonModel = Heston with properties: V0: 0.0320 ThetaV: 0.0700 Kappa: 0.0030 SigmaV: 0.0200 RhoSV: 0.0900 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); Maturity = datetime(2023,9,15); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 12 Dates: 15-Sep-2023 Rates: 0.0350 Settle: 15-Sep-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',150,'simulationDates',datetime(2022,9,15))`
```outPricer = HestonMonteCarlo with properties: DiscountCurve: [1x1 ratecurve] SpotPrice: 150 SimulationDates: 15-Sep-2022 NumTrials: 1000 RandomNumbers: [] Model: [1x1 finmodel.Heston] DividendType: "continuous" DividendValue: 0 ```

Price `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 60.5637 ```
```outPR = priceresult with properties: Results: [1x8 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×8 table Price Delta Gamma Lambda Rho Theta Vega VegaLT ______ _______ _________ ______ ______ _______ ______ _______ 60.564 0.94774 0.0011954 2.3473 326.36 -3.7126 35.272 0.31155 ```

This example shows the workflow to price a Bermudan option for a `Vanilla` instrument when you use a `BlackScholes` model and a `FiniteDifference` pricing method.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

`VanillaOpt = fininstrument("Vanilla",'Strike',[110,120],'ExerciseDate',[datetime(2022,9,15) ; datetime(2023,9,15)],'OptionType',"call",'ExerciseStyle',"Bermudan",'Name',"vanilla_option")`
```VanillaOpt = Vanilla with properties: OptionType: "call" ExerciseStyle: "bermudan" ExerciseDate: [15-Sep-2022 15-Sep-2023] Strike: [110 120] Name: "vanilla_option" ```

Create `BlackScholes` Model Object

Use `finmodel` to create a `BlackScholes` model object.

`BlackScholesModel = finmodel("BlackScholes","Volatility",0.2)`
```BlackScholesModel = BlackScholes with properties: Volatility: 0.2000 Correlation: 1 ```

Create `ratecurve` Object

Create a flat `ratecurve` object using `ratecurve`.

```Settle = datetime(2018,9,15); Maturity = datetime(2023,9,15); Rate = 0.035; myRC = ratecurve('zero',Settle,Maturity,Rate,'Basis',12)```
```myRC = ratecurve with properties: Type: "zero" Compounding: -1 Basis: 12 Dates: 15-Sep-2023 Rates: 0.0350 Settle: 15-Sep-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 `Vanilla` Instrument

Use `price` to compute the price and sensitivities for the `Vanilla` instrument.

`[Price, outPR] = price(outPricer,VanillaOpt,["all"])`
```Price = 18.6797 ```
```outPR = priceresult with properties: Results: [1x7 table] PricerData: [1x1 struct] ```
`outPR.Results`
```ans=1×7 table Price Delta Gamma Lambda Theta Rho Vega _____ _______ _________ ______ _______ ______ ______ 18.68 0.62163 0.0091406 3.3278 -3.3154 184.31 83.162 ```

This example shows the workflow to price a `Vanilla` instrument when you use a `Heston` model and various pricing methods.

Create `Vanilla` Instrument Object

Use `fininstrument` to create a `Vanilla` instrument object.

```Settle = datetime(2017,6,29); Maturity = datemnth(Settle,6); Strike = 80; VanillaOpt = fininstrument('Vanilla','ExerciseDate',Maturity,'Strike',Strike,'Name',"vanilla_option")```
```VanillaOpt = Vanilla with properties: OptionType: "call" ExerciseStyle: "european" ExerciseDate: 29-Dec-2017 Strike: 80 Name: "vanilla_option" ```

Create `Heston` Model Object

Use `finmodel` to create a `Heston` model object.

```V0 = 0.04; ThetaV = 0.05; Kappa = 1.0; SigmaV = 0.2; RhoSV = -0.7; HestonModel = finmodel("Heston",'V0',V0,'ThetaV',ThetaV,'Kappa',Kappa,'SigmaV',SigmaV,'RhoSV',RhoSV)```
```HestonModel = Heston with properties: V0: 0.0400 ThetaV: 0.0500 Kappa: 1 SigmaV: 0.2000 RhoSV: -0.7000 ```

Create `ratecurve` object

Create a `ratecurve` object using `ratecurve`.

```Rate = 0.03; ZeroCurve = ratecurve('zero',Settle,Maturity,Rate);```

Create `NumericalIntegration`, `FFT`, and `FiniteDifference` Pricer Objects

Use `finpricer` to create a `NumericalIntegration`, `FFT`, and `FiniteDifference` pricer objects and use the `ratecurve` object for the `'DiscountCurve'` name-value pair argument.

```SpotPrice = 80; Strike = 80; DividendYield = 0.02; NIPricer = finpricer("NumericalIntegration",'Model', HestonModel,'SpotPrice',SpotPrice,'DiscountCurve',ZeroCurve,'DividendValue',DividendYield)```
```NIPricer = NumericalIntegration with properties: Model: [1x1 finmodel.Heston] DiscountCurve: [1x1 ratecurve] SpotPrice: 80 DividendType: "continuous" DividendValue: 0.0200 AbsTol: 1.0000e-10 RelTol: 1.0000e-10 IntegrationRange: [1.0000e-09 Inf] CharacteristicFcn: @characteristicFcnHeston Framework: "heston1993" VolRiskPremium: 0 LittleTrap: 1 ```
```FFTPricer = finpricer("FFT",'Model',HestonModel, ... 'SpotPrice',SpotPrice,'DiscountCurve',ZeroCurve, ... 'DividendValue',DividendYield,'NumFFT',8192)```
```FFTPricer = FFT with properties: Model: [1x1 finmodel.Heston] DiscountCurve: [1x1 ratecurve] SpotPrice: 80 DividendType: "continuous" DividendValue: 0.0200 NumFFT: 8192 CharacteristicFcnStep: 0.0100 LogStrikeStep: 0.0767 CharacteristicFcn: @characteristicFcnHeston DampingFactor: 1.5000 Quadrature: "simpson" VolRiskPremium: 0 LittleTrap: 1 ```
`FDPricer = finpricer("FiniteDifference",'Model',HestonModel,'SpotPrice',SpotPrice,'DiscountCurve',ZeroCurve,'DividendValue',DividendYield)`
```FDPricer = FiniteDifference with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.Heston] SpotPrice: 80 GridProperties: [1x1 struct] DividendType: "continuous" DividendValue: 0.0200 ```

Price `Vanilla` Instrument

Use the following sensitivities when pricing the `Vanilla` instrument.

`InpSensitivity = ["delta", "gamma", "theta", "rho", "vega", "vegalt"];`

Use `price` to compute the price and sensitivities for the `Vanilla` instrument that uses the `NumericalIntegration` pricer.

`[PriceNI, outPR_NI] = price(NIPricer,VanillaOpt,InpSensitivity)`
```PriceNI = 4.7007 ```
```outPR_NI = priceresult with properties: Results: [1x7 table] PricerData: [] ```

Use `price` to compute the price and sensitivities for the `Vanilla` instrument that uses the `FFT` pricer.

`[PriceFFT, outPR_FFT] = price(FFTPricer,VanillaOpt,InpSensitivity)`
```PriceFFT = 4.7007 ```
```outPR_FFT = priceresult with properties: Results: [1x7 table] PricerData: [] ```

Use `price` to compute the price and sensitivities for the `Vanilla` instrument that uses the `FiniteDifference` pricer.

`[PriceFD, outPR_FD] = price(FDPricer,VanillaOpt,InpSensitivity)`
```PriceFD = 4.7003 ```
```outPR_FD = priceresult with properties: Results: [1x7 table] PricerData: [1x1 struct] ```

Aggregate the price results.

`[outPR_NI.Results;outPR_FFT.Results;outPR_FD.Results]`
```ans=3×7 table Price Delta Gamma Theta Rho Vega VegaLT ______ _______ ________ _______ ______ ______ ______ 4.7007 0.57747 0.03392 -4.8474 20.805 17.028 5.2394 4.7007 0.57747 0.03392 -4.8474 20.805 17.028 5.2394 4.7003 0.57722 0.035254 -4.8483 20.801 17.046 5.2422 ```

Compute Option Price Surfaces

Use the `price` function for the `NumericalIntegration` pricer and the `price` function for the `FFT` pricer to compute the prices for a range of `Vanilla` instruments.

```Maturities = datemnth(Settle,(3:3:24)'); NumMaturities = length(Maturities); Strikes = (20:10:160)'; NumStrikes = length(Strikes); [Maturities_Full,Strikes_Full] = meshgrid(Maturities,Strikes); NumInst = numel(Strikes_Full); VanillaOptions(NumInst, 1) = fininstrument("vanilla",... "ExerciseDate", Maturities_Full(1), "Strike", Strikes_Full(1)); for instidx=1:NumInst VanillaOptions(instidx) = fininstrument("vanilla",... "ExerciseDate", Maturities_Full(instidx), "Strike", Strikes_Full(instidx)); end Prices_NI = price(NIPricer, VanillaOptions); Prices_FFT = price(FFTPricer, VanillaOptions); figure; surf(Maturities_Full,Strikes_Full,reshape(Prices_NI,[NumStrikes,NumMaturities])); title('Price (Numerical Integration)'); view(-112,34); xlabel('Maturity') ylabel('Strike')```

```figure; surf(Maturities_Full,Strikes_Full,reshape(Prices_FFT,[NumStrikes,NumMaturities])); title('Price (FFT)'); view(-112,34); xlabel('Maturity') ylabel('Strike')```

expand all

## Tips

After creating a `Vanilla` instrument object, you can use `setExercisePolicy` to change the size of the options. For example, if you have the following instrument:

`VanillaOpt = fininstrument("Vanilla",'ExerciseDate',datetime(2021,5,1),'Strike',29,'OptionType',"put",'ExerciseStyle',"European")`
To modify the `Vanilla` instrument's size by changing the `ExerciseStyle` from `"European"` to `"American"`, use `setExercisePolicy`:
`VanillaOpt = setExercisePolicy(VanillaOpt,[datetime(2021,1,1) datetime(2022,1,1)],100,'American')`

Introduced in R2020a