Financial Calculations & Valuation Beginner

Altman Z-Score Corporate Credit Risk & Default Predictor in Python

Calculate Edward Altman's 5-factor Z-Score in Python to classify corporate balance sheets into Safe, Grey, or Financial Distress zones.

#pandas#numpy

Problem Statement

Fundamental investors and credit officers need an objective quantitative score to detect balance sheet deterioration before a company defaults or slips into NPA.

Formula / Core Logic

Z = 1.2*(WC/TA) + 1.4*(RE/TA) + 3.3*(EBIT/TA) + 0.6*(MVE/TL) + 1.0*(Sales/TA) Z > 2.99 = Safe Zone, Z < 1.81 = Distress Zone

Installation

pip install pandas numpy
altman-z-score-bankruptcy-prediction-python.py
def calculate_altman_zscore(working_cap, retained_earnings, ebit, mkt_cap_equity, total_liabilities, sales, total_assets):
    x1 = working_cap / total_assets
    x2 = retained_earnings / total_assets
    x3 = ebit / total_assets
    x4 = mkt_cap_equity / total_liabilities
    x5 = sales / total_assets
    
    z = (1.2 * x1) + (1.4 * x2) + (3.3 * x3) + (0.6 * x4) + (1.0 * x5)
    zone = 'SAFE_ZONE' if z > 2.99 else ('GREY_ZONE' if z >= 1.81 else 'DISTRESS_ALERT')
    return {'Altman_Z_Score': round(z, 2), 'Credit_Zone': zone}

Get the Complete 100+ Python Quant & Automation Bundle

Instant lifetime access to all production-ready scripts, valuation models, and trading bots ($19).

Buy Full Bundle on Gumroad ($19) →

Frequently Asked Questions

Q: Can Altman Z-Score be used for banking and NBFC stocks?

Standard Z-Score is designed for manufacturing and non-financial corporates; financial institutions require CAMELS metrics.