API Reference¶
The public facade lives at the top level of the package.
wayfault.estimate_wwr ¶
estimate_wwr(exposure: ExposureSource, credit: CreditCurveSource, model: DependenceModel, discount: ndarray | None = None, pfe_quantile: float = 0.95, sink: ResultSink | None = None) -> WWRResult
Estimate Wrong-Way Risk for one counterparty.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exposure
|
ExposureSource
|
The outbound-port collaborators. |
required |
credit
|
ExposureSource
|
The outbound-port collaborators. |
required |
model
|
ExposureSource
|
The outbound-port collaborators. |
required |
discount
|
ndarray | None
|
Optional discount factors on the grid. |
None
|
pfe_quantile
|
float
|
Quantile for the PFE profile. |
0.95
|
sink
|
ResultSink | None
|
Optional result sink; if given, the result is also written to it. |
None
|
Returns:
| Type | Description |
|---|---|
WWRResult
|
The full result object. |
Source code in src/wayfault/adapters/inbound/api.py
wayfault.WWRResult
dataclass
¶
WWRResult(baseline_cva: float, wwr_cva: float, alpha: float, classification: WWRClass, tenors: ndarray, epe: ndarray, conditional_ee: ndarray, pfe: ndarray, eepe: float, ead: float, uplift_pct: float, ee_ratio: ndarray, ee_hazard_corr: float, model: str, params: dict[str, float] = dict())
Outputs of a WWR estimation.
Attributes:
| Name | Type | Description |
|---|---|---|
baseline_cva, wwr_cva, alpha |
The independent CVA, the WWR-adjusted CVA, and their ratio. |
|
classification |
WWRClass
|
WWR / RWR / NEUTRAL label. |
tenors |
ndarray
|
The tenor grid year-fractions (x-axis for the per-tenor profiles). |
epe, conditional_ee, pfe |
Per-tenor profiles (numpy arrays). |
|
eepe |
float
|
Effective EPE scalar. |
ead |
float
|
|
uplift_pct, ee_ratio, ee_hazard_corr |
Diagnostics. |
|
model, params |
Metadata about the dependence model used. |
to_dict ¶
Return a JSON-serialisable dictionary representation.
Source code in src/wayfault/application/dto.py
wayfault.WWRRequest
dataclass
¶
WWRRequest(exposure: ExposureSource, credit: CreditCurveSource, model: DependenceModel, discount: ndarray | None = None, pfe_quantile: float = 0.95)
Inputs for a WWR estimation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exposure
|
ExposureSource
|
Port supplying the exposure cube. |
required |
credit
|
CreditCurveSource
|
Port supplying the credit curve. |
required |
model
|
DependenceModel
|
The dependence model to apply. |
required |
discount
|
ndarray | None
|
Optional discount factors on the grid (defaults to 1.0). |
None
|
pfe_quantile
|
float
|
Quantile used for the PFE profile. |
0.95
|
wayfault.WWRClass ¶
Bases: StrEnum
Classification of the dependence direction.
Errors¶
wayfault.WayfaultError ¶
Bases: Exception
Base class for all :mod:wayfault errors.
wayfault.ValidationError ¶
Bases: WayfaultError
Raised when a value object fails its construction-time invariants.
wayfault.MissingDependencyError ¶
Bases: WayfaultError
Raised when an optional adapter is used without its extra installed.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
package
|
str
|
The importable package that was missing (e.g. |
required |
extra
|
str
|
The :mod: |
required |
Source code in src/wayfault/domain/errors.py
Browse the layers:
- Domain — pure value objects and functions.
- Application — service and DTOs.
- Ports — Protocol definitions.
- Adapters — concrete implementations.