Basel 3.1 Credit Risk RWA Calculator compliant with PRA PS9/24
Project description
This package is still in development and is not production ready
UK Credit Risk RWA Calculator
A high-performance Risk-Weighted Assets (RWA) calculator for UK credit risk, supporting both current regulations and future Basel 3.1 implementation. Built with Python using Polars for vectorized performance.
Documentation: https://OpenAfterHours.github.io/rwa_calculator/
Installation
# Install from PyPI
pip install rwa-calc
# Or with uv
uv add rwa-calc
# With UI support (web-based calculator interface)
pip install rwa-calc[ui]
Optional Dependencies
| Extra | Description |
|---|---|
ui |
Interactive web UI via Marimo |
dev |
Development tools (pytest, mypy, zensical) |
all |
All optional dependencies |
Quick Start
from datetime import date
from rwa_calc.api import CreditRiskCalc
response = CreditRiskCalc(
data_path="/path/to/data",
framework="CRR",
reporting_date=date(2026, 12, 31),
permission_mode="irb",
).calculate()
if response.success:
print(f"Total RWA: {response.summary.total_rwa:,.0f}")
df = response.collect_results()
IRB Mode — set permission_mode="irb" and provide a model_permissions input table
to route exposures to FIRB, AIRB, or slotting based on per-model approvals. Exposures
without a matching model permission fall back to SA. See the
Data Model docs
for the model permissions schema.
Interactive UI — web-based calculator interface:
pip install rwa-calc[ui]
rwa-calc-ui
# Open http://localhost:8000 in your browser
Regulatory Scope
This calculator supports two regulatory regimes:
| Regime | Effective Period | UK Implementation | Status |
|---|---|---|---|
| CRR (Basel 3.0) | Until 31 December 2026 | UK CRR (EU 575/2013 as onshored) | Active |
| Basel 3.1 | From 1 January 2027 | PRA PS1/26 | Active Development |
A configuration toggle allows switching between calculation modes for:
- Current regulatory reporting under UK CRR
- Impact analysis and parallel running ahead of Basel 3.1 go-live
- Seamless transition when Basel 3.1 becomes effective
Key Features
- Dual-Framework Support: Single codebase for CRR and Basel 3.1 with UK-specific deviations
- High Performance: Polars LazyFrames for vectorized calculations (50-100x improvement over row iteration)
- Complete Coverage: Standardised (SA), IRB (F-IRB & A-IRB), and Slotting approaches
- Credit Risk Mitigation: Collateral, guarantees, and provisions with RWA-optimized allocation
- Complex Hierarchies: Multi-level counterparty and facility hierarchy support
- Audit Trail: Full calculation transparency for regulatory review
- Framework Comparison: Side-by-side CRR vs Basel 3.1 impact analysis
- COREP Output: Export results to COREP regulatory templates
- Multiple Export Formats: Parquet, CSV, Excel, and COREP
Supported Approaches
| Approach | Description |
|---|---|
| Standardised (SA) | Risk weights based on external ratings and exposure characteristics |
| Foundation IRB (F-IRB) | Bank-estimated PD, supervisory LGD |
| Advanced IRB (A-IRB) | Bank-estimated PD, LGD, and EAD |
| Slotting | Category-based approach for specialised lending |
Supported Exposure Classes
Sovereign, Institution, Corporate, Corporate SME, Retail Mortgage, Retail QRRE, Retail Other, Specialised Lending, Equity
Documentation
Comprehensive documentation is available at OpenAfterHours.github.io/rwa_calculator
| Section | Description |
|---|---|
| Getting Started | Installation and first calculation |
| User Guide | Regulatory frameworks, methodology, exposure classes |
| Architecture | System design and pipeline |
| Data Model | Input schemas and validation |
| API Reference | Complete technical documentation |
| Development | Testing, benchmarks, contributing |
| Plans | Development roadmap and status |
Running Tests
# Run all tests
uv run pytest -v
# Run with coverage
uv run pytest --cov=src/rwa_calc
# Run benchmarks (10K + 100K, excludes 1M/10M)
uv run pytest tests/benchmarks/ -m "benchmark and not slow" -k "not 1m" -o "addopts=" --benchmark-only -v
Test Results: ~1,915 tests (1,485 unit + 275 acceptance + 123 contract + ~30 benchmark)
License
References
Current Regulations (CRR / Basel 3.0)
Basel 3.1 Implementation (January 2027)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rwa_calc-0.1.63.tar.gz.
File metadata
- Download URL: rwa_calc-0.1.63.tar.gz
- Upload date:
- Size: 1.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ec212c9796eb9f605bfad5517069310f1eb1c5125949e8afc3471728cf1df516
|
|
| MD5 |
4eb1579ee5ebb0f49f0e611097489ed7
|
|
| BLAKE2b-256 |
622f2b880cad15e721c99749b9e708dd5cba67af366d66376c3b6d42cbfb1bed
|
Provenance
The following attestation bundles were made for rwa_calc-0.1.63.tar.gz:
Publisher:
publish.yml on OpenAfterHours/rwa_calculator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rwa_calc-0.1.63.tar.gz -
Subject digest:
ec212c9796eb9f605bfad5517069310f1eb1c5125949e8afc3471728cf1df516 - Sigstore transparency entry: 1340561370
- Sigstore integration time:
-
Permalink:
OpenAfterHours/rwa_calculator@bc728e3103685a1fbdb519bd0121cc0e92f6faf6 -
Branch / Tag:
refs/tags/0.1.63 - Owner: https://github.com/OpenAfterHours
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc728e3103685a1fbdb519bd0121cc0e92f6faf6 -
Trigger Event:
release
-
Statement type:
File details
Details for the file rwa_calc-0.1.63-py3-none-any.whl.
File metadata
- Download URL: rwa_calc-0.1.63-py3-none-any.whl
- Upload date:
- Size: 437.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057b32a371c9ac997a84f264a5f6bb07e366584f99ed396a3f32924a508206e1
|
|
| MD5 |
5d45c87460b60313bf7bc092e79808a6
|
|
| BLAKE2b-256 |
bdd4f9fafb2eae47d23bd160574e80c7a73dafbe7613bf6c6d4e66ea3eb458d6
|
Provenance
The following attestation bundles were made for rwa_calc-0.1.63-py3-none-any.whl:
Publisher:
publish.yml on OpenAfterHours/rwa_calculator
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
rwa_calc-0.1.63-py3-none-any.whl -
Subject digest:
057b32a371c9ac997a84f264a5f6bb07e366584f99ed396a3f32924a508206e1 - Sigstore transparency entry: 1340561372
- Sigstore integration time:
-
Permalink:
OpenAfterHours/rwa_calculator@bc728e3103685a1fbdb519bd0121cc0e92f6faf6 -
Branch / Tag:
refs/tags/0.1.63 - Owner: https://github.com/OpenAfterHours
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@bc728e3103685a1fbdb519bd0121cc0e92f6faf6 -
Trigger Event:
release
-
Statement type: