_WithAnalyticDeltaStatic#

class rateslib.periods.protocols._WithAnalyticDeltaStatic(*args, **kwargs)#

Bases: _WithAnalyticDelta, _WithIndexingStatic, _WithNonDeliverableStatic, Protocol

Protocol to establish analytical sensitivity to rate type metrics for Static Period types.

Required methods

try_unindexed_reference_cashflow_analytic_delta(*)

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment and indexation, with lazy error raising.

Provided methods

try_reference_cashflow_analytic_delta(*[, ...])

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment but after indexation, with lazy error raising.

try_unindexed_cashflow_analytic_delta(*[, ...])

Calculate the cashflow analytic delta for the Static Period with settlement currency adjustment but without indexation, with lazy error raising.

try_cashflow_analytic_delta(*[, rate_curve, ...])

Calculate the cashflow for the Period with settlement currency adjustment and indexation.

try_immediate_local_analytic_delta(*[, ...])

Calculate the immediate, analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

try_local_analytic_delta(*[, rate_curve, ...])

Calculate the analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

analytic_delta(*[, rate_curve, index_curve, ...])

Calculate the analytic rate delta of the Period converted to any other base accounting currency.

Notes

Since this is analytical, each Period type must define its unique referenced sensitivity to interest rates. This protocol ultimately determines the quantity,

\[A^{bas}(m_f, m_s) = \frac{\partial P^{bas}(m_f, m_s)}{\partial \xi}, \quad \text{for some quantity, } \xi\]

Attributes Summary

index_params

The _IndexParams of the Period, if any.

is_indexed

Check whether the Period has indexation applied, which means it has index_params.

is_non_deliverable

Check whether the Period is non-deliverable, which means it has non_deliverable_params.

non_deliverable_params

The _NonDeliverableParams of the Period., if any.

settlement_params

The _SettlementParams of the Period.

Methods Summary

analytic_delta(*[, rate_curve, index_curve, ...])

Calculate the analytic rate delta of the Period converted to any other base accounting currency.

convert_deliverable(value, fx)

Apply settlement currency conversion to a Static Period using its non_deliverable_params.

index_up(value, index_curve)

Apply indexation to a Static Period value using its index_params.

try_cashflow_analytic_delta(*[, rate_curve, ...])

Calculate the cashflow for the Period with settlement currency adjustment and indexation.

try_convert_deliverable(value, fx)

Replicate convert_deliverable() with lazy exception handling.

try_immediate_local_analytic_delta(*[, ...])

Calculate the immediate, analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

try_index_up(value, index_curve)

Replicate index_up() with lazy exception handling.

try_local_analytic_delta(*[, rate_curve, ...])

Calculate the analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

try_reference_cashflow_analytic_delta(*[, ...])

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment but after indexation, with lazy error raising.

try_unindexed_cashflow_analytic_delta(*[, ...])

Calculate the cashflow analytic delta for the Static Period with settlement currency adjustment but without indexation, with lazy error raising.

try_unindexed_reference_cashflow_analytic_delta(*)

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment and indexation, with lazy error raising.

Attributes Documentation

index_params#

The _IndexParams of the Period, if any.

is_indexed#

Check whether the Period has indexation applied, which means it has index_params.

is_non_deliverable#

Check whether the Period is non-deliverable, which means it has non_deliverable_params.

non_deliverable_params#

The _NonDeliverableParams of the Period., if any.

settlement_params#

The _SettlementParams of the Period.

Methods Documentation

