volatilities
Description
computes implied volatilities for a outVolatilities
= volatilities(inpPricer
,ExerciseDate
,ForwardValue
,Strike
)Swaption
instrument when you
use a SABR
pricer.
Examples
Compute Implied Volatilities for Swaption Instrument
This example shows the workflow to compute implied volatilities for a Swaption
Instrument.
Create ratecurve Object
Create a ratecurve
object using ratecurve
.
ValuationDate = datetime(2016,3,5); ZeroDates = datemnth(ValuationDate,[1 2 3 6 9 12*[1 2 3 4 5 6 7 8 9 10 12]])'; ZeroRates = [-0.33 -0.28 -0.24 -0.12 -0.08 -0.03 0.015 0.028 ... 0.033 0.042 0.056 0.095 0.194 0.299 0.415 0.525]'/100; Compounding = 1; ZeroCurve = ratecurve("zero",ValuationDate,ZeroDates,ZeroRates,'Compounding',Compounding)
ZeroCurve = ratecurve with properties: Type: "zero" Compounding: 1 Basis: 0 Dates: [16x1 datetime] Rates: [16x1 double] Settle: 05-Mar-2016 InterpMethod: "linear" ShortExtrapMethod: "next" LongExtrapMethod: "previous"
Create SABR
Model Object
Use finmodel
to create a SABR
model object.
Alpha = 0.0135; Beta = 0.5; Rho = 0.4654; Nu = 0.4957; Shift = 0.008; SABRModel = finmodel("SABR",'Alpha',Alpha,'Beta',Beta,'Rho',Rho,'Nu',Nu,'Shift',Shift)
SABRModel = SABR with properties: Alpha: 0.0135 Beta: 0.5000 Rho: 0.4654 Nu: 0.4957 Shift: 0.0080 VolatilityType: "black"
Create SABR
Pricer Object
Use finpricer
to create a SABR
pricer object and use the ratecurve
object for the 'DiscountCurve'
name-value pair argument.
SABRPricer = finpricer("Analytic", 'Model', SABRModel,'DiscountCurve', ZeroCurve)
SABRPricer = SABR with properties: DiscountCurve: [1x1 ratecurve] Model: [1x1 finmodel.SABR]
Compute Implied Volatilities
Use volatilities
to compute the implied volatilities for a Swaption
instrument.
SwaptionExerciseDate = datetime(2017,3,5); ForwardValue = 0.0007; StrikeGrid = [-0.5; -0.25; -0.125; 0; 0.125; 0.25; 0.5; 1.0; 1.5]/100; MarketStrikes = ForwardValue + StrikeGrid; outVolatilities = volatilities(SABRPricer, SwaptionExerciseDate, ForwardValue, MarketStrikes)
outVolatilities = 9×1
0.2132
0.1500
0.1409
0.1474
0.1609
0.1752
0.2004
0.2372
0.2627
Input Arguments
inpPricer
— SABR pricer
SABR
pricer object
SABR pricer, specified as a previously created SABR
pricer
object.
Data Types: object
ExerciseDate
— Option exercise date
datetime scalar | string scalar | date character vector
Option exercise date, specified as a scalar datetime, string, or date character vector.
To support existing code, volatilities
also
accepts serial date numbers as inputs, but they are not recommended.
ForwardValue
— Forward swap rate
decimal
Forward swap rate, specified as a scalar decimal.
Data Types: object
Strike
— Strike rate
decimal
Strike rate, specified as a scalar decimal.
Data Types: double
Output Arguments
outVolatilities
— Output volatilities
numeric
Output volatilities, returned as a numeric.
Version History
Introduced in R2020bR2022b: Serial date numbers not recommended
Although volatilities
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.
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 (한국어)