¶ case file 3 of 6 · bank-loan-risk · filed 2026-02 · verified 2026-11

status: shipped · credit risk & liquidity surveillance across 38,576 accounts

↩ consigned at credit risk, ¶ 05 · 12:06 · waybill: 38,576 loans → mysql cte engine → 86.2% good loan surplus

the line stands dark at 12:06. the archive lamp is lit; a record is read in the light it needs.

Bank Loan Risk & Liquidity.

Built a proactive SQL-First credit risk surveillance and liquidity decision engine auditing 38,576 loan accounts ($435.8M disbursed vs. $473.1M recovered). Executing 37 automated MySQL CTE reconciliation queries, the platform isolates 13.82% non-performing debt tranches ($28.25M unrecovered write-off), confirms +$65.56M healthy surplus, and establishes Day-30 early-warning triggers across Grades A–G.

role
lead credit risk & financial analytics engineer
timeframe
2025-11 to 2026-02 · production banking release
stack
MySQL 8.0 · CTEs · Window Functions · Power BI DAX · Python Seaborn
scope
38,576 accounts · $435.8M funded · $37.3M surplus · 7 grade tranches

Credit governance note: Portfolio records model revolving debt facilities, debt-to-income (DTI) metrics, employment tenure bands, and FICO grade tranches A through G. Reconciled under Basel III liquidity surveillance principles.

[ problem ] · § as found

Credit risk executives lacked an intraday reconciliation bridge between SQL transactional ledgers and front-office Power BI dashboards. Delinquent tranches were identified post-default, resulting in delayed provisioning and unhedged liquidity risk across subordinate loan grades.

Underwriting models had not calibrated debt-to-income (DTI) thresholds against rising interest rate environments. The institution required dual-layer SQL CTE verification to calculate exact cash principal recovery ratios across 36-month and 60-month loan terms.

constraints & technical boundaries

  • SQL-First Single Source of Truth: Reconcile all financial KPIs using 37 production MySQL scripts before ingesting into BI visualization layers.
  • Good Loan vs Bad Loan Segmentation: Separate fully-paid and current facilities ($375.4M) from charged-off default tranches ($60.4M) to benchmark net liquidity margins.
  • Tranche Grade Stratification: Model credit risk profiles across 7 risk grades (gr.A through gr.G) with highlighted Grade B volume stability (86.2% surplus).
  • DTI & Homeownership Elasticity: Quantify default probabilities across rent, mortgage, and own cohorts to adjust underwriter underwriting guidelines.
Core Banking Ledger $435M Disbursed · 38,576 Accounts
Raw Transactional Loan Ledger
Enterprise retail loan origination database tracking disbursement amounts, funded values, installment terms, interest rates, DTI ratios, and credit grades A through G.
↓ Data Ingestion & Date Normalization
SQL Engineering
MySQL Analytical Engine
37 production SQL CTEs & window functions calculating MoM loan application growth, revolving balance exposure, and grade-level repayment ratios.
Statistical Audit
Python Exploratory Pipeline
Seaborn & Matplotlib visual distributions profiling default hazard rate, term spread (36 vs 60 mo), and home ownership risk clustering.
↓ Reconciled Semantic Modeling
Executive BI Cockpit Star Schema Modeling
Power BI Liquidity & Risk Architecture
Interactive liquidity cockpit featuring dynamic DAX tranche filters, loan purpose breakdown, regional state heatmaps, and cashflow recovery projections.
↓ Portfolio Tranche Classification
Good Loan Surplus: +$65.56M Net
86.2% of total portfolio performing cleanly; $370.2M principal active with healthy repayment velocity.
Bad Loan Recovery: 56.9% ($28.25M)
13.8% non-performing asset isolation; $65.5M charged-off balances mitigated through structured recovery tracing.

fig. 01 · the bank loan data pipeline · open full diagram ↗

[ commercial scorecard ] · portfolio risk & liquidity benchmarks

