Option price and sensitivities by local volatility model, using finite differences
[
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
)
[
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
)
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 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.5462
Gamma = 0.0082
Lambda = 4.9173
Theta = -20.8350
Price = 65.5302
Rate
— Continuously compounded risk-free interest rateContinuously compounded risk-free interest rate, specified by a scalar numeric.
Data Types: double
AssetPrice
— Current underlying asset priceCurrent underlying asset price, specified as a scalar numeric.
Data Types: double
Settle
— Settlement dateSettlement date, specified as a scalar serial date number, date character vector, datetime object, or string array
Data Types: double
| char
| datetime
| string
ExerciseDates
— Option exercise datesOption 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, datetimes, or
strings. 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
OptSpec
— Definition of option '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 valueOption strike price value, specified as a nonnegative scalar.
Data Types: double
ImpliedVolData
— Table of maturity dates, strike or exercise prices, and corresponding implied volatilitiesA table of maturity dates, strike or exercise prices, and their
corresponding implied volatilities,specified as a
NVOL
-by-3
table.
Data Types: table
Specify 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
.
PriceSens = Price = optByLocalVolFD(Rate,AssetPrice,Settle,
ExerciseDates,OptSpec,Strike,ImpliedVolData,'AssetGridSize',1000,'OutSpec',{'delta','gamma','vega','lambda','rho','theta','price'})
'Basis'
— Day-count basis0
(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 yield0
(default) | scalar numericContinuously compounded underlying asset yield, specified as the
comma-separated pair consisting of 'DividendYield'
and a scalar numeric.
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) | vectorCash 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
.
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) | serial date number | date character vector | datetime array | string arrayEx-dividend dates, specified as the comma-separated pair consisting of
'ExDividendDates'
and a
NDIV
-by-1
vector.
Data Types: double
| char
| string
| datetime
'AssetPriceMax'
— Maximum price for price grid boundaryAssetPriceMax
values are calculated using asset distributions at maturity (default) | positive scalarMaximum 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 grid400
(default) | positive scalarSize 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 grid100
(default) | positive scalarSize 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 type0
(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
— European
1
— 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
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 (MATLAB) and Interpolating Gridded Data (MATLAB).
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
PriceSens
— Option price and sensitivitiesOption 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 methodGrid 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 assetPrices of the asset corresponding to the first dimension of
PriceGrid
, returned as a vector.
Times
— TimesTimes corresponding to second dimension of the
PriceGrid
, returned as a vector.
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]:
[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.
optByBatesFD
| optByHestonFD
| optByLocalVolFD
| optByMertonFD
| optBySensMertonFD
| optSensByBatesFD
| optSensByHestonFD
| optstockbyfd
| optstocksensbyfd
A modified version of this example exists on your system. Do you want to open this version instead? (es)
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.
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: .
Select web siteYou can also select a web site from the following list:
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.