BondMixin#

class rateslib.instruments.BondMixin#

Bases: object

Methods Summary

analytic_delta([curve, disc_curve, fx, base])

Return the analytic delta of the security via summing all periods.

cashflows([curves, solver, fx, base, settlement])

Return the properties of the security used in calculating cashflows.

ex_div(settlement)

Return a boolean whether the security is ex-div at the given settlement.

fwd_from_repo(price, settlement, ...[, ...])

Return a forward price implied by a given repo rate.

npv([curves, solver, fx, base, local])

Return the NPV of the security by summing cashflow valuations.

oaspread([curves, solver, fx, base, price, ...])

The option adjusted spread added to the discounting Curve to value the security at price.

repo_from_fwd(price, settlement, ...[, ...])

Return an implied repo rate from a forward price.

Methods Documentation

analytic_delta(curve=NoInput.blank, disc_curve=NoInput.blank, fx=NoInput.blank, base=NoInput.blank)#

Return the analytic delta of the security via summing all periods.

For arguments see analytic_delta().

cashflows(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, settlement=NoInput.blank)#

Return the properties of the security used in calculating cashflows.

Parameters:
  • curves (Curve, str or list of such) –

    A single Curve or id or a list of such. A list defines the following curves in the order:

    • Forecasting Curve for leg1.

    • Discounting Curve for leg1.

  • solver (Solver, optional) – The numerical Solver that constructs Curves from calibrating instruments.

  • fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a FXRates or FXForwards object, converts from local currency into base.

  • base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if fx_rate is an FXRates or FXForwards object.

  • settlement (datetime, optional) – The settlement date of the security. If None adds the regular settle time to the initial node date of the given discount curves.

Return type:

DataFrame

ex_div(settlement)#

Return a boolean whether the security is ex-div at the given settlement.

Parameters:

settlement (datetime) – The settlement date to test.

Return type:

bool

Notes

By default uses the UK DMO convention of returning False if settlement is on or before the ex-div date.

Some calc_mode options return True if settlement is on the ex-div date.

Ex-div dates are determined as measured by the number of ex_div business days prior to the unadjusted coupon end date.

With an ex_div of 1, a settlement that occurs on the coupon payment date will be classified as ex-dividend and not receive that coupon.

With an ex_div of 0, a settlement that occurs on the coupon payment date will not be classified as ex-dividend and will receive that coupon (in the default calculation mode).

fwd_from_repo(price, settlement, forward_settlement, repo_rate, convention=NoInput.blank, dirty=False, method='proceeds')#

Return a forward price implied by a given repo rate.

Parameters:
  • price (float, Dual, or Dual2) – The initial price of the security at settlement.

  • settlement (datetime) – The settlement date of the bond

  • forward_settlement (datetime) – The forward date for which to calculate the forward price.

  • repo_rate (float, Dual or Dual2) – The rate which is used to calculate values.

  • convention (str, optional) – The day count convention applied to the rate. If not given uses default values.

  • dirty (bool, optional) – Whether the input and output price are specified including accrued interest.

  • method (str in {"proceeds", "compounded"}, optional) – The method for determining the forward price.

Return type:

float, Dual or Dual2

Notes

Any intermediate (non ex-dividend) cashflows between settlement and forward_settlement will also be assumed to accrue at repo_rate.

npv(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, local=False)#

Return the NPV of the security by summing cashflow valuations.

Parameters:
  • curves (Curve, str or list of such) –

    A single Curve or id or a list of such. A list defines the following curves in the order:

    • Forecasting Curve for leg1.

    • Discounting Curve for leg1.

  • solver (Solver, optional) – The numerical Solver that constructs Curves from calibrating instruments.

  • fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a FXRates or FXForwards object, converts from local currency into base.

  • base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if fx is an FXRates or FXForwards object.

  • local (bool, optional) – If True will ignore the base request and return a dict identifying local currency NPV.

Return type:

float, Dual, Dual2 or dict of such

Notes

The settlement date of the bond is inferred from the objects settle days parameter and the initial date of the supplied curves. The NPV returned is for immediate settlement.

If only one curve is given this is used as all four curves.

If two curves are given the forecasting curve is used as the forecasting curve on both legs and the discounting curve is used as the discounting curve for both legs.

oaspread(curves=NoInput.blank, solver=NoInput.blank, fx=NoInput.blank, base=NoInput.blank, price=NoInput.blank, dirty=False)#

The option adjusted spread added to the discounting Curve to value the security at price.

Parameters:
  • curves (Curve, str or list of such) –

    A single Curve or id or a list of such. A list defines the following curves in the order:

    • Forecasting Curve for leg1.

    • Discounting Curve for leg1.

  • solver (Solver, optional) – The numerical Solver that constructs Curves from calibrating instruments.

  • fx (float, FXRates, FXForwards, optional) – The immediate settlement FX rate that will be used to convert values into another currency. A given float is used directly. If giving a FXRates or FXForwards object, converts from local currency into base.

  • base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if fx is an FXRates or FXForwards object.

  • price (float, Dual, Dual2) – The price of the bond to match.

  • dirty (bool) – Whether the price is given clean or dirty.

Return type:

float, Dual, Dual2

repo_from_fwd(price, settlement, forward_settlement, forward_price, convention=NoInput.blank, dirty=False)#

Return an implied repo rate from a forward price.

Parameters:
  • price (float, Dual, or Dual2) – The initial price of the security at settlement.

  • settlement (datetime) – The settlement date of the bond

  • forward_settlement (datetime) – The forward date for which to calculate the forward price.

  • forward_price (float, Dual or Dual2) – The forward price which iplies the repo rate

  • convention (str, optional) – The day count convention applied to the rate. If not given uses default values.

  • dirty (bool, optional) – Whether the input and output price are specified including accrued interest.

Return type:

float, Dual or Dual2

Notes

Any intermediate (non ex-dividend) cashflows between settlement and forward_settlement will also be assumed to accrue at repo_rate.