FXDeltaVolSmile#

class rateslib.fx_volatility.FXDeltaVolSmile(nodes, eval_date, expiry, delta_type, id=NoInput.blank, ad=0)#

Bases: object

Create an FX Volatility Smile at a given expiry indexed by delta percent.

Parameters:
  • nodes (dict[float, DualTypes]) – Key-value pairs for a delta index amount and associated volatility. See examples.

  • 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

  • delta_type (str in {"spot", "spot_pa", "forward", "forward_pa"}) – The type of delta calculation that is used on the options to attain a delta which is referenced by the node keys.

  • id (str, optional) – The unique identifier to distinguish between Smiles in a multicurrency framework and/or Surface.

  • ad (int, optional) – Sets the automatic differentiation order. Defines whether to convert node values to float, Dual or Dual2. It is advised against using this setting directly. It is mainly used internally.

Notes

The delta axis of this Smile is a negated put delta, i.e. 0.25 corresponds to a put delta of -0.25. This permits increasing strike for increasing delta index. For a ‘forward’ delta type 0.25 corresponds to a call delta of 0.75 via put-call delta parity. For a ‘spot’ delta type it would not because under a ‘spot’ delta type put-call delta parity is not 1.0, but related to the spot versus forward interest rates.

The interpolation function between nodes is a cubic spline.

  • For an unadjusted delta_type the range of the delta index is set to [0,1], and the cubic spline is natural with second order derivatives set to zero at the endpoints.

  • For premium adjusted delta_types the range of the delta index is in [0, d] where d is set large enough to encompass 99.99% of all possible values. The right endpoint is clamped with a first derivative of zero to avoid uncontrolled behaviour. The value of d is derived using \(d = e^{\sigma \sqrt{t} (3.75 + \frac{1}{2} \sigma \sqrt{t})}\)

Methods Summary

csolve()

Solves and sets the coefficients, c, of the PPSpline.

get(delta, delta_type, phi[, w_deli, w_spot, u])

Return a volatility for a provided real option delta.

get_from_strike(k, f[, w_deli, w_spot, expiry])

Given an option strike return associated delta and vol values.

plot([comparators, difference, labels, x_axis])

Plot given forward tenor rates from the curve.

Methods Documentation

csolve()#

Solves and sets the coefficients, c, of the PPSpline.

Return type:

None

Notes

Only impacts curves which have a knot sequence, t, and a PPSpline. Only solves if c not given at curve initialisation.

Uses the spline_endpoints attribute on the class to determine the solving method.

get(delta, delta_type, phi, w_deli=NoInput.blank, w_spot=NoInput.blank, u=NoInput.blank)#

Return a volatility for a provided real option delta.

This function is more explicit than the __getitem__ method of the Smile because it permits certain forward/spot delta conversions and put/call option delta conversions, and also converts to the index delta of the Smile.

Parameters:
  • delta (float) – The delta to obtain a volatility for.

  • delta_type (str in {"spot", "spot_pa", "forward", "forward_pa"}) – The delta type the given delta is expressed in.

  • phi (float) – Whether the given delta is assigned to a put or call option.

  • w_deli (DualTypes, optional) – Required only for spot/forward conversions.

  • w_spot (DualTypes, optional) – Required only for spot/forward conversions.

  • u (DualTypes, optional) – Required only for premium adjustment / unadjusted conversions.

Return type:

DualTypes

get_from_strike(k, f, w_deli=NoInput.blank, w_spot=NoInput.blank, expiry=NoInput.blank)#

Given an option strike return associated delta and vol values.

Parameters:
  • k (float, Dual, Dual2) – The strike of the option.

  • f (float, Dual, Dual2) – The forward rate at delivery of the option.

  • w_deli (DualTypes, optional) – Required only for spot/forward conversions.

  • w_spot (DualTypes, optional) – Required only for spot/forward conversions.

  • expiry (datetime, optional) – If given, performs a check to ensure consistency of valuations. Raises if expiry requested and expiry of the Smile do not match. Used internally.

Returns:

tuple of float, Dual, Dual2

Return type:

(delta index, vol, k)

Notes

This function will return a delta index associated with the FXDeltaVolSmile and the volatility attributed to the delta at that point. Recall that the delta index is the negated put option delta for the given strike k.

plot(comparators=NoInput.blank, difference=False, labels=NoInput.blank, x_axis='delta')#

Plot given forward tenor rates from the curve.

Parameters:
  • tenor (str) – The tenor of the forward rates to plot, e.g. “1D”, “3M”.

  • right (datetime or str, optional) – The right bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the final node of the curve minus the tenor.

  • left (datetime or str, optional) – The left bound of the graph. If given as str should be a tenor format defining a point measured from the initial node date of the curve. Defaults to the initial node of the curve.

  • comparators (list[Curve]) – A list of curves which to include on the same plot as comparators.

  • difference (bool) – Whether to plot as comparator minus base curve or outright curve levels in plot. Default is False.

  • 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 {"delta", "moneyness"}) – If “delta” the vol is shown relative to its native delta values. If “moneyness” the delta values are converted to \(K/f_d\).

Returns:

(fig, ax, line)

Return type:

Matplotlib.Figure, Matplotplib.Axes, Matplotlib.Lines2D