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
0100200Jan 2022Jul 2022Jan 2023Jul 2023Jan 2024Jul 2024Jan 2025Jul 2025Nov 2025
Rows per month in loans.origination_date, counted from the file.

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

loan_idprimary key
unique on every row
4,200 distinctno empties
borrower_idforeign key
points to borrowers.borrower_id
2,255 distinctno empties
senioritycategory
  • senior_unsecured
    83%
  • subordinated
    17%
2 valuesno empties
commitment_typecategory
  • term_loan
    46%
  • long_term_revolving
    21%
  • short_term_revolving
    19%
  • unconditionally_cancellable
    14%
4 valuesno empties
drawn_amountnumber
50,00013.6M
mean 1.32Mmedian 714,61050,000 to 25Mno empties
undrawn_commitmentnumber
01.13M
mean 72,327median 9,507.20 to 3.57Mno empties
origination_datedate
Jan 2022Nov 2025
2022-01-01 to 2025-11-30no empties
lgdnumber
0.40.75
mean 0.46median 0.40.4 to 0.75no empties
ccfnumber
00.5
mean 0.14median 00 to 0.5no empties
eadnumber
50,72613.6M
mean 1.34Mmedian 736,80550,000 to 25Mno empties
pdnumber
00.27
mean 0.023median 0.00030 to 0.27no empties
defaultedyes / no
true · 2.4%false · 98%
no empties
expected_lossnumber
0428,018
mean 14,849median 219.40 to 4.05Mno empties
realized_lossnumber
0788,898
mean 18,064median 00 to 15Mno empties

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_id0 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.

  1. 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_rating
    credit_ratingloansavg_pd_pctdefaultsrealized_rate_pct
    A718000
    AA281000
    AAA68000
    BBB1,2610.0320.16
    BB9190.2830.33
    B6391.6191.41
    CCC31426.928828.03
  2. 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 loans
    eadexpected_lossexpected_loss_pct_of_eadrealized_loss
    5,629,505,20262,364,848.571.10875,869,968.04
  3. 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 desc
    senioritycommitment_typeloanseadexpected_lossshare_of_expected_loss_pctexpected_loss_pct_of_ead
    senior_unsecuredterm_loan1,5842,070,928,53618,977,667.9730.40.916
    senior_unsecuredlong_term_revolving728980,446,820.39,381,680.99150.957
    subordinatedterm_loan333500,808,884.98,405,288.7613.51.678
    senior_unsecuredshort_term_revolving661898,733,487.17,356,587.0711.80.819
    senior_unsecuredunconditionally_cancellable507659,465,715.36,016,756.299.60.912
    subordinatedunconditionally_cancellable91145,428,4545,571,909.088.93.831
    subordinatedshort_term_revolving149184,307,571.84,070,838.636.52.209
    subordinatedlong_term_revolving147189,385,732.82,584,119.784.11.364
  4. 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 desc
    industryloansead_rated_b_or_worse_pctead_weighted_pd_pct
    Technology596252.97
    Financial Services74524.52.85
    Energy44021.92.5
    Retail60728.22.21
    Manufacturing451202.1
    Healthcare38919.12.02
    Real Estate97218.21.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 sampleConsumer Lending Loan Book
Rows7,2001,535,789
Tables210
Columns18150
FormatsCSVCSV
AuditKeys and the checks listed above96 checks, all listed
LicenceCC0, freeCommercial use, $15 once
Built forcredit risk, fintech, PD LGD EAD, BaselProbability 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 premium
  • Cumulative 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 preview
  • Card 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 preview
  • Gross 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

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.