_WithRate#
- class rateslib.instruments.protocols._WithRate(*args, **kwargs)#
Bases:
ProtocolProtocol to establish a rate pricing metric of any Instrument type.
Attributes Summary
A scaling quantity associated with the
Solverrisk calculations.Methods Summary
rate(*[, curves, solver, fx, vol, base, ...])Calculate some pricing rate metric for the Instrument.
spread(*[, curves, solver, fx, vol, base, ...])Calculate some pricing spread metric for the Instrument.
Attributes Documentation
Methods Documentation
- rate(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank, metric=NoInput.blank)#
Calculate some pricing rate metric for the Instrument.
Examples
The default metric for an
IRSis its fixed ‘rate’.In [146]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [147]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve], fixed_rate=2.0) In [148]: irs.rate() # <- `fixed_rate` on fixed leg to equate value with float leg Out[148]: 2.87622187684324
- 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.metric (str, optional) – The specific calculation to perform and the value to return. See Pricing on each Instrument for details of allowed inputs.
- Return type:
- spread(*, curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate some pricing spread metric for the Instrument.
This calculation may be an alias for
rate()with a specific metric and is designated at an Instrument level.Examples
The ‘spread’ on an
IRSis the float leg spread to equate value with the fixed leg.In [149]: curve = Curve({dt(2000, 1, 1): 1.0, dt(2010, 1, 1): 0.75}) In [150]: irs = IRS(dt(2000, 1, 1), "3Y", spec="usd_irs", curves=[curve], fixed_rate=2.0) In [151]: irs.spread() # <- `spread` on float leg to equate value with fixed leg Out[151]: -87.62218768432399
- 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: