Fly#

class rateslib.instruments.Fly(instrument1, instrument2, instrument3)#

Bases: Sensitivities

A butterfly instrument which is, mechanically, the spread of two spread instruments.

Parameters:
  • instrument1 (Instrument) – The initial instrument, usually the shortest tenor, e.g. 5Y in 5s10s15s.

  • instrument2 (Instrument) – The second instrument, usually the mid-length tenor, e.g. 10Y in 5s10s15s.

  • instrument3 (Instrument) – The third instrument, usually the longest tenor, e.g. 15Y in 5s10s15s.

Notes

When using a Fly each Instrument must either have pricing parameters pre-defined using the appropriate pricing mechanisms or share common pricing parameters defined at price time.

Examples

See examples for Spread for similar functionality.

Methods Summary

cashflows(*args, **kwargs)

delta(*args, **kwargs)

Calculate the delta of the Instrument.

exo_delta(vars[, curves, solver, fx, base, ...])

Calculate delta risk of an Instrument against some exogenous user created Variables.

fixings_table([curves, solver, fx, base, ...])

Return a DataFrame of fixing exposures on the Instruments.

gamma(*args, **kwargs)

Calculate the gamma of the Instrument.

npv(*args, **kwargs)

Return the NPV of the composited object by summing instrument NPVs.

rate(*args, **kwargs)

Return the mid-market rate of the composited via the difference of instrument rates.

Methods Documentation

cashflows(*args, **kwargs)#
delta(*args, **kwargs)#

Calculate the delta of the Instrument.

For arguments see Sensitivities.delta().

exo_delta(vars, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False, vars_scalar=NoInput.blank, vars_labels=NoInput.blank, **kwargs)#

Calculate delta risk of an Instrument against some exogenous user created Variables.

See What are exogenous variables? in the cookbook.

Parameters:
  • vars (list[str]) – The variable tags which to determine sensitivities for.

  • curves (Curve, str or list of such, optional) –

    A single Curve or id or a list of such. A list defines the following curves in the order:

    • Forecasting Curve for leg1.

    • Discounting Curve for leg1.

    • Forecasting Curve for leg2.

    • Discounting Curve for leg2.

  • solver (Solver, optional) – The Solver that calibrates Curves from given Instruments.

  • fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a FXRates or FXForwards object, converts from local currency into base.

  • base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if fx_rate is an FXRates or FXForwards object.

  • local (bool, optional) – If True will ignore base - this is equivalent to setting base to None. Included only for argument signature consistent with npv.

  • vars_scalar (list[float], optional) – Scaling factors for each variable, for example converting rates to basis point etc. Defaults to ones.

  • vars_labels (list[str], optional) – Alternative names to relabel variables in DataFrames.

Return type:

DataFrame

fixings_table(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, approximate=False, right=NoInput.blank)#

Return a DataFrame of fixing exposures on the Instruments.

For arguments see XCS.fixings_table(), and/or IRS.fixings_table()

Return type:

DataFrame

gamma(*args, **kwargs)#

Calculate the gamma of the Instrument.

For arguments see Sensitivities.gamma().

npv(*args, **kwargs)#

Return the NPV of the composited object by summing instrument NPVs.

Parameters:
  • args – Positional arguments required for the npv method of both of the underlying Instruments.

  • kwargs – Keyword arguments required for the npv method of both of the underlying Instruments.

Return type:

float, Dual or Dual2

rate(*args, **kwargs)#

Return the mid-market rate of the composited via the difference of instrument rates.

Parameters:
  • args – Positional arguments required for the rate method of both of the underlying Instruments.

  • kwargs – Keyword arguments required for the rate method of both of the underlying Instruments.

Return type:

float, Dual or Dual2