# optByLocalVolFD

Option price by local volatility model, using finite differences

## Syntax

``````[Price,PriceGrid,AssetPrices,Times] = optByLocalVolFD(Rate,AssetPrice,Settle,ExerciseDates,OptSpec,Strike,ImpliedVolData)``````
``````[Price,PriceGrid,AssetPrices,Times] = optByLocalVolFD(___,Name,Value)``````

## Description

example

``````[Price,PriceGrid,AssetPrices,Times] = optByLocalVolFD(Rate,AssetPrice,Settle,ExerciseDates,OptSpec,Strike,ImpliedVolData)``` compute a Vanilla European or American option price by the local volatility model, using the Crank-Nicolson method. ```

example

``````[Price,PriceGrid,AssetPrices,Times] = optByLocalVolFD(___,Name,Value)``` specifies options using one or more name-value pair arguments in addition to the input arguments in the previous syntax. ```

## Examples

collapse all

Define the option variables.

```AssetPrice = 590; Strike = 590; Rate = 0.06; DividendYield = 0.0262; Settle = '01-Jan-2018'; ExerciseDates = '01-Jan-2020';```

Define the implied volatility surface data.

```Maturity = ["06-Mar-2018" "05-Jun-2018" "12-Sep-2018" "10-Dec-2018" "01-Jan-2019" ... "02-Jul-2019" "01-Jan-2020" "01-Jan-2021" "01-Jan-2022" "01-Jan-2023"]; Maturity = repmat(Maturity,10,1); Maturity = Maturity(:); ExercisePrice = AssetPrice.*[0.85 0.90 0.95 1.00 1.05 1.10 1.15 1.20 1.30 1.40]; ExercisePrice = repmat(ExercisePrice,1,10)'; ImpliedVol = [... 0.190; 0.168; 0.133; 0.113; 0.102; 0.097; 0.120; 0.142; 0.169; 0.200; ... 0.177; 0.155; 0.138; 0.125; 0.109; 0.103; 0.100; 0.114; 0.130; 0.150; ... 0.172; 0.157; 0.144; 0.133; 0.118; 0.104; 0.100; 0.101; 0.108; 0.124; ... 0.171; 0.159; 0.149; 0.137; 0.127; 0.113; 0.106; 0.103; 0.100; 0.110; ... 0.171; 0.159; 0.150; 0.138; 0.128; 0.115; 0.107; 0.103; 0.099; 0.108; ... 0.169; 0.160; 0.151; 0.142; 0.133; 0.124; 0.119; 0.113; 0.107; 0.102; ... 0.169; 0.161; 0.153; 0.145; 0.137; 0.130; 0.126; 0.119; 0.115; 0.111; ... 0.168; 0.161; 0.155; 0.149; 0.143; 0.137; 0.133; 0.128; 0.124; 0.123; ... 0.168; 0.162; 0.157; 0.152; 0.148; 0.143; 0.139; 0.135; 0.130; 0.128; ... 0.168; 0.164; 0.159; 0.154; 0.151; 0.147; 0.144; 0.140; 0.136; 0.132]; ImpliedVolData = table(Maturity, ExercisePrice, ImpliedVol);```

Compute the European call option price.

```OptSpec = 'Call'; Price = optByLocalVolFD(Rate, AssetPrice, ... Settle, ExerciseDates, OptSpec, Strike, ImpliedVolData, 'DividendYield',DividendYield)```
```Price = 65.1319 ```

## Input Arguments

collapse all

Continuously compounded risk-free interest rate, specified by a scalar numeric.

Data Types: `double`

Current underlying asset price, specified as a scalar numeric.

Data Types: `double`

Settlement date, specified as a scalar serial date number, date character vector, datetime array, or string array.

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

Option exercise dates, specified as a serial date number, a date character vector, a datetime array, or a string array:

• For a European option, there is only one `ExerciseDates` value and this is the option expiry date.

• For an American option, use a `1`-by-`2` vector of serial date numbers, date character vectors, datetime arrays, or string arrays. The American option can be exercised on any date between or including the pair of dates. If only one non-`NaN` date is listed, the option can be exercised between `Settle` and the single listed date in `ExerciseDates`.

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

Definition of the option, specified as a character vector or string array with values `'call'` or `'put'`.

Data Types: `char` | `string`

Option strike price value, specified as a nonnegative scalar.

Data Types: `double`

Table of maturity dates, strike or exercise prices, and their corresponding implied volatilities,specified as a `NVOL`-by-`3` table.

Data Types: `table`

### Name-Value Arguments

Specify 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: ```Price = optByLocalVolFD(Rate,AssetPrice,Settle, ExerciseDates,OptSpec,Strike,ImpliedVolData,'AssetGridSize',1000)```

Day-count basis, specified as the comma-separated pair consisting of `'Basis'` and a scalar using one of the supported values:

