Installation¶
This guide covers how to install the UK Credit Risk RWA Calculator and its dependencies.
Requirements¶
- Python: 3.13 or higher
- Operating System: Windows, macOS, or Linux
- Package Manager: uv (recommended) or pip
Install from PyPI (Recommended)¶
The simplest way to install the calculator:
Optional Dependencies¶
The calculator provides several optional dependency groups:
| Extra | Description |
|---|---|
ui |
Interactive web UI via Marimo for exploration and testing |
dev |
Development tools (pytest, mypy, zensical, etc.) |
all |
All optional dependencies combined |
Recommended Installation
For most users, we recommend installing with ui for the interactive web interface:
Install from Source¶
For development or to get the latest unreleased changes, install from the GitHub repository.
Installation with uv (Recommended)¶
uv is the recommended package manager for this project due to its speed and reliability.
Install uv¶
Install the Calculator¶
# Clone the repository
git clone https://github.com/OpenAfterHours/rwa_calculator.git
cd rwa_calculator
# Install dependencies with uv
uv sync
# Install with development dependencies
uv sync --all-extras
# Download regulatory reference documents
uv run python scripts/download_docs.py
Installation with pip¶
If you prefer pip, you can install using:
# Clone the repository
git clone https://github.com/OpenAfterHours/rwa_calculator.git
cd rwa_calculator
# Create a virtual environment
python -m venv .venv
# Activate the virtual environment
# Windows:
.venv\Scripts\activate
# macOS/Linux:
source .venv/bin/activate
# Install in editable mode
pip install -e .
# Install with development dependencies
pip install -e ".[dev]"
Dependencies¶
Core Dependencies¶
| Package | Purpose |
|---|---|
polars |
High-performance DataFrame operations |
polars-normal-stats |
Statistical functions for IRB calculations (normal CDF/PPF) |
fastexcel |
Excel file reading (polars read_excel backend) |
xlsxwriter |
Excel file writing |
Optional Dependencies¶
| Package | Extra | Purpose |
|---|---|---|
marimo |
ui |
Interactive notebook UI |
uvicorn |
ui |
ASGI server for UI |
Development Dependencies¶
| Package | Purpose |
|---|---|
pytest |
Testing framework |
pytest-cov |
Test coverage reporting |
ruff |
Linting and formatting |
mypy |
Static type checking |
zensical |
Documentation generation |
mkdocstrings[python] |
API documentation |
marimo |
Interactive notebooks |
Verifying Installation¶
After installation, verify everything is working:
You should see output similar to:
========================= test session starts ==========================
collected 468 items
tests/contracts/test_bundles.py::TestRawDataBundle ...
...
========================= 448 passed, 20 skipped =======================
Project Structure¶
After installation, your project structure should look like:
rwa_calculator/
├── src/
│ └── rwa_calc/ # Main source code
│ ├── config/ # Configuration (FX rates)
│ ├── contracts/ # Interfaces and data contracts
│ ├── data/ # Schemas and regulatory tables
│ ├── domain/ # Core domain enums
│ └── engine/ # Calculation engines
├── tests/ # Test suite
├── workbooks/ # Reference implementations
├── docs/assets/ # Regulatory documents (run scripts/download_docs.py)
├── docs/ # This documentation
├── pyproject.toml # Project configuration
└── zensical.toml # Documentation configuration
Environment Variables¶
The calculator uses sensible defaults, but you can configure:
| Variable | Description | Default |
|---|---|---|
RWA_DATA_PATH |
Default path for input data | ./data |
RWA_OUTPUT_PATH |
Default path for output files | ./output |
IDE Setup¶
VS Code¶
Install recommended extensions:
PyCharm¶
- Open the project directory
- Configure the Python interpreter to use the virtual environment
- Mark
srcas a Sources Root
Troubleshooting¶
Common Issues¶
Python version mismatch
# Check your Python version
python --version
# Ensure it's 3.13 or higher
# If not, install Python 3.13+ from python.org
Import errors
# Ensure the package is installed in editable mode
uv pip install -e .
# Or verify PYTHONPATH includes src/
export PYTHONPATH="${PYTHONPATH}:./src"
Polars installation issues
Next Steps¶
- Quick Start Guide - Run your first calculation
- Concepts - Understand the key terminology