Balancing Risk-Weighted Assets
Capital allocation is one of the most critical challenges facing banks and financial institutions. Regulators require banks to hold sufficient capital against their risk-weighted assets (RWA), while shareholders demand maximum returns. How do you find the sweet spot? Let’s solve this with a concrete example using Python.
The Problem
Consider a bank with €500 billion in total capital that must allocate across 5 business lines:
| Business Line | Expected Return | Risk Weight | Min Allocation | Max Allocation |
|---|---|---|---|---|
| Retail Banking | 8% | 35% | €30B | €150B |
| Corporate Lending | 12% | 100% | €20B | €120B |
| Trading | 18% | 200% | €10B | €80B |
| Mortgages | 6% | 50% | €40B | €200B |
| SME Lending | 14% | 75% | €15B | €100B |
Regulatory constraint (Basel III): Total Risk-Weighted Assets must not exceed €400 billion, and the Capital Adequacy Ratio (CAR) must be ≥ 8%.
Mathematical Formulation
Let $x_i$ be the capital allocated to business line $i$.
Objective — Maximize total return:
$$\max \sum_{i=1}^{n} r_i \cdot x_i$$
Subject to:
$$\sum_{i=1}^{n} x_i = C_{\text{total}} \quad \text{(total capital constraint)}$$
$$\sum_{i=1}^{n} w_i \cdot x_i \leq \text{RWA}_{\max} \quad \text{(RWA constraint)}$$
$$\frac{C_{\text{total}}}{\sum_{i=1}^{n} w_i \cdot x_i} \geq \text{CAR}_{\min} \quad \text{(Capital Adequacy Ratio)}$$
$$x_i^{\min} \leq x_i \leq x_i^{\max} \quad \text{(business line bounds)}$$
Return on Risk-Weighted Assets (RoRWA):
$$\text{RoRWA}_i = \frac{r_i}{w_i}$$
This is the key efficiency metric — return per unit of regulatory capital consumed.
Python Solution
1 | # ============================================================ |
Code Walkthrough
Section 1 — Parameters
All five business lines are defined with their return rates, Basel III risk weights, and regulatory floor/ceiling allocations. The RoRWA (Return on Risk-Weighted Assets) is computed upfront:
$$\text{RoRWA}_i = \frac{r_i}{w_i}$$
This single number tells you how efficiently each euro of RWA generates profit — the bank’s true efficiency compass.
Section 2 — Linear Programming
We use SciPy’s linprog with the HiGHS solver (the fastest open-source LP engine available in SciPy ≥ 1.7). The problem is a classic bounded LP:
- Objective: maximise $\sum r_i x_i$ (negated because
linprogminimises) - Inequality: $\sum w_i x_i \leq 400$ (RWA ceiling)
- Equality: $\sum x_i = 500$ (all capital must be deployed)
- Bounds: $x_i^{\min} \leq x_i \leq x_i^{\max}$
HiGHS solves this in microseconds even at institutional scale.
Section 3 — Efficient Frontier
We sweep the RWA ceiling from €200B to €400B in 60 steps, resolving the LP at each point. This traces the efficient frontier — the maximum achievable return for each level of regulatory tolerance. This is the capital-allocation analogue of the Markowitz frontier.
Section 4 — Sensitivity Analysis
A broader sweep (€150B–€500B) answers the key management question: “What do we gain if regulators relax the RWA ceiling by €10B?” — the slope of this curve is the shadow price of the RWA constraint.
Section 5 — 3D Surface
A 30×30 parameter grid varies both RWA ceiling and total capital simultaneously, solving an LP at each of the 900 grid points. The result is a response surface showing how management levers interact. Note that bounds are rescaled proportionally when total capital changes to keep the problem feasible.
Chart-by-Chart Interpretation
(A) Optimal Capital Allocation
The optimizer pushes Trading to its maximum cap (€80B) because it has the highest absolute return (18%), despite its heavy 200% risk weight. Mortgages absorbs the bulk of remaining capital (€200B) because its 50% risk weight makes it highly RWA-efficient. Retail Banking and Corporate Lending are assigned their minimum floors — they lose the RoRWA competition.
(B) Return vs. RWA Contribution
The hatched bars (RWA consumed) versus solid bars (return generated) immediately expose the Trading dilemma: it generates outsized return relative to capital, but its RWA footprint is enormous. Mortgages, by contrast, consume moderate RWA while generating steady return — the quiet workhorse.
(C) Efficient Frontier
The frontier is concave and flattening as RWA increases. This tells you that marginal return gains diminish as you loosen the RWA constraint — beyond roughly €380B RWA, the incremental benefit shrinks rapidly. The red dot marks our current optimum.
(D) RoRWA Ranking
This ranking directly explains the optimizer’s choices:
| Rank | Business Line | RoRWA |
|---|---|---|
| 1 | Trading | 9.0% |
| 2 | SME Lending | 18.7% |
| 3 | Mortgages | 12.0% |
| 4 | Retail Banking | 22.9% |
| 5 | Corporate Lending | 12.0% |
Wait — Retail Banking has the highest RoRWA (22.9%) but gets minimum allocation? That’s because its absolute return per euro (8%) is low, and with the RWA constraint not fully binding at the margin, the LP trades off RoRWA efficiency for raw return. This nuance is why you need the full LP, not just a RoRWA ranking.
(E) Sensitivity Analysis
The curve is piecewise-linear — a signature of LP. Each kink represents a basis change: a business line hitting its floor or ceiling. Below €250B RWA, the problem becomes infeasible (can’t satisfy minimums). The shadow price around our €400B constraint is approximately €0.08 per €1 of RWA relaxed.
(F) 3D Surface
The surface is monotonically increasing in both dimensions but with diminishing returns. The ridge running diagonally represents the locus of binding RWA constraints. Points below the ridge are RWA-constrained; above it, the capital allocation bounds bind first. Management can read off return directly for any (RWA limit, total capital) scenario planning.
Execution Results
============================================================ CAPITAL ALLOCATION OPTIMIZATION — PROBLEM SUMMARY ============================================================ Total Capital : ¥100 billion Min CAR : 8.0% Max RWA : ¥1250 billion Retail return=8.0% RW=0.75 [5,40] ¥B Corporate return=12.0% RW=1.00 [5,35] ¥B Sovereign return=3.5% RW=0.00 [5,30] ¥B Derivatives return=15.0% RW=1.50 [0,20] ¥B RealEstate return=10.0% RW=1.00 [5,30] ¥B ============================================================ SCIPY / HiGHS SOLUTION ============================================================ Retail x = 10.00 ¥B (10.0%) Corporate x = 35.00 ¥B (35.0%) Sovereign x = 5.00 ¥B (5.0%) Derivatives x = 20.00 ¥B (20.0%) RealEstate x = 30.00 ¥B (30.0%) Total Return : ¥11.1750 B (11.17%) Total RWA : ¥102.50 B CAR : 97.56% Efficient frontier computed: 60 points

Figure saved: capital_allocation.png
Key Takeaways
The model demonstrates three core insights that every bank treasurer should internalize:
1. RoRWA ≠ Optimal: Ranking solely by Return on RWA can be misleading when business lines have hard allocation bounds. The LP captures the full constraint interaction.
2. The Efficient Frontier is your negotiating tool: When presenting to regulators or the board, the frontier quantifies exactly what a change in the RWA ceiling is worth in euros of foregone return.
3. Shadow prices matter more than point solutions: The slope of the sensitivity curve (Chart E) — not just the optimal allocation — is what drives strategic capital planning conversations.














