_WithCashflows#
- class rateslib.periods.protocols._WithCashflows(*args, **kwargs)#
Bases:
_WithNPV,ProtocolProtocol for parameter and calculation display for the Period.
Warning
The direct methods of this class are for display convenience. Calling these to extract certain values should be avoided. It is more efficient to source relevant parameters or calculations from object attributes or other methods directly.
Required methods
try_cashflow(*[, rate_curve, disc_curve, ...])Calculate the cashflow for the Period with any non-deliverable currency adjustment and indexation.
Provided methods
cashflows(*[, rate_curve, disc_curve, ...])Return aggregated cashflow data for the Period.
Attributes Summary
The
_SettlementParamsof the Period.Methods Summary
cashflows(*[, rate_curve, disc_curve, ...])Return aggregated cashflow data for the Period.
immediate_local_npv(*[, rate_curve, ...])Calculate the immediate NPV of the Period in local settlement currency.
local_npv(*[, rate_curve, index_curve, ...])Calculate the NPV of the Period in local settlement currency.
npv(*[, rate_curve, index_curve, ...])Calculate the NPV of the Period converted to any other base accounting currency.
try_cashflow(*[, rate_curve, disc_curve, ...])Calculate the cashflow for the Period with any non-deliverable currency adjustment and indexation.
try_immediate_local_npv(*[, rate_curve, ...])Replicate
immediate_local_npv()with lazy exception handling.try_local_npv(*[, rate_curve, index_curve, ...])Replicate
local_npv()with lazy exception handling.Attributes Documentation
- settlement_params#
The
_SettlementParamsof the Period.
Methods Documentation
- cashflows(*, rate_curve=NoInput.blank, disc_curve=NoInput.blank, index_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Return aggregated cashflow data for the Period.
Warning
This method is a convenience method to provide a visual representation of all associated calculation data. Calling this method to extracting certain values should be avoided. It is more efficient to source relevant parameters or calculations from object attributes or other methods directly.
- Parameters:
rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.
index_curve (_BaseCurve, optional) – Used to forecast index values for indexation, if necessary.
disc_curve (_BaseCurve, optional) – Used to discount cashflows.
fx (FXForwards, optional) – The
FXForwardsobject used for forecasting thefx_fixingfor deliverable cashflows, if necessary. Or, anFXRatesobject purely for immediate currency conversion.fx_vol (FXDeltaVolSmile, FXSabrSmile, FXDeltaVolSurface, FXSabrSurface, optional) – The FX volatility Smile or Surface object used for determining Black calendar day implied volatility values.
base (str, optional) – The currency to convert the local settlement NPV to.
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:
dict of values
- immediate_local_npv(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank)#
Calculate the immediate NPV of the Period in local settlement currency.
This method does not adjust for ex-dividend and is an immediate measure according to,
\[P_0 = \mathbb{E^Q} [V(m_T) C(m_T)]\]- Parameters:
rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.
index_curve (_BaseCurve, optional) – Used to forecast index values for indexation, if necessary.
disc_curve (_BaseCurve, optional) – Used to discount cashflows.
fx (FXForwards, optional) – The
FXForwardsobject used for forecasting thefx_fixingfor deliverable cashflows, if necessary. Or, an class:~rateslib.fx.FXRates object purely for immediate currency conversion.fx_vol (FXDeltaVolSmile, FXSabrSmile, FXDeltaVolSurface, FXSabrSurface, optional) – The FX volatility Smile or Surface object used for determining Black calendar day implied volatility values.
- Return type:
- local_npv(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate the NPV of the Period in local settlement currency.
This method adjusts the immediate NPV for ex-dividend, settlement and forward projected value, according to,
\[\begin{split}P(m_s, m_f) = \mathbb{I}(m_s) \frac{1}{v(m_f)} P_0, \qquad \; \mathbb{I}(m_s) = \left \{ \begin{matrix} 0 & m_s > m_{ex} \\ 1 & m_s \leq m_{ex} \end{matrix} \right .\end{split}\]for forward, \(m_f\), settlement, \(m_s\), and ex-dividend, \(m_{ex}\).
- Parameters:
rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.
index_curve (_BaseCurve, optional) – Used to forecast index values for indexation, if necessary.
disc_curve (_BaseCurve, optional) – Used to discount cashflows.
fx (FXForwards, optional) – The
FXForwardsobject used for forecasting thefx_fixingfor deliverable cashflows, if necessary. Or, an class:~rateslib.fx.FXRates object purely for immediate currency conversion.fx_vol (FXDeltaVolSmile, FXSabrSmile, FXDeltaVolSurface, FXSabrSurface, optional) – The FX volatility Smile or Surface object used for determining Black calendar day implied volatility values.
settlement (datetime, optional (set as immediate date)) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional (set as
settlement)) – The future date to project the PV to using thedisc_curve.
- Return type:
- npv(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank, base=NoInput.blank, local=False, settlement=NoInput.blank, forward=NoInput.blank)#
Calculate the NPV of the Period converted to any other base accounting currency.
This method converts a local settlement currency value to a base accounting currency according to:
\[P^{bas}(m_s, m_f) = f_{loc:bas}(m_f) P(m_s, m_f)\]Hint
If the cashflows are unspecified or incalculable due to missing information this method will raise an exception. For a function that returns a Result indicating success or failure use
try_local_npv().- Parameters:
rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.
index_curve (_BaseCurve, optional) – Used to forecast index values for indexation, if necessary.
disc_curve (_BaseCurve, optional) – Used to discount cashflows.
fx (FXForwards, optional) – The
FXForwardsobject used for forecasting thefx_fixingfor deliverable cashflows, if necessary. Or, anFXRatesobject purely for immediate currency conversion.fx_vol (FXDeltaVolSmile, FXSabrSmile, FXDeltaVolSurface, FXSabrSurface, optional) – The FX volatility Smile or Surface object used for determining Black calendar day implied volatility values.
base (str, optional) – The currency to convert the local settlement NPV to.
local (bool, optional) – An override flag to return a dict of NPV values indexed by string currency.
settlement (datetime, optional, (set as immediate date)) – The assumed settlement date of the PV determination. Used only to evaluate ex-dividend status.
forward (datetime, optional, (set as
settlement)) – The future date to project the PV to using thedisc_curve.
- Return type:
float, Dual, Dual2, Variable or dict of such indexed by string currency.
Notes
If
baseis not provided then this function will return the value obtained fromlocal_npv().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.
- try_cashflow(*, rate_curve=NoInput.blank, disc_curve=NoInput.blank, index_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank)#
Calculate the cashflow for the Period with any non-deliverable currency adjustment and indexation.
- Parameters:
rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.
index_curve (_BaseCurve, optional) – Used to forecast index values for indexation, if necessary.
disc_curve (_BaseCurve, optional) – Used to discount cashflows.
fx (FXForwards, optional) – The
FXForwardsobject used for forecasting thefx_fixingfor deliverable cashflows, if necessary. Or, anFXRatesobject purely for immediate currency conversion.fx_vol (FXDeltaVolSmile, FXSabrSmile, FXDeltaVolSurface, FXSabrSurface, optional) – The FX volatility Smile or Surface object used for determining Black calendar day implied volatility values.
- Return type:
- try_immediate_local_npv(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank)#
Replicate
immediate_local_npv()with lazy exception handling.
- try_local_npv(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank, settlement=NoInput.blank, forward=NoInput.blank)#
Replicate
local_npv()with lazy exception handling.