Build a bank-grade credit scoring engine combining Altman Z-Score, FOIR limits, and DSRA liquidity buffers using pure Pandas and NumPy.
tags: python, datascience, finance, fintech

canonical_url: https://pyquant-library.netlify.app/

Most retail and SME credit underwriting workflows break down because teams evaluate cash-flow capacity (FOIR) in isolation from balance-sheet solvency (Altman Z-Score) and liquidity buffers (DSRA).

Here is a clean, dependency-light Python implementation that combines all three into a deterministic underwriting decision engine.

The 3-Pillar Underwriting Logic

  1. Altman Z-Score ($Z = 1.2X_1 + 1.4X_2 + 3.3X_3 + 0.6X_4 + 1.0X_5$): Flags whether a borrower sits in the Safe (> 2.99), Grey (1.81 – 2.99), or Distress (< 1.81) zone.
  2. FOIR Penalty: Penalizes applicants whose fixed obligations cross the 40% threshold.
  3. DSRA Buffer Credit: Rewards borrowers maintaining 3–6 months of Debt Service Reserve coverage.

Complete Python Implementation

import numpy as np import pandas as pd np.random.seed(42) borrowers = pd.DataFrame({ "Borrower_ID": [f"CORP_{i:03d}" for i in range(1, 11)], "Working_Capital_to_TA": np.round(np.random.uniform(-0.05, 0.45, 10), 3), "Retained_Earnings_to_TA": np.round(np.random.uniform(-0.10, 0.50, 10), 3), "EBIT_to_TA": np.round(np.random.uniform(0.02, 0.28, 10), 3), "Equity_to_Total_Liab": np.round(np.random.uniform(0.30, 2.50, 10), 3), "Sales_to_TA": np.round(np.random.uniform(0.50, 2.20, 10), 3), "FOIR_Pct": np.round(np.random.uniform(28.0, 68.0, 10), 1), "DSRA_Months": np.random.choice([0, 1, 2, 3, 6], size=10) }) borrowers["Altman_Z"] = np.round( 1.2 * borrowers["Working_Capital_to_TA"] + 1.4 * borrowers["Retained_Earnings_to_TA"] + 3.3 * borrowers["EBIT_to_TA"] + 0.6 * borrowers["Equity_to_Total_Liab"] + 1.0 * borrowers["Sales_to_TA"], 2 ) borrowers["Distress_Zone"] = np.where( borrowers["Altman_Z"] > 2.99, "SAFE_ZONE", np.where(borrowers["Altman_Z"] >= 1.81, "GREY_ZONE", "DISTRESS_ZONE") ) raw_score = ( 550 + (borrowers["Altman_Z"] * 65) - (np.maximum(0, borrowers["FOIR_Pct"] - 40) * 3.5) + (borrowers["DSRA_Months"] * 12) ) borrowers["Credit_Score"] = np.clip(np.round(raw_score, 0), 300, 900).astype(int) Run & Explore More Models Interactive Kaggle Notebook: Credit Scoring & Altman Z-Score Model in Python Full 126+ Python Quant & Credit Risk Library: PyQuant Library --- ### 3. Medium Article (SEO & Google AI Overviews Optimized) * **Title:** `Building a Bank-Grade Credit Scoring & Altman Z-Score Engine in Python` * **Subtitle:** `How to combine solvency ratios, FOIR thresholds, and DSRA liquidity buffers into an automated underwriting model.` * **Body:** > In retail and SME credit underwriting, two borrowers with identical cash-flow coverage can carry vastly different default risks. One might have strong retained earnings and working capital, while the other is masking balance-sheet distress behind short-term revenue. > > Having worked across retail banking credit risk and quantitative modeling, I’ve found that the cleanest way to automate initial credit screening in Python is by combining three institutional metrics: > > **1. Altman Z-Score (Balance Sheet Solvency)** > Edward Altman’s classic multi-factor formula evaluates liquidity, cumulative profitability, operating efficiency, leverage, and asset turnover simultaneously: > `Z = 1.2*(WC/TA) + 1.4*(RE/TA) + 3.3*(EBIT/TA) + 0.6*(Equity/Liabilities) + 1.0*(Sales/TA)` > Scores above **2.99** sit in the Safe Zone, while scores below **1.81** signal high distress probability. > > **2. Fixed Obligation to Income Ratio (FOIR)** > Even a solvent borrower can face near-term repayment friction if existing debt obligations consume more than 40–45% of net inflows. > > **3. Debt Service Reserve Account (DSRA) Covenants** > Maintaining 3 to 6 months of debt service in reserve acts as a shock absorber during revenue dips—and should directly uplift a borrower's composite credit score. > > **Run the Live Python Notebook & Full Code:** > * Execute the runnable notebook on Kaggle: **Credit Scoring & Altman Z-Score Model in Python** (`[https://www.kaggle.com/code/ayushman4you/credit-scoring-altman-z-score-model-in-python](https://www.kaggle.com/code/ayushman4you/credit-scoring-altman-z-score-model-in-python)`) > * Browse 126+ open-source Python scripts across Credit Risk, Basel PD/LGD/EAD, and Quantitative Finance at **PyQuant Library** (`[https://pyquant-library.netlify.app/](https://pyquant-library.netlify.app/)`). *(Note: Medium mein links ko select karke hyperlink icon se clickable bana dena.)* --- ### 4. LinkedIn Post (High-Engagement Banking + Quant Hook) 


text
Most credit underwriting models fail because they look at cash flow and balance-sheet solvency in separate silos.

A borrower with an acceptable FOIR can still be heading toward insolvency—and a borrower in the Altman Grey Zone can be safely underwritten if backed by a 6-month DSRA liquidity covenant.

After 9+ years in retail banking and credit risk, I put together a clean, pure-Python Credit Scoring & Altman Z-Score engine that combines:
✅ Altman Z-Score (Safe / Grey / Distress zone classification)
✅ FOIR threshold penalties (>40% obligation load)
✅ DSRA reserve buffer uplifts (300–900 internal score scale)

Zero heavy dependencies—just clean NumPy & Pandas logic ready for risk analysts and fintech builders.

👉 Run the interactive code on Kaggle: https://www.kaggle.com/code/ayushman4you/credit-scoring-altman-z-score-model-in-python
👉 Explore 126+ Quant & Credit Risk scripts: https://pyquant-library.netlify.app/

Which metric carries the highest weight in your underwriting scorecard—cash flow (FOIR/DSCR) or balance-sheet leverage?

CreditRisk #Python #FinTech #RiskManagement #Banking #DataScience #QuantitativeFinance