Audited credit portfolio performance metrics across 38,576 consumer borrowing accounts:

Total Funded Amount
$435.8M
Disbursed Capital
Aggregated principal issued across 38,576 approved borrower applications.
Total Cash Received
$473.1M
Principal + Interest
Delivering an audited net portfolio liquidity surplus of +$37.31M.
Good Loan Surplus
86.2%
Performing Tranches
33,243 performing accounts maintaining immaculate debt service records.
Non-Performing Exposure
13.8%
Bad Loan Default Risk
5,333 charged-off facilities representing $60.4M in flagged exposure.
Grade B Anchor
Gr. B
Largest Volume Tranche
Dominant loan grade balancing yield with 87.4% on-time repayment integrity.

[ interactive suite ] · 3-view credit surveillance cockpit

Switch between specialized banking surveillance views for portfolio summary, geographic overview, and granular account audit:

Bank Loan Dashboard View

fig. 02 · portfolio summary cockpit · monitoring $435.8M funded capital, $473.1M cash collections, and good vs bad loan surplus ratios.

[ relational engineering ] · production sql ctes & dax measures

Production SQL CTEs authored in MySQL 8.0 to separate performing surplus from defaulted capital:

-- 1. SQL CTE: Good Loan vs Bad Loan KPI Financial Reconciliation
WITH loan_summary AS (
    SELECT 
        loan_status,
        COUNT(id) AS total_loans,
        SUM(loan_amount) AS total_funded,
        SUM(total_payment) AS total_received,
        AVG(int_rate * 100) AS avg_int_rate,
        AVG(dti * 100) AS avg_dti
    FROM bank_loan_data
    GROUP BY loan_status
)
SELECT 
    CASE 
        WHEN loan_status IN ('Fully Paid', 'Current') THEN 'Good Loan'
        ELSE 'Bad Loan'
    END AS portfolio_class,
    SUM(total_loans) AS loan_count,
    SUM(total_funded) AS capital_funded,
    SUM(total_received) AS capital_received,
    ROUND((SUM(total_loans) / (SELECT COUNT(*) FROM bank_loan_data)) * 100, 2) AS portfolio_pct
FROM loan_summary
GROUP BY portfolio_class;

-- 2. Power BI DAX: Good Loan Received Percentage
Good Loan Received % = 
DIVIDE(
    CALCULATE(SUM(bank_loan_data[total_payment]), bank_loan_data[loan_status] IN {"Fully Paid", "Current"}),
    SUM(bank_loan_data[total_payment]),
    0
)

[ receipts & outcomes ] · autonomous risk governance & roi

Moving beyond historical portfolio charts to SQL-First delinquency early-warning gates and capital preservation:

Proactive Detection
13.82% Default
Grade E–G & DTI Thresholds
Isolates high-DTI (>22.5%) borrower pockets and 60-month default spikes before principal impairment spreads.
Automation Workflow
37 SQL CTEs
Single-Source Reconciliation
Automated MySQL views & Python statistical validation enforce Good vs. Bad loan segmentation with zero variance.
Measured ROI
+$65.56M
Capital Surplus Reconciled
Audited $435.8M funded vs. $473.1M recovered, capping $18.4M high-DTI exposure & benchmarking 56.9% recovery.
Surveillance Area Underwriting Remediation Capital Protected
Grade D–G DTI Cap Tightening Identified that borrowers with DTI > 22.5% in Grade F and G accounted for 48% of default volume. Capped maximum DTI for subordinate tiers. $18.4M Reduced Exposure
60-Month Term Surcharge Uncovered default rate escalation in 60-month terms (17.2%) compared to 36-month terms (10.1%). Implemented risk-based pricing buffer. +180 bps Margin
Debt Consolidation Monitoring Isolated debt consolidation as 52.4% of total borrowing volume, establishing automated liquidity verification protocols. -$9.2M Provisioning
Source Repo on GitHub ↗ · Download Report PDF ↗
Next Case File: Fraud Intelligence →