Skip to main content

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

Documentation

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, mkdocs)
all All optional dependencies

Quick Start

Option 1: Interactive UI

pip install rwa-calc[ui]
rwa-calc-ui
# Open http://localhost:8000 in your browser

Option 2: Python API

from datetime import date
from rwa_calc.engine.pipeline import create_pipeline
from rwa_calc.contracts.config import CalculationConfig

config = CalculationConfig.crr(reporting_date=date(2026, 12, 31))
pipeline = create_pipeline()
result = pipeline.run(config)

print(f"Total RWA: {result.total_rwa:,.2f}")

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 Development
Basel 3.1 From 1 January 2027 PRA PS9/24 Planned

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

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
uv run pytest tests/benchmarks/ -v

Test Results: 826 passed, 4 skipped

License

Apache-2.0 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

rwa_calc-0.1.13.tar.gz (729.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

rwa_calc-0.1.13-py3-none-any.whl (200.7 kB view details)

Uploaded Python 3

File details

Details for the file rwa_calc-0.1.13.tar.gz.

File metadata

  • Download URL: rwa_calc-0.1.13.tar.gz
  • Upload date:
  • Size: 729.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rwa_calc-0.1.13.tar.gz
Algorithm Hash digest
SHA256 28fe61d7a23475c170a6d5fc19c9861f19163243b189231cc193e6de23b32a48
MD5 db9c4fd5bb4cd0077d7a342c9bd3fb1e
BLAKE2b-256 6e4bec45efe050fa033e6e5b95aa3b7a02ce271ce95b55bfb631e70291d03c98

See more details on using hashes here.

File details

Details for the file rwa_calc-0.1.13-py3-none-any.whl.

File metadata

  • Download URL: rwa_calc-0.1.13-py3-none-any.whl
  • Upload date:
  • Size: 200.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for rwa_calc-0.1.13-py3-none-any.whl
Algorithm Hash digest
SHA256 b632d397c325f4b7ee85daec4eb67fa1f838a866b49c94dcbe1692e71671cc10
MD5 5c5b9fa249616d04f147c957a2682208
BLAKE2b-256 8c11a6f4644b59c211a5a12c220aa62e8d61b4a048a147133d12353b4b77d8fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page