FRTB IMA: End-to-End Numerical Case Study with 100 Trades
Reproduce FRTB IMA capital from 100 synthetic trades, historical scenarios, risk factor eligibility, expected shortfall, desk validation and correlated default simulation.
The big picture
A bank trades currencies, shares and commodities. Prices move, and on a bad day or a bad month the bank can lose a lot of money. Regulators therefore require the bank to hold enough loss-absorbing capital to withstand large losses.
Under FRTB IMA (Fundamental Review of the Trading Book, Internal Models Approach), a bank may estimate that cushion with its own risk model, but only if the model passes a series of tests. This case study builds the whole calculation on 100 made-up trades, so you can see every step with real numbers.
The journey in one table:
| Step | The question it answers |
|---|---|
| 1. Portfolio | What does the bank actually hold? |
| 2. Risk factors | Which market prices drive the value, and can we trust the data on each? |
| 3-4. Scenarios | What could prices do over 10 days, based on history? |
| 5. Expected Shortfall | In the worst few scenarios, how big is the average loss? |
| 6. Liquidity horizons | What if we cannot sell quickly in a crisis? |
| 7-8. Stress and IMCC | What if markets are as bad as the worst past period? |
| 9. NMRF | What about prices we cannot model well? |
| 10-11. Backtesting and P&L attribution | Is the model honest and accurate? |
| 12. Default risk | What if a company whose shares we own goes bust? |
| 13. Final capital | Add it all up. |
Final answer: capital of USD 3,472,266.59, which converts to market risk RWA (risk-weighted assets) of USD 43,403,332.33.
Mini glossary
- Risk factor: a market price that drives the value of the positions, such as EUR/USD or the WTI oil price.
- P&L: profit and loss. Positive means a gain.
- Loss: simply minus P&L. A positive loss is bad. A negative loss is a gain.
- Long / short: long gains when the price rises. Short gains when the price falls.
- Expected Shortfall (ES): the average loss in the worst slice of scenarios.
- Liquidity horizon (LH): a prescribed measure of how long it can take to exit or hedge an exposure in stressed markets.
- Modellable: a risk factor with enough real price evidence to be put into the model.
- RWA: risk-weighted assets. Capital multiplied by 12.5.
1. Portfolio construction
In plain English: the bank has one trading desk, DESK01, holding 100 trades: 30 currency (FX) trades, 40 share trades and 30 commodity futures trades.
There are 10 risk factors (3 currency pairs, 4 stocks and 3 commodities), and 10 trades sit on each one. For each factor, 7 trades are long and 3 are short. Their quantities partly offset, leaving one net position per factor.
The stock issuers are fictional, and the case ignores funding, basis, counterparty and settlement risk. Amounts are in USD. Within each factor group, commodity futures share the same contract specifications and maturity, with enough time remaining for the assigned liquidity horizon.
How a trade's size is measured. Three ingredients:
- n = number of contracts or units (negative if short)
- m = multiplier (for example 1,000 barrels per oil contract)
- X = today's price
Quantity equals signed contracts or units times the multiplier. Reference exposure equals that quantity times the current quote. The net quantity for a factor is the sum of the quantities mapped to it. Trade T071 (WTI oil, long) has 3 contracts of 1,000 barrels each at USD 75 per barrel, for USD 225,000 in reference exposure. Trade T001 (EUR/USD) has 347,764 units at 1.1, for USD 382,540.40.
Two totals to understand:
- Gross exposure (add up the absolute size of every trade, ignoring direction): USD 13,076,652.05.
- Signed exposure (longs minus shorts): USD 8,720,000.00.
The gap between them is the longs and shorts offsetting each other. Neither number is capital or the portfolio's market value. They are only a measure of size. Note also that for a futures contract the exposure is not its fair value.
Quotes are in USD per unit: FX is USD per unit of foreign currency, stocks USD per share, WTI USD per barrel, wheat USD per bushel. The individual tickets were generated randomly (seed 100) so that they add up to the assumed net quantities. The full blotter is in data/trades.csv.
Selected rows from the trade blotter:
| Trade | Factor | Side | Signed lots/units | Multiplier | Price units | Exposure USD |
|---|---|---|---|---|---|---|
| T001 | EURUSD | Long | 347764 | 1 | 347764 | 382,540.40 |
| T002 | EURUSD | Long | 348140 | 1 | 348140 | 382,954.00 |
| T008 | EURUSD | Short | -191722 | 1 | -191722 | -210,894.20 |
| T031 | ALPHA | Long | 1662 | 1 | 1662 | 166,200.00 |
| T068 | DELTA | Short | -597 | 1 | -597 | -35,820.00 |
| T071 | WTI | Long | 3 | 1000 | 3000 | 225,000.00 |
| T090 | WHEAT | Short | -1 | 5000 | -5000 | -30,000.00 |
| T100 | RARE | Short | -1 | 1000 | -1000 | -70,000.00 |
2. Risk mapping, RFET and liquidity horizons
This step classifies each of the 10 risk factors in two ways.
(a) Can we trust its price data? The Risk Factor Eligibility Test (RFET). A model needs real, observable prices. The rule used here (Basel MAR31.13) is: the factor must have at least 100 days with real price observations in the past 12 months, with at most one observation counted per day. Factors that pass are modellable. Factors that fail are non-modellable (NMRF). They cannot go into the main model and get a separate, tougher treatment (Step 9).
(b) How long to exit or hedge? The liquidity horizon uses prescribed categories. In this portfolio, the specified currency pairs and large-cap equities use 10 days, small-cap equities and energy use 20 days, and agricultural commodities use 60 days.
| Factor | Class | Net units | Quote (USD) | LH (days) | Real-price days | Modellable | In reduced set |
|---|---|---|---|---|---|---|---|
| EURUSD | FX | 2,000,000 | 1.1 | 10 | 220 | Yes | Yes |
| GBPUSD | FX | 100,000 | 1.25 | 10 | 210 | Yes | No |
| JPYUSD | FX | 200,000,000 | 0.0067 | 10 | 205 | Yes | Yes |
| ALPHA | Equity | 10,000 | 100.0 | 10 | 230 | Yes | Yes |
| BETA | Equity | 12,000 | 80.0 | 10 | 225 | Yes | Yes |
| GAMMA | Equity | 15,000 | 45.0 | 20 | 180 | Yes | Yes |
| DELTA | Equity | 8,000 | 60.0 | 20 | 175 | Yes | Yes |
| WTI | Commodity | 20,000 | 75.0 | 20 | 240 | Yes | Yes |
| WHEAT | Commodity | 50,000 | 6.0 | 60 | 200 | Yes | Yes |
| RARE | Commodity | 2,000 | 70.0 | 20 | 18 | No | No |
RARE has only 18 real-price days, far below 100, so it is non-modellable. Everything else passes.
MAR31.13 also allows a route with at least 24 qualifying real-price dates and no applicable 90-day period with fewer than four observations. RARE’s 18 dates fail both routes.
The reduced set. Regulators also want a smaller set of factors that have a long, reliable history, because this set is used to find the stress period later. Here it has 8 factors: the 9 modellable ones minus GBPUSD, which is dropped because the position is small. RARE is in neither set and gets its own capital charge.
Caveats. The price-day counts are assumed evidence, not real quotes. In real life you would also monitor monthly, check data quality and check that proxies are representative. The portfolio has no interest-rate or credit-spread factors.
3. Generate synthetic market shocks
Why synthetic? The study has no real market data, so it manufactures realistic-looking daily price moves from 2 January 2007 to 27 November 2026 (weekdays only, holidays ignored, random seed 20261128). The convention is 250 business days = one year.
The daily price change of factor f on day t is built like a recipe:
- Volatility is how large the factor's typical daily move is (set per factor in risk_factors.csv).
- Global part is a market-wide shock shared by all factors, so that things tend to move together.
- Commodity part is a shock shared only by commodities.
- Own noise is the factor's private randomness. The loadings are chosen so the three parts together keep unit variance, which is why the noise is multiplied by the square root of what is left over.
In the model, the global, commodity and factor-specific innovations are independent standard normal variables.
- Regime multiplier a(t) scales volatility up in crisis periods: 2.5 from July 2008 to June 2009, 1.8 from March 2020 to February 2021, and 1 otherwise.
The two crises are synthetic and do not estimate real crisis losses. Changes are absolute (added to today's price), and there is no modelling of rolling futures contracts.
4. Ten-day historical simulation and trade-level repricing
The idea: take what happened in history over 10-day periods and ask, "If the same moves happened starting from today, how much would the bank gain or lose?"
For every 10-day window, the shock is simply the sum of the 10 actual daily changes (not one day's move scaled up by the square root of 10). In 250 days there are 250 - 10 + 1 = 241 overlapping windows, so 241 scenarios.
For each scenario and trade:
Multiply the signed quantity by the 10-day move to find a trade’s P&L. For the factors in the set , add up the trade P&Ls and reverse the sign to get the loss. The linear quote exposure is used for P&L differences. Futures fair value is a separate measure.
Because every trade is linear (no options), adding trade P&Ls gives exactly the same answer as shocking each factor's net quantity once. The code checks this match for every factor and scenario.
The reconciliation follows from . Options would require nonlinear repricing.
Worked example: the first current scenario. Trade T001 (quantity 347,764) faces a 10-day EUR/USD move of +0.025290948, so its P&L is 347,764 x 0.025290948 = USD 8,795.28. Adding all trades per factor:
| Factor | 10-day shock | Net P&L (USD) |
|---|---|---|
| EURUSD | 0.025290948 | 50,581.90 |
| GBPUSD | 0.030037384 | 3,003.74 |
| JPYUSD | -0.000009719 | -1,943.76 |
| ALPHA | 2.050393469 | 20,503.93 |
| BETA | -2.905410374 | -34,864.92 |
| GAMMA | -1.424583837 | -21,368.76 |
| DELTA | -2.232123070 | -17,856.98 |
| WTI | 3.303110316 | 66,062.21 |
| WHEAT | 0.245640908 | 12,282.05 |
| RARE | -0.633759620 | -1,267.52 |
The nine modellable factors add up to a gain of USD 76,399.40, so the loss is -76,399.40. A negative loss is a gain. RARE is left out because it is handled separately.
The files current_trade_scenarios.csv and stress_trade_scenarios.csv each hold 24,100 rows (100 trades x 241 scenarios). Positive P&L is a gain. Positive loss is a loss.
5. Expected Shortfall estimation
VaR vs ES. Value at Risk (VaR) answers "what is the loss I will only exceed in the worst 2.5% of cases?" It says nothing about how bad those cases are. Expected Shortfall goes further: it averages the losses in that worst 2.5% tail. FRTB uses ES at the 97.5% level.
How to compute it. Sort the 241 losses from worst to best. The tail is 2.5% of 241 = 6.025 scenarios. The six worst losses count fully, and the seventh counts for only 0.025 of a scenario. Then divide by 6.025.
For confidence and equally weighted losses, the tail contains observations by weight. Let , , and order the losses from worst to best, starting at .
6. Liquidity horizon adjustment
The problem: a 10-day loss assumes you can get out in 10 days. If wheat takes 60 days to sell, you are exposed to wheat moves for much longer, so the risk should be larger.
The fix, step by step.
- Choose the horizons 10, 20, 40, 60 and 120 days.
- For each horizon h, keep only the factors whose LH is at least h, and compute the ordinary 10-day ES for that group. So "LH 20" covers GAMMA, DELTA, WTI and WHEAT, and "LH 40" and "LH 60" cover wheat alone.
- Combine the ES values using the weights for the 10-, 20-, 40-, 60- and 120-day horizons.
Intuitively, each weight counts how many extra 10-day periods that slice of positions stays stuck. Wheat is stuck for 60 days, so it shows up in the 10, 20, 40 and 60 slices. The 40 and 60 slices have the same ES because both contain only wheat, but both are weighted separately. There is no 120-day exposure, so that term is zero.
The portfolio results (USD). FC = full set, current data. RC = reduced set, current data. RS = reduced set, stressed data.
| Calibration | ES LH10 | ES LH20 | ES LH40 | ES LH60 | ES LH120 | LH-adjusted ES |
|---|---|---|---|---|---|---|
| FC | 338,666.41 | 261,181.09 | 51,020.28 | 51,020.28 | 0.00 | 439,684.86 |
| RC | 337,550.31 | 261,181.09 | 51,020.28 | 51,020.28 | 0.00 | 438,825.76 |
| RS | 854,626.53 | 647,342.31 | 131,473.42 | 131,473.42 | 0.00 | 1,103,892.94 |
For example, the FC result is the square root of: 338,666.41 squared + 261,181.09 squared + 2 x 51,020.28 squared + 2 x 51,020.28 squared. The file liquidity_es.csv has all 18 scope and calibration rows.
7. Reduced set validation and selection of the stress window
Part A: does the reduced set represent the full set? Over the last 60 days, compute reduced-set ES divided by full-set ES each day and average it. Regulators require at least 75%. Here the average is 99.8120% (latest day 99.8046%), a comfortable pass.
Part B. Find the worst period in history. At the first date of the 60-day capital history, the model scans all complete 250-day windows since 2007 using information available at that date. For each window it scores the stressed reduced-set ES with the current scaling ratios, then picks the window with the highest blended charge.
The selected stress window is 21 March 2008 to 5 March 2009. It overlaps the synthetic 2008–09 crisis regime. The same window applies to the unconstrained and class-level calculations, and both the reduced set and the stress window stay fixed through the 60-day run. The candidate scores are in stress_search.csv. Production governance requires review at least quarterly and after material changes. Supervisory approval and data quality are assumed here.
8. IMCC calculation
IMCC (Internally Modelled Capital Charge) is the main capital number for modellable risk. For each scope (All, and each risk class) take the stressed reduced ES and scale it by how much the full set exceeds the reduced set today:
Absent classes give zero. A nonzero full ES with zero reduced ES would signal a model design error.
| Scope | ES_FC | ES_RC | ES_RS | Scale | Stressed charge |
|---|---|---|---|---|---|
| All | 439,684.86 | 438,825.76 | 1,103,892.94 | 1.001958 | 1,106,054.05 |
| FX | 92,000.41 | 91,252.15 | 273,437.35 | 1.008200 | 275,679.50 |
| Equity | 290,082.39 | 290,082.39 | 517,446.08 | 1.000000 | 517,446.08 |
| Commodity | 252,605.66 | 252,605.66 | 740,279.63 | 1.000000 | 740,279.63 |
| Interest rate | 0.00 | 0.00 | 0.00 | 1.000000 | 0.00 |
| Credit spread | 0.00 | 0.00 | 0.00 | 1.000000 | 0.00 |
Then blend the all-risk number with the sum of the per-class numbers:
Check: 0.5 x 1,106,054.05 + 0.5 x (275,679.50 + 517,446.08 + 740,279.63) = USD 1,319,729.63. The sum of the classes is larger than the all-risk figure because adding classes ignores diversification, and the 50/50 blend gives partial credit for it.
The model recomputes this on each of the last 60 days, giving an average IMCC of USD 1,319,363.77.
9. NMRF stress scenario capital
Non-modellable factors have too little data for the normal model, so regulators ask for a deliberately conservative Stress Scenario charge (SES). Here only RARE is non-modellable.
- Its horizon is max(20, LH) = 20 days.
- Build 20-day price changes from a proxy (a similar, better-observed series).
- Apply the net 2,000-barrel position and compute 97.5% ES in every 250-day window (231 overlapping 20-day scenarios each).
- Take the worst window, here 3 October 2019 to 16 September 2020.
With one NMRF there is nothing to aggregate, so SES = USD 13,220.93. With several NMRFs, regulators prescribe common stress periods and aggregation rules (MAR33.16-17). Because the position and calibration are fixed, the SES is identical on all 60 history dates.
The example assumes the proxy is suitable. A production model must demonstrate that its calibration is prudent.
10. Desk-level VaR backtesting and bank-wide multiplier
Backtesting asks: did the model's predicted risk match reality? Each day, the model forecasts a one-day VaR. If the actual loss is larger, that is an exception. Too many exceptions means the model underestimates risk.
The test uses 250 days. Each forecast uses the preceding 250 days of losses (excluding the test day) and is a plain empirical quantile. VaR here is one-day and not liquidity-adjusted. Three P&L streams are compared:
- RTPL (risk-theoretical P&L): what the risk model says the portfolio made.
- HPL (hypothetical P&L): RTPL plus 250 x random noise, standing in for valuation differences.
- APL (actual P&L): HPL plus 350 x random noise minus 100, standing in for intraday trading and fees.
The forecasts use the inverse empirical CDF without interpolation. RTPL includes RARE, while the VaR forecast uses modellable risk factors. The example claims no NMRF exception waiver.
The desk's exception count is the larger of the APL and HPL counts.
| Confidence | APL exceptions | HPL exceptions | Desk maximum allowed |
|---|---|---|---|
| 97.5% | 10 | 10 | 30 |
| 99% | 2 | 2 | 12 |
The desk passes both tests. Being the only desk, its 99% exceptions are also the bank-wide count. The capital multiplier m(c) depends on that count: 1.50 for 0-4 exceptions, 1.70, 1.76, 1.83, 1.88, 1.92 for 5-9, and 2.00 for 10 or more, before any discretionary add-ons. With 2 exceptions, m(c) = 1.50. The P&L streams were deliberately built to be close to each other, so passing here is not independent proof of model quality.
11. P&L attribution test
Question: is the risk model's P&L (RTPL) a good match for the desk's hypothetical P&L (HPL)? If not, the model is not capturing what drives profits.
Two statistics over the same 250 days:
- Spearman rank correlation: do big gain days and big loss days line up in the same order in both series? 1.0 is perfect.
- Kolmogorov-Smirnov (KS) distance: the biggest gap between the two P&L distributions. 0 is identical.
Results: Spearman 0.99993395, KS 0.012.
Zones: green if correlation is above 0.80 and KS below 0.09. Red if correlation is below 0.70 or KS above 0.12. Amber otherwise. This desk is comfortably green, so there is no PLA surcharge. Daily data are in desk_tests.csv.
12. Default risk charge: four correlated equity obligors
The risk: the market-risk model above handles price moves. It does not cover a company going bust, where a share price drops to zero. The Default Risk Charge (DRC) captures that.
Four equity positions are exposed. The loss if a company defaults (jump-to-default, JTD) is the whole position value.
| Issuer | JTD (USD) | 1-year default probability | Region loading | Industry loading |
|---|---|---|---|---|
| ALPHA | 1,000,000 | 0.5% | 0.35 | 0.30 |
| BETA | 960,000 | 0.8% | 0.35 | 0.45 |
| GAMMA | 675,000 | 1.5% | 0.40 | 0.25 |
| DELTA | 480,000 | 2.0% | 0.40 | 0.40 |
Why correlation matters. Companies tend to fail together in a downturn, so the chance of several defaulting at once is higher than if they were independent. The model captures this with a latent variable for each firm, a hidden measure of financial health:
- R is a shared region factor, I is a shared industry factor, and e(i) is the firm's own luck.
- Firm i defaults if Y(i) falls below a threshold set by its default probability.
- Two firms are correlated through the shared factors: corr = b(i,R) b(j,R) + b(i,I) b(j,I).
The probabilities and loadings are assumed. A production calibration requires the applicable 10-year market-data history. The two systematic factors and the issuer-specific innovations are independent standard normals.
Simulation. Simulate 2,000,000 one-year outcomes (seed 20261129). Each outcome identifies which of the 4 firms default (16 possible combinations). Total loss is . The DRC is the smallest loss level at which the cumulative probability reaches 99.9%.
- At USD 1,440,000 the cumulative probability is below 99.9%.
- At USD 1,480,000 it is 0.9990220, so DRC = USD 1,480,000.00.
A useful observation: the loss levels come from default combinations. For example, 1,440,000 equals BETA + DELTA, and 1,480,000 equals ALPHA + DELTA.
Cross-check. Simulation has sampling noise, so the code independently estimates the distribution by 60 × 60 Gauss–Hermite quadrature over the two shared factors. It multiplies conditional issuer default or survival probabilities to obtain each state’s probability. The resulting CDF is 0.9990433 at USD 1,480,000, giving the same quantile. Both estimates are in drc_distribution.csv. The final rule takes the larger of the latest DRC and its previous 12-week average. These are identical under the case study’s fixed positions and calibration.
13. Final capital and market risk RWA
The final assembly (simplified MAR33.43, green desk, no ineligible positions) has two branches for the non-default capital:
The max is a safety feature: capital cannot drop just because yesterday was calm. Then:
(The 12.5 comes from the Basel convention that capital is 8% of RWA, and 1 / 0.08 = 12.5.)
| Item | USD |
|---|---|
| Latest IMCC | 1,319,729.63 |
| Average IMCC | 1,319,363.77 |
| Latest and average SES | 13,220.93 |
| Branch 1: latest IMCC + SES | 1,332,950.56 |
| Branch 2: 1.5 x average IMCC + SES | 1,992,266.59 |
| Non-default capital (larger branch) | 1,992,266.59 |
| Default risk charge | 1,480,000.00 |
| SA / PLA surcharge | 0.00 |
| Total market risk capital | 3,472,266.59 |
| Market risk RWA | 43,403,332.33 |
Branch 2 wins because the 1.50 multiplier pushes it well above Branch 1. Check: 1.5 x 1,319,363.77 + 13,220.93 = 1,992,266.59, and 1,992,266.59 + 1,480,000 = 3,472,266.59. Rounding is for display only.
14. Assumption and input provenance
| Item | Source |
|---|---|
| Desk approval, quantities, quotes, multipliers | Assumed |
| Individual ticket sizes | Generated to match the assumed net positions |
| Liquidity horizons, RFET evidence, proxy quality | Assumed |
| Volatilities, loadings, crisis regimes | Assumed |
| Daily and 10-day shocks, trade P&L | Generated, then calculated and reconciled |
| ES, IMCC, SES, backtest and PLA statistics | Calculated |
| Default probabilities and loadings | Assumed |
| Default outcomes and DRC | Simulated, checked by quadrature |
| Capital history and RWA | Calculated, assuming fixed positions |
The table separates assumed inputs, generated data, and calculated outputs. The regulatory calculations are applied to a synthetic portfolio and market history.
15. Reproduce the case study
python -m pip install -r requirements.txt
python run_case_study.pyThe script regenerates every file in data/. Start with summary.json (the authoritative results), then use trades.csv and risk_factors.csv for inputs. The trade-level scenario files let you filter by ticket or date, and desk_tests.csv, liquidity_es.csv, imcc_components.csv, stress_search.csv, nmrf_stress_losses.csv, drc_issuers.csv, drc_distribution.csv, capital_history.csv and drc_weekly.csv trace each step above.
| Dataset | Use |
|---|---|
| trades.csv, risk_factors.csv | Blotter and factor master |
| rfet_assumed_flags.csv, daily_shocks.csv | RFET evidence and shock history |
| current_trade_scenarios.csv, stress_trade_scenarios.csv | Trade-level scenario P&L |
| latest_scenarios.csv, selected_stress_scenarios.csv | Factor-level scenario reconciliation |
| liquidity_es.csv, imcc_components.csv | ES and IMCC |
| stress_search.csv, nmrf_stress_losses.csv | Stress window and NMRF |
| desk_tests.csv | Backtesting and PLA |
| capital_history.csv, drc_weekly.csv | Regulatory averages |
| drc_issuers.csv, drc_distribution.csv | Correlated issuer default calculation |
| summary.json | Final results |
16. Regulatory scope and limitations
This is a teaching model, not a bank-ready engine. It leaves out interest rate and credit spread factors, options (and so any nonlinear revaluation), multiple desks, changing holdings, exchange holidays, the standardised-approach fallback and the amber PLA surcharge. It approximates a year as 250 business days and 12 weeks as 60. A real implementation needs all applicable risk factors, real market data, independent validation, calibrated default parameters, supervisory approval and local rules.
References: Basel MAR30, MAR31, MAR32, MAR33. In particular MAR31.13, MAR32.9/18/19/22 and PLA thresholds, MAR33.4–7, 12–17, 18–39 and 43–44.
A production implementation also needs full valuation controls, a review of proxy suitability, prescribed reporting conventions and the applicable jurisdiction’s rules.
Explore the synthetic case study
100 synthetic trades. Reported capital: USD 3,472,266.59. Market risk RWA: USD 43,403,332.33. Enable JavaScript to explore the datasets.