NDF#

class rateslib.instruments.NDF(settlement, pair, notional=NoInput.blank, fx_rate=NoInput.blank, fx_fixing=NoInput.blank, eval_date=NoInput.blank, calendar=NoInput.blank, modifier=NoInput.blank, currency=NoInput.blank, payment_lag=NoInput.blank, eom=NoInput.blank, curves=NoInput.blank, spec=NoInput.blank)#

Bases: Sensitivities, Metrics

Create a non-deliverable forward (NDF).

Parameters:
  • settlement (datetime or str) – The date on which settlement will occur. String tenors are allowed, e.g. “3M”.

  • pair (str) – The FX pair against which settlement takes place (2 x 3-digit code).

  • notional (float, Variable, optional) – The notional amount expressed in terms of buying units of the reference currency, and not settlement currency.

  • currency (str, optional) – The settlement currency of the contract. If not given is assumed to be currency 2 of the pair, e.g. USD in BRLUSD. Must be one of the currencies in pair. The reference currency is inferred as the other currency in the pair.

  • fx_rate (float, Variable, optional) – The agreed price on the NDF contact. May be omitted for unpriced contracts.

  • fx_fixing (float, Variable, optional) – The rate against which settlement takes place. Will be forecast if not given or not known.

  • eval_date (datetime, optional) – Required only if settlement is given as string tenor. Should be entered as today (also called horizon), and not spot. Spot is derived from payment_lag and calendar.

  • calendar (str or Calendar, optional) – Determines settlement if given as string tenor and fixing date from settlement.

  • modifier (str, optional) – Date modifier for determining string tenor.

  • payment_lag (int, optional) – Number of business day until settlement delivery. Defaults to 2 (spot) if not given. Used to derive the fx_fixing date and spot if using an eval_date.

  • eom (bool, optional) – Whether to allow end of month rolls to settlement as tenor.

  • curves (Curve, str or list of such, optional) – Only one curve is required for an NDF. This curve should discount cashflows in the given currency at a known collateral rate.

  • spec (str, optional) – An identifier to pre-populate many fields with conventional values. See here for more info and available values.

Examples

This is a standard non-deliverable forward with the notional expressed in EUR settling in USD.

In [1]: ndf = NDF(
   ...:     settlement="3m",
   ...:     pair="eurusd",  # <- EUR is the reference currency
   ...:     currency="usd",  # <- USD is the settlement currency
   ...:     notional=1e6,  # <- this is long 1mm EUR
   ...:     eval_date=dt(2000, 7, 1),
   ...:     calendar="tgt|fed",
   ...:     modifier="mf",
   ...:     payment_lag=2,
   ...:     fx_rate=1.04166666,  # (=125/120) <- implies short 1.0416mm USD
   ...:  )
   ...: 

This has the pair reversed but the notional is still expressed in EUR.

In [2]: ndf = NDF(
   ...:     settlement="3m",
   ...:     pair="usd",  # <- EUR is still reference currency
   ...:     currency="usd",  # <- USD is the settlement currency
   ...:     notional=1e6,  # <- this is long 1mm EUR
   ...:     eval_date=dt(2000, 7, 1),
   ...:     calendar="tgt|fed",
   ...:     modifier="mf",
   ...:     payment_lag=2,
   ...:     fx_rate=0.96,  # (=120/125) <- implies short 1.0416mm USD
   ...:  )
   ...: 

Attributes Summary

fixed_rate

If set will also set the fixed_rate of the contained leg1.

float_spread

If set will also set the float_spread of contained leg1.

index_base

If set will also set the index_base of the contained leg1.

leg2_fixed_rate

If set will also set the fixed_rate of the contained leg2.

leg2_float_spread

If set will also set the float_spread of contained leg2.

leg2_index_base

If set will also set the index_base of the contained leg1.

Methods Summary

analytic_delta(*args, **kwargs)

Return the analytic delta of the NDF.

cashflows([curves, solver, fx, base])

Return the cashflows of the NDF.

cashflows_table([curves, solver, fx, base])

Aggregate the values derived from a cashflows() method on an Instrument.

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.

gamma(*args, **kwargs)

Calculate the gamma of the Instrument.

npv([curves, solver, fx, base, local])

Return the NPV of the NDF.

rate([curves, solver, fx, base])

Return the mid-market pricing parameter of the NDF.

Attributes Documentation

fixed_rate#

If set will also set the fixed_rate of the contained leg1.

Note

fixed_rate, float_spread, leg2_fixed_rate and leg2_float_spread are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

float_spread#

If set will also set the float_spread of contained leg1.

Type:

float or None

index_base#

If set will also set the index_base of the contained leg1.

Note

index_base and leg2_index_base are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

leg2_fixed_rate#

If set will also set the fixed_rate of the contained leg2.

Type:

float or None

leg2_float_spread#

If set will also set the float_spread of contained leg2.

Type:

float or None

leg2_index_base#

If set will also set the index_base of the contained leg1.

Note

index_base and leg2_index_base are attributes only applicable to certain Instruments. AttributeErrors are raised if calling or setting these is invalid.

Type:

float or None

Methods Documentation

analytic_delta(*args, **kwargs)#

Return the analytic delta of the NDF.

Defined as zero.

Return type:

float

cashflows(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#

Return the cashflows of the NDF.

For arguments see BaseMixin.cashflows

cashflows_table(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, **kwargs)#

Aggregate the values derived from a cashflows() method on an Instrument.

Parameters:
  • curves (CurveType, str or list of such, optional) – Argument input to the underlying cashflows method of the Instrument.

  • solver (Solver, optional) – Argument input to the underlying cashflows method of the Instrument.

  • fx (float, FXRates, FXForwards, optional) – Argument input to the underlying cashflows method of the Instrument.

  • base (str, optional) – Argument input to the underlying cashflows method of the Instrument.

  • kwargs (dict) – Additional arguments input the underlying cashflows method of the Instrument.

Return type:

DataFrame

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

gamma(*args, **kwargs)#

Calculate the gamma of the Instrument.

For arguments see Sensitivities.gamma().

npv(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False)#

Return the NPV of the NDF.

Parameters:
  • curves (str or Curve) – The discount curve used for the settlement currency.

  • solver (Solver, optional) – The numerical Solver which may contain a mapping of curves, fx and/or base.

  • fx (FXForwards, optional) – An FXForwards market for forecasting.

  • base (str, optional) – The base currency to convert cashflows into (3-digit code). Only used if fx is an FXRates or FXForwards object. If not given defaults to fx.base.

  • local (bool, optional) – If True will return a dict identifying NPV by settlement currency.

Return type:

float, Dual, Dual2 or dict of such.

rate(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#

Return the mid-market pricing parameter of the NDF.

Parameters:
  • curves (str or Curve) – Not used by NDF.rate.

  • solver (Solver, optional) – The numerical Solver which may contain a mapping of curves, fx and/or base.

  • fx (FXForwards, optional) – An FXForwards market for forecasting.

  • base (str, optional) – Not used by NDF.rate.

Return type:

float, Dual, Dual2