_WithNPV#

class rateslib.instruments.protocols._WithNPV(*args, **kwargs)#

Bases: _WithPricingObjs, Protocol

Protocol to establish value of any Instrument type.

Attributes Summary

kwargs

The _KWArgs container for the Instrument.

settlement_params

The default _SettlementParams of the Instrument.

Methods Summary

npv(*[, curves, solver, fx, vol, base, ...])

Calculate the NPV of the Instrument converted to any other base accounting currency.

Attributes Documentation

kwargs#

The _KWArgs container for the Instrument.

settlement_params#

The default _SettlementParams of the Instrument.

This is used to define a base currency when one is not specified.

Methods Documentation

npv(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, local=False, settlement=NoInput.blank, forward=NoInput.blank)#

Calculate the NPV of the Instrument converted to any other base accounting currency.

Examples

In [142]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75})

In [143]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", fixed_rate=1.0, curves=[curve])

In [144]: irs.npv()
Out[144]: 53875.24237805192

In [145]: irs.npv(local=True)
Out[145]: {'usd': 53875.24237805192}
Parameters:
  • curves (_Curves, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.

  • solver (Solver, optional) – A Solver object containing Curve, Smile, Surface, or Cube mappings for pricing.

  • fx (FXForwards, optional) – The FXForwards object used for forecasting FX rates, if necessary.

  • vol (_Vol, optional) – Pricing objects. See Pricing on each Instrument for details of allowed inputs.

  • base (str, optional (set to settlement currency)) – The currency to convert the local settlement NPV to.

  • local (bool, optional (set as False)) – An override flag to return a dict of NPV values indexed by string currency.

  • settlement (datetime, optional) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.

  • forward (datetime, optional) – The future date to project the PV to using the disc_curve.

Return type:

float, Dual, Dual2, Variable or dict of such indexed by string currency.

Notes

If base is not given then this function will return the value obtained from determining the PV in local settlement currency.

If base is provided this then an FXForwards object may be required to perform conversions. An FXRates object is also allowed for this conversion although best practice does not recommend it due to possible settlement date conflicts.