analytic_delta(*, 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 analytic rate delta 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:

\[A^{bas}(m_s, m_f) = f_{loc:bas}(m_f) A(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_analytic_delta().

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 FXForwards object used for forecasting the fx_fixing for deliverable cashflows, if necessary. Or, an 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.

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

  • local (bool, optional) – An override flag to return a dict of 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 the disc_curve.

Return type:

float, Dual, Dual2, Variable or dict

convert_deliverable(value, fx)#

Apply settlement currency conversion to a Static Period using its non_deliverable_params.

Parameters:
  • value (float, Dual, Dual2, Variable) – The possible value to apply settlement currency conversion to.

  • fx (FXForwards, optional) – The object used to forecast forward FX rates, if necessary.

Return type:

float, Dual, Dual2, Variable

index_up(value, index_curve)#

Apply indexation to a Static Period value using its index_params.

Parameters:
  • value (float, Dual, Dual2, Variable) – The possible value to apply indexation to.

  • index_curve (_BaseCurve, optional) – The index curve used to forecast index values, if necessary.

Return type:

float, Dual, Dual2, Variable

try_cashflow_analytic_delta(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank)#

Calculate the cashflow for the Period with settlement currency adjustment and indexation.

\[I_r f(m_d) \frac{\partial \mathbb{E^Q}[\bar{C}_t]}{\partial \xi}\]
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 FXForwards object used for forecasting the fx_fixing for deliverable cashflows, if necessary. Or, an 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:

Result[float, Dual, Dual2, Variable]

try_convert_deliverable(value, fx)#

Replicate convert_deliverable() with lazy exception handling.

Parameters:
  • value (Result[float, Dual, Dual2, Variable]) – The possible value to apply settlement currency conversion to.

  • fx (FXForwards, optional) – The object used to forecast forward FX rates, if necessary.

Return type:

Result[float, Dual, Dual2, Variable]

try_immediate_local_analytic_delta(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, fx_vol=NoInput.blank)#

Calculate the immediate, analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

This method does not adjust for ex-dividend and is an immediate measure according to,

\[A_0 = \frac{\partial P_0}{\partial \xi}, \quad \text{for some, } \xi\]
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 FXForward object used for forecasting the fx_fixing for 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:

Result[float, Dual, Dual2, Variable]

try_index_up(value, index_curve)#

Replicate index_up() with lazy exception handling.

Parameters:
  • value (Result[float, Dual, Dual2, Variable]) – The possible value to apply indexation to.

  • index_curve (_BaseCurve, optional) – The index curve used to forecast index values, if necessary.

Return type:

Result[float, Dual, Dual2, Variable]

try_local_analytic_delta(*, 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 analytic rate delta of a Period expressed in local settlement currency, with lazy error raising.

This method adjusts the immediate NPV for ex-dividend and forward projected value, according to,

\[\begin{split}A(m_s, m_f) = \mathbb{I}(m_s) \frac{1}{v(m_f)} A_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 FXForward object used for forecasting the fx_fixing for 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) – 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:

Result[float, Dual, Dual2, Variable]

try_reference_cashflow_analytic_delta(*, rate_curve=NoInput.blank, index_curve=NoInput.blank, disc_curve=NoInput.blank)#

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment but after indexation, with lazy error raising.

\[I_r \frac{\partial \mathbb{E^Q}[\bar{C}_t]}{\partial \xi}\]
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.

Return type:

Result[float, Dual, Dual2, Variable]

try_unindexed_cashflow_analytic_delta(*, rate_curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank)#

Calculate the cashflow analytic delta for the Static Period with settlement currency adjustment but without indexation, with lazy error raising.

\[f(m_d) \frac{\partial \mathbb{E^Q}[\bar{C}_t]}{\partial \xi}\]
Parameters:
  • rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.

  • disc_curve (_BaseCurve, optional) – Used to discount cashflows.

  • fx (FXForwards, optional) – The FXForwards object used for forecasting the fx_fixing for deliverable cashflows, if necessary. Or, an FXRates object purely for immediate currency conversion.

Return type:

Result[float, Dual, Dual2, Variable]

try_unindexed_reference_cashflow_analytic_delta(*, rate_curve=NoInput.blank, disc_curve=NoInput.blank)#

Calculate the cashflow analytic delta for the Static Period before settlement currency adjustment and indexation, with lazy error raising.

\[\frac{\partial \mathbb{E^Q}[\bar{C}_t]}{\partial \xi}\]
Parameters:
  • rate_curve (_BaseCurve or dict of such indexed by string tenor, optional) – Used to forecast floating period rates, if necessary.

  • disc_curve (_BaseCurve, optional) – Used to discount cashflows.

Return type:

Result[float, Dual, Dual2, Variable]