Credit risk portfolio
Credit risk portfolio is a free synthetic dataset of 2 tables and 7,200 rows, released under CC0. Its 1 key relationship joins with no orphans, and 4 questions come with the SQL that answers them.
3,000 borrowers and 4,200 commercial loans, where a credit rating actually predicts whether the loan defaults, at the rate S&P's own data says it should.
A credit_score column and a defaulted column with no statistical relationship between them is worse than useless for validating a risk model. Here, PD comes from S&P Global Ratings' own published annual global corporate default rate (averaged across the 2019-2024 studies), LGD comes from the Basel Foundation IRB supervisory value (a number banks are required to use, not one they estimate), and EAD is drawn plus a credit-conversion-factor on undrawn commitment, the real Basel formula. Whether a loan actually defaults is a Bernoulli draw at its borrower's own PD, so AAA, AA, and A show exactly zero defaults, and CCC defaults at close to 28%, both measured directly from these files.
- credit risk
- fintech
- PD LGD EAD
- Basel
- risk modeling
Explore
Every table, profiled
Each column's type, spread, empties and most common values, measured from the CSVs in the download. Switch to the first rows to see the data exactly as it sits in the file.
loans.csv
4,200 rows · 14 columns · 1 foreign keys
- senior_unsecured83%
- subordinated17%
- term_loan46%
- long_term_revolving21%
- short_term_revolving19%
- unconditionally_cancellable14%
Keys
Every join resolves
1 foreign key, 4,200 references checked against the table each one points at. None points at a row that does not exist.
loans
- borrower_idborrowers.borrower_id4,200 rows checked0 orphans
Checks
What we checked
- AAA, AA, and A: 0 of 1,067 loans defaulted (S&P published PD: 0.00% for all three)
- BBB: 2 of 1,261 defaulted, 0.16%, against a cited 0.03% PD
- CCC: 88 of 314 defaulted, 28.03%, against a cited 26.92% PD
- senior_unsecured LGD is exactly 40% on all 3,480 such loans, subordinated exactly 75% on all 720
- ead equals drawn_amount + ccf x undrawn_commitment on all 4,200 loans
- expected_loss equals pd x lgd x ead on all 4,200 loans
- realized_loss is 0 on every non-defaulted loan, and equals lgd x ead on every defaulted one
- 0 orphaned foreign keys joining loans to borrowers
The same checks ship in the zip as INTEGRITY.txt, so you can rerun them in any SQL engine. How we verify
Questions, answered
Worth asking it
Each answer is the query's result on these exact files. Open one for its SQL and rows, then check your own query against it.
1Does realized default rate actually track PD, by rating grade?Realized default rate against PD: BBB 0.16% vs 0.03%, BB 0.33% vs 0.28%, B 1.41% vs 1.61%, CCC 28.03% vs 26.92%.
select b.credit_rating, count(*) as loans, round(100 * avg(l.pd), 2) as avg_pd_pct, sum(case when l.defaulted then 1 else 0 end) as defaults, round(100.0 * sum(case when l.defaulted then 1 else 0 end) / count(*), 2) as realized_rate_pct from loans l join borrowers b on b.borrower_id = l.borrower_id group by b.credit_rating order by avg_pd_pct, b.credit_ratingcredit_rating loans avg_pd_pct defaults realized_rate_pct A 718 0 0 0 AA 281 0 0 0 AAA 68 0 0 0 BBB 1,261 0.03 2 0.16 BB 919 0.28 3 0.33 B 639 1.61 9 1.41 CCC 314 26.92 88 28.03 2What is the portfolio's total expected loss as a percentage of exposure?Expected loss $62,364,849 on $5,629,505,202 of exposure, 1.108%.
select round(sum(ead), 2) as ead, round(sum(expected_loss), 2) as expected_loss, round(100 * sum(expected_loss) / sum(ead), 3) as expected_loss_pct_of_ead, round(sum(realized_loss), 2) as realized_loss from loansead expected_loss expected_loss_pct_of_ead realized_loss 5,629,505,202 62,364,848.57 1.108 75,869,968.04 3How does expected loss concentrate across seniority and commitment type?senior_unsecured term_loan carries the most expected loss (30.4% of it).
select seniority, commitment_type, count(*) as loans, round(sum(ead), 2) as ead, round(sum(expected_loss), 2) as expected_loss, round(100 * sum(expected_loss) / (select sum(expected_loss) from loans), 1) as share_of_expected_loss_pct, round(100 * sum(expected_loss) / sum(ead), 3) as expected_loss_pct_of_ead from loans group by seniority, commitment_type order by expected_loss descseniority commitment_type loans ead expected_loss share_of_expected_loss_pct expected_loss_pct_of_ead senior_unsecured term_loan 1,584 2,070,928,536 18,977,667.97 30.4 0.916 senior_unsecured long_term_revolving 728 980,446,820.3 9,381,680.99 15 0.957 subordinated term_loan 333 500,808,884.9 8,405,288.76 13.5 1.678 senior_unsecured short_term_revolving 661 898,733,487.1 7,356,587.07 11.8 0.819 senior_unsecured unconditionally_cancellable 507 659,465,715.3 6,016,756.29 9.6 0.912 subordinated unconditionally_cancellable 91 145,428,454 5,571,909.08 8.9 3.831 subordinated short_term_revolving 149 184,307,571.8 4,070,838.63 6.5 2.209 subordinated long_term_revolving 147 189,385,732.8 2,584,119.78 4.1 1.364 4Which industries carry the riskiest rating mix?Technology is the riskiest by exposure-weighted PD (2.97%), Real Estate the safest (1.81%).
select b.industry, count(*) as loans, round(100 * sum(case when b.credit_rating in ('B', 'CCC') then l.ead else 0 end) / sum(l.ead), 1) as ead_rated_b_or_worse_pct, round(100 * sum(l.pd * l.ead) / sum(l.ead), 2) as ead_weighted_pd_pct from loans l join borrowers b on b.borrower_id = l.borrower_id group by b.industry order by ead_weighted_pd_pct descindustry loans ead_rated_b_or_worse_pct ead_weighted_pd_pct Technology 596 25 2.97 Financial Services 745 24.5 2.85 Energy 440 21.9 2.5 Retail 607 28.2 2.21 Manufacturing 451 20 2.1 Healthcare 389 19.1 2.02 Real Estate 972 18.2 1.81
Every query runs on the files in the download as they are. ANSWERS.sql holds all of them; run it in DuckDB from the dataset's folder.
Full version · $15
This sample, or the full Consumer Lending Loan Book
Applications, loans, a monthly servicing tape and losses. Try its free preview before you decide.
| This sample | Consumer Lending Loan Book | |
|---|---|---|
| Rows | 7,200 | 1,535,789 |
| Tables | 2 | 10 |
| Columns | 18 | 150 |
| Formats | CSV | CSV |
| Audit | Keys and the checks listed above | 96 checks, all listed |
| Licence | CC0, free | Commercial use, $15 once |
| Built for | credit risk, fintech, PD LGD EAD, Basel | Probability of default and scorecards, Vintage and roll-rate analysis, Loss forecasting and CECL-style reserves, Credit policy and pricing, Teaching and demos |
Use it
Take it, or make one shaped like yours
Rebuild it byte for byte
pip install misata curl -O https://raw.githubusercontent.com/rasinmuhammed/misata/main/examples/credit_risk_portfolio.py python -c "from credit_risk_portfolio import build, verify; t = build(n_borrowers=3000, seed=11); verify(t)"
This dataset adds a reconcile step on top of the declared schema (PD/LGD/EAD lookups, a real Bernoulli default draw per loan), so it ships as a runnable script rather than a schema.yaml a bare misata generate could regenerate honestly.
Your own tables, your own numbers
Describe the data you need in Studio and get connected tables with the totals you state, profiled like this and checked before you download.
The full version, and what goes with it
All premiumCumulative charge-off by months on book, by year booked
A regional lender, 52,000 applicants, three products, four years
Applications, loans, a monthly servicing tape and losses
- Rows
- 1,535,789
- Tables
- 10
- Checks
- 96 of 96
Free preview16-question projectProfile and previewCard spending each month, debit and credit
2,500 US households at five banks and seven card issuers, two years
Five banks' raw statement lines, with every label behind them
Answer key
- description
- merchant_name
- category
- +6 more
- Rows
- 7,627,186
- Tables
- 14
- Checks
- 50 of 50
Free previewProfile and previewGross sales by month, 2024 against 2025
One online retailer, 30,377 customers, six markets, two years
Two years of an online store's orders, payments, returns and refunds, reconciled to the cent
- Rows
- 436,126
- Tables
- 7
- Checks
- 44 of 44
Free preview15-question projectProfile and preview
Related free datasets
All 9- Retail star schemaA dimensional model you can actually practise joins on: one fact table, four dimensions, 47,051 rows, every join resolving and every total known.47,051 rows · 5 tables
- Ecommerce storefrontA year of orders across five joined tables, with best sellers, heavy buyers, a real Q4 peak and totals that reconcile to the cent.49,493 rows · 5 tables
- B2B SaaS subscription analyticsAccounts, seats, MRR, churn and support load, where company size actually drives the plan.42,240 rows · 5 tables
- Network intrusion / netflow500 hosts and 20,000 labeled flows, where a port scan, a DDoS flood, and a brute-force attempt each carry the real statistical signature their MITRE ATT&CK technique actually leaves in traffic.20,500 rows · 2 tables
- Contact center queueing (Erlang C)4 queues, 2,400 half-hour intervals over a full business month, where agents_staffed is what Erlang C (1917) says is actually required to clear each queue's own SLA target, not a plausible-looking number.2,404 rows · 2 tables
- Clinical trial: sites, patients, visits and adverse eventsTwo trials across nine sites: enrolment, scheduled visits, dosing, lab biomarkers and graded adverse events, all in the right order.22,496 rows · 7 tables
Fully synthetic. No real person, company or transaction is represented, and no production data was read to make it. CC0: use it anywhere, no attribution needed.

