base
Base classes and enumerations for financial instruments in the core domain model.
Classes:
-
BalanceSheetCategory–Enumeration for the category of the balance sheet an instrument is on.
-
BookType–Enumeration for different types of books.
-
CompositeInstrument–Composite class for financial instruments.
-
CreditRating–Enumeration of S&P credit ratings.
-
Instrument–Abstract base class for financial instruments.
-
Issuer–Class representing an issuer of financial instruments.
-
IssuerType–Enumeration of issuer types.
BalanceSheetCategory
Bases: Enum
Enumeration for the category of the balance sheet an instrument is on.
BookType
Bases: Enum
Enumeration for different types of books.
Before a bank can calculate RWA for credit risk and RWA for market risk, it must follow the requirements of RBC25 to identify the instruments that are in the trading book. The banking book comprises all instruments that are not in the trading book and all other assets of the bank.
CompositeInstrument
CompositeInstrument(
name: str = "",
book_type: BookType | None = None,
credit_rating: CreditRating | None = None,
issuer: Issuer | None = None,
parent: Instrument | None = None,
)
Bases: Instrument
Composite class for financial instruments.
This class allows for the aggregation of multiple financial instruments into a single composite instrument. It can be used to represent a collection of assets, liabilities, or equities for a bank.
Methods:
-
accept–Accept a visitor by delegating to all contained instruments.
-
add–Add an instrument to the composite.
-
is_composite–Check if the instrument is composite.
-
remove–Remove an instrument from the composite.
-
repricing_date–Return the next repricing date for variable-rate instruments.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
issuer(Issuer) –Get the instrument's issuer.
-
parent(Instrument | None) –Get the parent instrument.
accept
accept(visitor: Visitor) -> None
Accept a visitor by delegating to all contained instruments.
is_composite
is_composite() -> bool
Check if the instrument is composite.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
CreditRating
Bases: Enum
Enumeration of S&P credit ratings.
Methods:
-
is_investment_grade–Check if the credit rating is investment grade.
-
to_str–Get a custom string representation of the credit rating.
is_investment_grade
is_investment_grade() -> bool
Check if the credit rating is investment grade.
to_str
to_str() -> str
Get a custom string representation of the credit rating.
Instrument
Instrument(
name: str = "",
book_type: BookType | None = None,
credit_rating: CreditRating | None = None,
issuer: Issuer | None = None,
parent: Instrument | None = None,
measurement_basis: MeasurementBasis | None = None,
repricing_frequency: Period | None = None,
)
Bases: ABC
Abstract base class for financial instruments.
Subclasses declare applicable_rules — a frozenset of rule classes
that the :class:RuleEngine should evaluate for positions holding this
instrument. The default is an empty set (no rules apply).
Methods:
-
accept–Accept a visitor.
-
is_composite–Check if the instrument is composite.
-
repricing_date–Return the next repricing date for variable-rate instruments.
Attributes:
-
book_type(BookType | None) –Get the book type of the instrument.
-
credit_rating(CreditRating) –Get the instrument's credit rating.
-
issuer(Issuer) –Get the instrument's issuer.
-
parent(Instrument | None) –Get the parent instrument.
is_composite
is_composite() -> bool
Check if the instrument is composite.
repricing_date
repricing_date(as_of: date) -> date | None
Return the next repricing date for variable-rate instruments.
Returns None for fixed-rate instruments (repricing_frequency is None).
Issuer
Issuer(
name: str,
issuer_type: IssuerType,
credit_rating: CreditRating | None = None,
)
Class representing an issuer of financial instruments.
Methods:
-
is_bank–Check if the issuer is depositary institution or bank.
-
is_corporate–Check if the issuer is corporate.
-
is_individual–Check if the issuer is individual.
-
is_mdb–Check if the issuer is multilateral development bank (MDB).
-
is_pse–Check if the issuer is public sector entity (PSE).
-
is_securities_firm–Check if the issuer is securities firm.
-
is_sme–Check if the issuer is SME corporate.
-
is_sovereign–Check if the issuer is sovereign.
Attributes:
-
credit_rating(CreditRating) –Get the issuer's credit rating.
is_bank
is_bank() -> bool
Check if the issuer is depositary institution or bank.
is_corporate
is_corporate() -> bool
Check if the issuer is corporate.
is_individual
is_individual() -> bool
Check if the issuer is individual.
is_mdb
is_mdb() -> bool
Check if the issuer is multilateral development bank (MDB).
is_pse
is_pse() -> bool
Check if the issuer is public sector entity (PSE).
is_securities_firm
is_securities_firm() -> bool
Check if the issuer is securities firm.
is_sme
is_sme() -> bool
Check if the issuer is SME corporate.
is_sovereign
is_sovereign() -> bool
Check if the issuer is sovereign.
IssuerType
Bases: Flag
Enumeration of issuer types.
Methods:
-
to_str–Get a custom string representation of the issuer type.
to_str
to_str() -> str
Get a custom string representation of the issuer type.