Core API¶
creditriskengine.core.types
¶
Core type definitions for the credit risk engine.
All enums map directly to regulatory classifications from BCBS d424 (Basel III final reforms, December 2017).
Jurisdiction
¶
Bases: StrEnum
Supported regulatory jurisdictions.
Source code in creditriskengine\core\types.py
CreditRiskApproach
¶
Bases: StrEnum
Credit risk capital calculation approach.
Reference: BCBS d424, CRE20 (SA), CRE30-36 (IRB).
Source code in creditriskengine\core\types.py
IRBAssetClass
¶
IRBCorporateSubClass
¶
Bases: StrEnum
Corporate sub-classes per BCBS CRE30.5-30.9.
Source code in creditriskengine\core\types.py
IRBSpecialisedLendingType
¶
Bases: StrEnum
Specialised lending categories per BCBS CRE30.7.
Source code in creditriskengine\core\types.py
IRBRetailSubClass
¶
Bases: StrEnum
Retail sub-classes per BCBS CRE30.11-30.15.
Source code in creditriskengine\core\types.py
SAExposureClass
¶
Bases: StrEnum
Standardized approach exposure classes per BCBS CRE20.
Source code in creditriskengine\core\types.py
CreditQualityStep
¶
Bases: int, Enum
Credit quality steps for SA risk weight mapping.
Maps external ratings to standardized risk weight buckets. CQS 1 = AAA/AA-, CQS 2 = A+/A-, etc. Reference: BCBS d424, CRE20 Table 1-10.
Source code in creditriskengine\core\types.py
IFRS9Stage
¶
DefaultDefinition
¶
Bases: StrEnum
Default definition frameworks.
Source code in creditriskengine\core\types.py
CollateralType
¶
Bases: StrEnum
Eligible collateral types per BCBS CRE22.
Source code in creditriskengine\core\types.py
CRMApproach
¶
Bases: StrEnum
Credit risk mitigation approaches per BCBS CRE22.
Source code in creditriskengine\core\types.py
creditriskengine.core.exposure
¶
Exposure and facility data models.
Data models represent the minimum set of attributes required for regulatory capital calculation under both SA and IRB approaches.
Collateral
¶
Bases: BaseModel
Collateral pledged against an exposure.
Source code in creditriskengine\core\exposure.py
Exposure
¶
Bases: BaseModel
Single credit exposure / facility for capital calculation.
Contains all fields needed for SA, F-IRB, and A-IRB RWA computation, IFRS 9/CECL ECL calculation, and model validation.
Source code in creditriskengine\core\exposure.py
pd_floor_check(v)
classmethod
¶
Validate PD is between 0 and 1 (inclusive).
Note: The Basel III PD floor of 0.03% (CRE32.13) is enforced at the
IRB calculation level (rwa.irb.formulas), not at the data model
level, because SA and ECL workflows accept PDs below the IRB floor.
Source code in creditriskengine\core\exposure.py
creditriskengine.core.portfolio
¶
Portfolio container for credit exposures.
Portfolio
¶
Bases: BaseModel
Container for a portfolio of credit exposures.
Provides iteration, filtering, and aggregation over exposures.
Source code in creditriskengine\core\portfolio.py
creditriskengine.core.exceptions
¶
Custom exception hierarchy for creditriskengine.
CreditRiskEngineError
¶
ConfigurationError
¶
Bases: CreditRiskEngineError
Raised when configuration is invalid or missing.
JurisdictionError
¶
Bases: CreditRiskEngineError
Raised when jurisdiction-specific config is not found.
ValidationError
¶
Bases: CreditRiskEngineError
Raised when input validation fails.
RegulatoryError
¶
Bases: CreditRiskEngineError
Raised when regulatory constraints are violated.
CalculationError
¶
Bases: CreditRiskEngineError
Raised when a calculation fails or produces invalid results.
DataError
¶
Bases: CreditRiskEngineError
Raised when input data is malformed or insufficient.