BondMixin#
- class rateslib.instruments.BondMixin#
Bases:
objectMethods 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
Curveor id or a list of such. A list defines the following curves in the order:Forecasting
Curveforleg1.Discounting
Curveforleg1.
solver (Solver, optional) – The numerical
Solverthat constructsCurvesfrom 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
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fx_rateis anFXRatesorFXForwardsobject.settlement (datetime, optional) – The settlement date of the security. If None adds the regular
settletime to the initial node date of the given discountcurves.
- 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
settlementis on or before the ex-div date.Some
calc_modeoptions return True ifsettlementis on the ex-div date.Ex-div dates are determined as measured by the number of
ex_divbusiness days prior to the unadjusted coupon end date.With an
ex_divof 1, asettlementthat occurs on the coupon payment date will be classified as ex-dividend and not receive that coupon.With an
ex_divof 0, asettlementthat 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:
Notes
Any intermediate (non ex-dividend) cashflows between
settlementandforward_settlementwill also be assumed to accrue atrepo_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
Curveor id or a list of such. A list defines the following curves in the order:Forecasting
Curveforleg1.Discounting
Curveforleg1.
solver (Solver, optional) – The numerical
Solverthat constructsCurvesfrom 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
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fxis anFXRatesorFXForwardsobject.local (bool, optional) – If True will ignore the
baserequest and return a dict identifying local currency NPV.
- Return type:
Notes
The
settlementdate of the bond is inferred from the objectssettledays parameter and the initial date of the suppliedcurves. 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
Curveor id or a list of such. A list defines the following curves in the order:Forecasting
Curveforleg1.Discounting
Curveforleg1.
solver (Solver, optional) – The numerical
Solverthat constructsCurvesfrom 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
FXRatesorFXForwardsobject, converts from local currency intobase.base (str, optional) – The base currency to convert cashflows into (3-digit code), set by default. Only used if
fxis anFXRatesorFXForwardsobject.price (float, Dual, Dual2) – The price of the bond to match.
dirty (bool) – Whether the price is given clean or dirty.
- Return type:
- 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:
Notes
Any intermediate (non ex-dividend) cashflows between
settlementandforward_settlementwill also be assumed to accrue atrepo_rate.