Credit Instruments

Bonds

class rivapy.instruments.bond_specifications.ZeroCouponBondSpecification(obj_id: str, issue_date: date | datetime, maturity_date: date | datetime, currency: str = 'EUR', notional: float = 100.0, issuer: str = None, securitization_level: SecuritizationLevel | str = None, rating: Rating | str = Rating.NONE)[source]

Zero coupon bond specification.

Parameters:
  • obj_id (str) – (Preferably) Unique label of the bond, e.g. ISIN.

  • issue_date (_Union[date, datetime]) – Date of bond issuance.

  • maturity_date (_Union[date, datetime]) – Bond’s maturity/expiry date. Must lie after the issue_date.

  • currency (str, optional) – Currency as alphabetic, Defaults to ‘EUR’.

  • notional (float, optional) – Bond’s notional/face value. Must be positive. Defaults to 100.0.

  • issuer (str, optional) – Name/id of issuer. Defaults to None.

  • securitization_level (_Union[SecuritizationLevel, str], optional) – Securitization level. Defaults to None.

  • rating (_Union[Rating, str]) – Paper rating.

static _create_sample(n_samples: int, seed: int = None, ref_date=None, issuers: List[str] = None, sec_levels: List[str] = None, currencies: List[str] = None)[source]
expected_cashflows() List[Tuple[datetime, float]][source]

Return a list of all expected cashflows (here only the final notional) together with their payment date.

Returns:

The resulting list of all cashflows.

Return type:

_List[Tuple[datetime, float]]

class rivapy.instruments.bond_specifications.PlainVanillaCouponBondSpecification(obj_id: str, issue_date: date | datetime, maturity_date: date | datetime, accrual_start: date | datetime, coupon_freq: str, coupon: float, currency: str = 'EUR', notional: float = 100.0, issuer: str = None, securitization_level: SecuritizationLevel | str = None, stub: bool = True, rating: Rating | str = Rating.NONE)[source]

PlainVanillaCouponBond specification.

Parameters:
  • obj_id (str) – (Preferably) Unique label of the bond, e.g. ISIN.

  • issue_date (_Union[date, datetime]) – Date of bond issuance.

  • maturity_date (_Union[date, datetime]) – Bond’s maturity/expiry date. Must lie after the issue_date.

  • first_coupondate (_Union[date, datetime]) – The first coupon date.

  • coupon_freq (str) – Frequency of coupons. Defaults to ‘1Y’ for yearly. Internally, the method rivapy.tools.Period.from_string() is used, see the definition of valid strings there.

  • coupon (float) – Coupon as relative number (multiplied internaly by notional to get absolute cashflow).

  • currency (str, optional) – Currency as alphabetic, Defaults to ‘EUR’.

  • notional (float, optional) – Bond’s notional/face value. Must be positive. Defaults to 100.0.

  • issuer (str, optional) – Name/id of issuer. Defaults to None.

  • securitization_level (_Union[SecuritizationLevel, str], optional) – Securitization level. Defaults to None.

  • rating (_Union[Rating, str]) – Paper rating.

static _create_sample(n_samples: int, seed: int = None, ref_date=None, issuers: List[str] = None, sec_levels: List[str] = None, currencies: List[str] = None)[source]
expected_cashflows() List[Tuple[datetime, float]][source]

Return a list of all expected cashflows (final notional and coupons) together with their payment date.

Returns:

The resulting list of all cashflows.

Return type:

_List[Tuple[datetime, float]]

Credit Default Swaps

class rivapy.instruments.cds_specification.CDSSpecification(premium: float, premium_pay_dates: List[datetime], protection_start: datetime, notional: float = 1.0, expiry: datetime = None, recovery: float = None, issuer: str = '', cash_settled: bool = True)[source]

Bases: object

Constructor for credit default swap

Parameters:
  • premium (float) – The premium as fraction of notional paid at each premium date.

  • premium_pay_dates (List[datetime]) – List of dates for premium payments.

  • protection_start (datetime) – Date when protection starts

  • notional (foat) – Notional

  • expiry (datetime, optional) – [description]. Defaults to None.

  • recovery (float, optional) – The protection is only paid for the real loss (notional minus recovery). If recovery is not specified, it is assumed that recovery as specified in contract. If no fixed recovery is specified[description]. Defaults to None.

  • issuer (str, optional) – [description]. Defaults to ‘’.

  • cash_settled (bool, optional) – Flag indicating o instrument is physical settled (the protection buyer )

validate()[source]

Some simple validation