_WithNPV#
- class rateslib.instruments.protocols._WithNPV(*args, **kwargs)#
Bases:
_WithPricingObjs,ProtocolProtocol to establish value of any Instrument type.
Attributes Summary
The
_KWArgscontainer for the Instrument.The default
_SettlementParamsof 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
- settlement_params#
The default
_SettlementParamsof the Instrument.This is used to define a
basecurrency 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
Solverobject containing Curve, Smile, Surface, or Cube mappings for pricing.fx (FXForwards, optional) – The
FXForwardsobject 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
baseis not given then this function will return the value obtained from determining the PV in local settlement currency.If
baseis provided this then anFXForwardsobject may be required to perform conversions. AnFXRatesobject is also allowed for this conversion although best practice does not recommend it due to possible settlement date conflicts.