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
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
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 datetime, string, or date character vector.
To support existing code, optSensByLocalVolFD
also
accepts serial date numbers as inputs, but they are not recommended.
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.
Definition of the option, specified as a character vector or string array
with a value of 'call'
or
'put'
.
Data Types: char
| string
Option strike price value, specified as a nonnegative scalar.
Data Types: double
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'})
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
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 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.
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 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 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
— European1
— 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 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
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
Option price and sensitivities, returned as a scalar numeric.
OutSpec
determines the types and order of the
output.
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.
More About
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.
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 R2018bAlthough 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.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- 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)