• 0 = actual/actual

• 1 = 30/360 (SIA)

• 2 = actual/360

• 3 = actual/365

• 4 = 30/360 (PSA)

• 5 = 30/360 (ISDA)

• 6 = 30/360 (European)

• 7 = actual/365 (Japanese)

• 8 = actual/actual (ICMA)

• 9 = actual/360 (ICMA)

• 10 = actual/365 (ICMA)

• 11 = 30/360E (ICMA)

• 12 = actual/365 (ISDA)

• 13 = BUS/252

Data Types: `double`

Continuously compounded underlying asset yield, specified as the comma-separated pair consisting of `'DividendYield'` and a scalar numeric.

Note

If you enter a value for `DividendYield`, then set `DividendAmounts` and `ExDividendDates` = ```[ ]``` or do not enter them. If you enter values for `DividendAmounts` and `ExDividendDates`, then set `DividendYield` = `0`.

Data Types: `double`

Cash dividend amounts, specified as the comma-separated pair consisting of `'DividendAmounts'` and a `NDIV`-by-`1` vector.

For each dividend amount, there must be a corresponding `ExDividendDates` date. If you enter values for `DividendAmounts` and `ExDividendDates`, then set `DividendYield` = `0`.

Note

If you enter a value for `DividendYield`, then set `DividendAmounts` and `ExDividendDates` = ```[ ]``` or do not enter them.

Data Types: `double`

Ex-dividend dates, specified as the comma-separated pair consisting of `'ExDividendDates'` and a `NDIV`-by-`1` vector.

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

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

Data Types: `double`

Size of the asset grid for a finite difference grid, specified as the comma-separated pair consisting of `'AssetGridSize'` and a positive scalar.

Data Types: `double`

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

Data Types: `double`

Option type, specified as the comma-separated pair consisting of `'AmericanOpt'` and a positive integer scalar flag with one of these values:

• `0` — European

• `1` — American

Data Types: `double`

Method of interpolation for estimating the implied volatility surface from `ImpliedVolData`, specified as the comma-separated pair consisting of `'InterpMethod'` and a character vector or string array 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`

## Output Arguments

collapse all

Option price, returned as a scalar numeric.

Grid containing prices calculated by the finite difference method, returned as a grid that is two-dimensional with size `AssetGridSize``TimeGridSize`. The number of columns does not have to be equal to the `TimeGridSize`, because `ExerciseDates` and `ExDividendDates` are added to the time grid. `PriceGrid(:, :, end)` contains the price for t = `0`.

Prices of the asset corresponding to the first dimension of `PriceGrid`, returned as a vector.

Times corresponding to second dimension of the `PriceGrid`, returned as a vector.

collapse all

### Vanilla Option

A vanilla option is a category of options that includes only the most standard components.

A vanilla option has an expiration date and straightforward strike price. American-style options and European-style options are both categorized as vanilla options.

The payoff for a vanilla option is as follows:

• For a call: $\mathrm{max}\left(St-K,0\right)$

• For a put: $\mathrm{max}\left(K-St,0\right)$

where:

St is the price of the underlying asset at time t.

K is the strike price.

### Local Volatility Model

A local volatility model treats volatility as a function both of the current asset level and of time.

The local volatility can be estimated by using the Dupire formula [2]:

`$\begin{array}{l}{\sigma }_{loc}^{2}\left(K,\tau \right)=\frac{{\sigma }_{imp}^{2}+2\tau {\sigma }_{imp}\frac{\partial {\sigma }_{imp}}{\partial \tau }+2\left(\tau -d\right)K\tau {\sigma }_{imp}\frac{\partial {\sigma }_{imp}}{\partial K}}{{\left(1+K{d}_{1}\sqrt{\tau }\frac{\partial {\sigma }_{imp}}{\partial K}\right)}^{2}+{K}^{2}\tau {\sigma }_{imp}\left(\frac{{\partial }^{2}{\sigma }_{imp}}{\partial {K}^{2}}-{d}_{1}\sqrt{\tau }{\left(\frac{\partial {\sigma }_{imp}}{\partial K}\right)}^{2}\right)}\\ {d}_{1}=\frac{\mathrm{ln}\left({S}_{0}/K\right)+\left(\left(\tau -d\right)+{\sigma }_{imp}^{2}/2\right)\tau }{{\sigma }_{imp}\sqrt{\tau }}\end{array}$`

## References

[1] Andersen, L. B., and R. Brotherton-Ratcliffe. "The Equity Option Volatility Smile: An Implicit Finite-Difference Approach." Journal of Computational Finance. Vol. 1, Number 2, 1997, pp. 5–37.

[2] Dupire, B. "Pricing with a Smile." Risk. Vol. 7, Number 1, 1994, pp. 18–20.

## Version History

Introduced in R2018b