FXSabrSmile#
- class rateslib.fx_volatility.FXSabrSmile(nodes, eval_date, expiry, delivery_lag=NoInput.blank, calendar=NoInput.blank, pair=NoInput.blank, id=NoInput.blank, ad=0)#
Bases:
_WithState,_WithCache[float,float | Dual | Dual2 | Variable]Create an FX Volatility Smile at a given expiry indexed by strike using SABR parameters.
Warning
This class is in beta status.
- Parameters:
nodes (dict[str, DualTypes]) – The parameters for the SABR model. Keys must be ‘alpha’, ‘beta’, ‘rho’, ‘nu’. See below.
eval_date (datetime) – Acts as the initial node of a Curve. Should be assigned today’s immediate date.
expiry (datetime) – The expiry date of the options associated with this Smile
id (str, optional) – The unique identifier to distinguish between Smiles in a multicurrency framework and/or Surface.
delivery_lag (int, optional) – The number of business days after expiry that the physical settlement of the FX exchange occurs. Uses
defaults.fx_delivery_lag. Used in determination of ATM forward rates.calendar (calendar or str, optional) – The holiday calendar object to use for FX delivery day determination. If str, looks up named calendar from static data.
pair (str, optional) – The FX currency pair used to determine ATM forward rates.
ad (int, optional) – Sets the automatic differentiation order. Defines whether to convert node values to float,
DualorDual2. It is advised against using this setting directly. It is mainly used internally.
Notes
The keys for
nodesare described as the following:alpha(DualTypes): The initial volatility parameter (e.g. 0.10 for 10%) of the SABR model, in (0, inf).beta(float): The scaling parameter between normal (0) and lognormal (1) of the SABR model in [0, 1].rho(DualTypes): The correlation between spot and volatility of the SABR model, e.g. -0.10, in [-1.0, 1.0)nu(DualTypes): The volatility of volatility parameter of the SABR model, e.g. 0.80.
The arguments
delivery_lag,calendarandpairare only required if using anFXForwardsobject to forecast ATM-forward FX rates for pricing. If the forward rates are supplied directly as numeric values these arguments are not required.Attributes Summary
Methods Summary
get_from_strike(k, f[, expiry, w_deli, w_spot])Given an option strike return the volatility.
plot([comparators, labels, x_axis, f])Plot volatilities associated with the Smile.
update_node(key, value)Update a single node value on the SABRSmile.
Attributes Documentation
- ad#
- n = 4#
Methods Documentation
- get_from_strike(k, f, expiry=NoInput.blank, w_deli=NoInput.blank, w_spot=NoInput.blank)#
Given an option strike return the volatility.
- Parameters:
f (float, Dual, Dual2) – The forward rate at delivery of the option.
expiry (datetime, optional) – Typically uses with Surfaces. If given, performs a check to ensure consistency of valuations. Raises if expiry requested and expiry of the Smile do not match. Used internally.
w_deli (DualTypes, optional) – Not used by SabrSmile
w_spot (DualTypes, optional) – Not used by SabrSmile
- Returns:
tuple of DualTypes
- Return type:
(placeholder, vol, k)
Notes
This function returns a tuple consistent with an
FXDeltaVolSmile, however since the FXSabrSmile has no concept of a delta index the first element returned is always zero and can be effectively ignored.
- plot(comparators=NoInput.blank, labels=NoInput.blank, x_axis='strike', f=NoInput.blank)#
Plot volatilities associated with the Smile.
Warning
The ‘delta’
x_axistype for a SabrSmile is calculated based on a forward, unadjusted delta and is expressed as a negated put option delta consistent with the definition for aFXDeltaVolSmile.- Parameters:
comparators (list[Smile]) – A list of Smiles which to include on the same plot as comparators. Note the comments on
FXDeltaVolSmile.plot.labels (list[str]) – A list of strings associated with the plot and comparators. Must be same length as number of plots.
x_axis (str in {"strike", "moneyness", "delta"}) – ‘strike’ is the natural option for this Smile type. If ‘delta’ see the warning. If ‘moneyness’ the strikes are converted using
f.f (DualTypes) – The FX forward rate at delivery.
- Returns:
(fig, ax, line)
- Return type:
Matplotlib.Figure, Matplotplib.Axes, Matplotlib.Lines2D
- update_node(key, value)#
Update a single node value on the SABRSmile.
- Parameters:
- Return type:
None
Notes
Warning
Rateslib is an object-oriented library that uses complex associations. Although Python may not object to directly mutating attributes of a Curve instance, this should be avoided in rateslib. Only use official
updatemethods to mutate the values of an existing Curve instance. This class is labelled as a mutable on update object.