optSensByLocalVolFD
Option price and sensitivities by local volatility model, using finite differences
Syntax
Description
[
compute option price and sensitivities by the local volatility model, using the
Crank-Nicolson method.PriceSens
,PriceGrid
,AssetPrices
,Times
]
= optSensByLocalVolFD(Rate
,AssetPrice
,Settle
,ExerciseDates
,OptSpec
,Strike
,ImpliedVolData
)
Note
Alternatively, you can use the Vanilla
object to calculate price or sensitivities for vanilla options. For more
information, see Get Started with Workflows Using Object-Based Framework for Pricing Financial Instruments.
[
specifies options using one or more name-value pair arguments in addition to the
input arguments in the previous syntax. PriceSens
,PriceGrid
,AssetPrices
,Times
]
= optSensByLocalVolFD(___,Name,Value
)
Examples
Compute European Option Price and Sensitivities Using the Local Volatility Model
Define the option variables.
AssetPrice = 590; Strike = 590; Rate = 0.06; DividendYield = 0.0262; Settle = datetime(2018,1,1); ExerciseDates = datetime(2020,1,1);
Define the implied volatility surface data.
Maturity = [datetime(2018,3,6) datetime(2018,6,5) datetime(2018,9,12) datetime(2018,12,10) datetime(2019,1,1) datetime(2019,7,2) datetime(2020,1,1) datetime(2021,1,1) datetime(2022,1,1) datetime(2023,1,1)]; 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 and sensitivities.
OptSpec = 'Call'; [Delta,Gamma,Lambda,Theta,Price] = optSensByLocalVolFD(Rate, AssetPrice, ... Settle, ExerciseDates, OptSpec, Strike, ImpliedVolData, 'DividendYield',DividendYield, ... 'OutSpec',["Delta" "Gamma" "Lambda" "Theta" "Price"])
Delta = 0.5519
Gamma = 0.0091
Lambda = 4.9994
Theta = -20.9529
Price = 65.1319
Input Arguments
Rate
— Continuously compounded risk-free interest rate
scalar numeric
Continuously compounded risk-free interest rate, specified by a scalar numeric.
Data Types: double
AssetPrice
— Current underlying asset price
scalar numeric
Current underlying asset price, specified as a scalar numeric.
Data Types: double
Settle
— Settlement date
datetime scalar | string scalar | date character vector
Settlement date, specified as a scalar datetime, string, or date character vector.
To support existing code, optSensByLocalVolFD
also
accepts serial date numbers as inputs, but they are not recommended.
ExerciseDates
— Option exercise dates
datetime array | string array | date character vector
Option exercise dates, specified as a datetime array, string array, or date character vectors:
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 dates. 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 betweenSettle
and the single listed date inExerciseDates
.
To support existing code, optSensByLocalVolFD
also
accepts serial date numbers as inputs, but they are not recommended.
OptSpec
— Definition of option
character vector with value of 'call'
or 'put'
| string array with value of "call"
or "put"
Definition of the option, specified as a character vector or string array
with a value of 'call'
or
'put'
.
Data Types: char
| string
Strike
— Option strike price value
nonnegative scalar
Option strike price value, specified as a nonnegative scalar.
Data Types: double
ImpliedVolData
— Table of maturity dates, strike or exercise prices, and corresponding implied volatilities
table
A 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: PriceSens = Price = optByLocalVolFD(Rate,AssetPrice,Settle,
ExerciseDates,OptSpec,Strike,ImpliedVolData,'AssetGridSize',1000,'OutSpec',{'delta','gamma','vega','lambda','rho','theta','price'})
Basis
— Day-count basis
0
(default) | numeric values: 0
,1
, 2
, 3
, 4
, 6
, 7
, 8
,
9
, 10
, 11
,
12
, 13
Day-count basis, specified as the comma-separated pair consisting of
'Basis'
and a scalar using one of these 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
For more information, see Basis.
Data Types: double
DividendYield
— Continuously compounded underlying asset yield
0
(default) | scalar numeric
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
DividendAmounts
— Cash dividend amounts
[ ]
(default) | vector
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
ExDividendDates
— Ex-dividend dates
[ ]
(default) | datetime array | string array | date character vector
Ex-dividend dates, specified as the comma-separated pair consisting of
'ExDividendDates'
and a
NDIV
-by-1
vector using a
datetime array, string array, or date character vectors.
To support existing code, optSensByLocalVolFD
also
accepts serial date numbers as inputs, but they are not recommended.
AssetPriceMax
— Maximum price for price grid boundary
if unspecified, AssetPriceMax
values are calculated using asset distributions at maturity (default) | positive scalar
Maximum price for price grid boundary, specified as the
comma-separated pair consisting of 'AssetPriceMax'
and a positive scalar.
Data Types: double
AssetGridSize
— Size of asset grid for finite difference grid
400
(default) | positive scalar
Size of the asset grid for finite difference grid, specified as the
comma-separated pair consisting of 'AssetGridSize'
and a positive scalar.
Data Types: double
TimeGridSize
— Size of time grid for finite difference grid
100
(default) | positive scalar
Size of the time grid for finite difference grid, specified as the
comma-separated pair consisting of 'TimeGridSize'
and
a positive scalar.
Data Types: double
AmericanOpt
— Option type
0
(European) (default) | scalar with values [0,1]
Option type, specified as the comma-separated pair consisting of
'AmericanOpt'
and a positive integer scalar flag
with one of these values:
0
— European1
— American
Data Types: double
InterpMethod
— Method of interpolation for estimating the implied volatility surface from ImpliedVolData
'linear'
(default) | character vector with values 'linear'
,
'makima'
, 'spline'
, or
'tpaps'
| string with values "linear"
,
"makima"
, "spline"
, or
"tpaps"
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 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
OutSpec
— Define outputs
{'price'}
(default) | cell array of character vectors with values 'price'
, 'delta'
,
'gamma'
, 'vega'
,
'lambda'
, 'rho'
,
'theta'
| string array with values "price"
,
"delta"
, "gamma"
,
"vega"
, "rho"
,
"theta"
Define outputs, specified as the comma-separated pair consisting of
'OutSpec'
and an NOUT
-
by-1
or a
1
-by-NOUT
cell array of
character vectors with possible values of 'price'
,
'delta'
, 'gamma'
,
'vega'
, 'lambda'
,
'rho'
, and 'theta'
.
Example: OutSpec =
{'delta','gamma','vega','lambda','rho','theta','price'}
Data Types: cell
| string
Output Arguments
PriceSens
— Option price and sensitivities
scalar numeric
Option price and sensitivities, returned as a scalar numeric.
OutSpec
determines the types and order of the
output.
PriceGrid
— Grid containing prices calculated by finite difference method
grid
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
.
AssetPrices
— Prices of asset
vector
Prices of the asset corresponding to the first dimension of
PriceGrid
, returned as a vector.
Times
— Times
vector
Times corresponding to second dimension of the
PriceGrid
, returned as a vector.
More About
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:
For a put:
where:
St is the price of the underlying asset at time t.
K is the strike price.
For more information, see Vanilla Option.
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]:
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 R2018bR2022b: Serial date numbers not recommended
Although optSensByLocalVolFD
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
optstockbyfd
| optstocksensbyfd
| optByLocalVolFD
| optByHestonFD
| optSensByHestonFD
| optByBatesFD
| optSensByBatesFD
| optByMertonFD
| optSensByMertonFD
| Vanilla
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.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- 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)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)