The SN Rating Model is a configurable, Python‑based corporate credit rating engine with an Excel front‑end. It lets you align the rating logic to your own risk appetite and governance: define financial ratios, qualitative factors, distress hardstops, sovereign caps, and outlook rules in clear Excel templates, while the core logic runs in a clean, inspectable Python package. You get transparent, explainable ratings – not a black‑box vendor model.
This repository contains the latest and actively maintained SN Rating Model. Earlier implementations of the SN Rating Model are deprecated and kept only for historical reference; they will not receive new features or bug fixes.
The SN Rating Model is a transparent, configurable corporate credit scoring engine that maps a 0–100 score to a rating grade from AAA to C via an Excel‑driven workflow. It uses generic, illustrative financial ratios and scoring bands that have not been probability‑of‑default (PD) validated or approved for regulatory capital or IFRS 9/CECL use. It is intended for educational, exploratory and prototype purposes only.
Users can adjust ratio bands and factor weights in Excel and may calibrate the score‑to‑PD or grade mapping within their own validated frameworks and governance.
The project supports two main use cases:
- Windows executable workflow for non‑technical users
- Python source workflow for developers and analysts
The model reads Excel input data, applies scoring rules defined in configuration files, and generates an Excel rating report.
You can get the project code in two main ways:
- Using
git clone(recommended if you use Git / plan to update regularly) - Downloading a ZIP (quick one‑off download)
-
Make sure Git is installed on your machine.
- On Windows, you can install Git from: https://git-scm.com/downloads
- On macOS, Git is usually available via Xcode Command Line Tools or Homebrew.
- On Linux, install via your package manager (e.g.
sudo apt install git).
-
Open the GitHub repository page in your browser:
https://github.com/snlabs-tech/SN-Rating-Model
-
Click the green Code button.
-
In the HTTPS tab, copy the repository URL, which should look like:
https://github.com/snlabs-tech/SN-Rating-Model.git -
Open a terminal (Command Prompt, PowerShell, Git Bash, or any shell).
-
Change to the directory where you want to clone the project:
cd /path/to/your/projects -
Run the clone command:
git clone https://github.com/snlabs-tech/SN-Rating-Model.git
-
Move into the cloned repository:
cd SN-Rating-Model
You now have a local working copy of the repository.
Use this if you have an SSH key configured with GitHub.
-
Configure an SSH key with your GitHub account (if not already done).
See: https://docs.github.com/en/authentication/connecting-to-github-with-ssh -
Open the repo page:
https://github.com/snlabs-tech/SN-Rating-Model
-
Click the green Code button, switch to the SSH tab, and copy the SSH URL:
git@github.com:snlabs-tech/SN-Rating-Model.git -
In your terminal:
cd /path/to/your/projects git clone git@github.com:snlabs-tech/SN-Rating-Model.git cd SN-Rating-Model
-
Open the GitHub repository page:
https://github.com/snlabs-tech/SN-Rating-Model
-
Click the green Code button.
-
Click Download ZIP.
-
Once downloaded, unzip the file into your desired folder.
-
The unzipped folder contains the project files; you can open it in your editor or run the code from there.
Once you have the project locally:
- Navigate into the project directory:
cd SN-Rating-Model - Follow the project’s README instructions to set up Python dependencies and run:
or use the
python run_sn_rating.py
windows_bundleas described in the documentation, if you prefer the packaged executable.
SN-Rating-Model/
├── windows_bundle/ # Standalone Windows execution package
│ ├── run_sn_rating.bat # Batch wrapper around the .exe
│ ├── Run_SN_RatingModel.exe # Packaged Windows executable
│ ├── input/
│ │ ├── sn_rating_input.xlsx # Company info input template
│ │ └── sn_rating_config.xlsx # Configuration workbook
│ └── output/ # Created at runtime, holds rating reports
│
├── src/ # Python execution package
│ ├── input/
│ │ ├── sn_rating_input.xlsx # Company info input template
│ │ └── sn_rating_config.xlsx # Configuration workbook
│ ├── run_sn_rating.py # Python file for CLI run
│ ├── output/ # Created at runtime, holds rating reports
│ └── sn_rating/ # Core Python package
│ ├── __init__.py # Package metadata
│ ├── config.py # Configuration handling
│ ├── datamodel.py # Data structures and schemas
│ ├── excel_io.py # Excel input logic
│ ├── helpers.py # Utility functions (bands, outlook, etc.)
│ ├── model.py # Rating model logic
│ ├── report.py # Report generation helpers
│ └── run_from_excel.py # Entry point for Excel-based runs
│
├── docs/ # Methodology and workflow documentation
│ ├── 1_User_Manual.md
│ ├── 2_Running_The_Model.md
│ ├── 3_Methodology_Overview.md
│ ├── 4_Quantitative_Factors_and_Ratio_Definitions.md
│ ├── 5_Rating_Outlook_Workflow.md
│ ├── 6_Hardstop_Rating_Workflow.md
│ └── 7_Sovereign_Cap_Workflow.md
│
├── notebooks/ # Exploratory analysis and demos
│ └── sn_rating.ipynb
│
├── requirements.txt # Python dependencies
├── README.md # Main project overview and usage
├── LICENSE # MIT license
└── .gitignore # Git ignore rules
Conceptually, the model applies three layers:
-
Base rating (unconstrained)
Derived from the combined quantitative and qualitative score usingSCORE_TO_RATING, with no distress overlay and no sovereign cap. -
Distress hardstops (optional)
Apply notch‑down adjustments based on a set of configured distress metrics (fromDISTRESS_BANDS), for e.g. interest coverage, DSCR, Altman Z, liquidity or covenant ratios. If nodistress_bandsinput is provided in the Excel config, the model falls back to the three core metrics:interest_coverage,dscr, andaltman_z.
The distress / hardstop mechanism acts like a configurable covenant‑style breach trigger: whenever any configured ratio crosses a specified distress threshold, the model applies the associated downgrade notches to the base rating, subject toMAX_DISTRESS_NOTCHES. -
Sovereign cap (optional)
Ensures the final issuer rating is not better than the specified sovereign rating when the cap is enabled.
The hardstop rating is the outcome after applying the distress layer to the base rating. When enable_hardstops is False, the hardstop rating equals the base rating and the distress layer is effectively inactive.
Distress can also affect the outlook via trend‑based logic that looks at selected distress metrics over time.
For a detailed description, see docs/6_Hardstop_Rating_Workflow.md.
The Windows bundle workflow lets you run the model without installing Python.
windows_bundle/
Open:
input/sn_rating_input.xlsx
and enter the company data (see docs/1_User_Manual.md for details on the metadata, fin_ratios, components, qual_factors, and peers_t0 sheets).
Open:
input/sn_rating_config.xlsx
This workbook controls:
- Ratio scoring bands
- Ratio/family weights
- Scoring directions (via
higher_better/lower_betterconfig sheets, as applicable) - Distress bands (
distress_bandssheet) and global options such asMAX_DISTRESS_NOTCHES.
Make sure both input and config workbooks are saved and closed before running the model.
Double‑click:
run_sn_rating.bat
This calls Run_SN_RatingModel.exe with the configured Excel files.
After execution completes, open:
windows_bundle/output/
The folder will contain the generated rating report Excel file.
- Python 3.x
- Packages listed in
requirements.txt(e.g.pandas,numpy,openpyxl,numexpr, etc.)
Install dependencies into a virtualenv or conda env:
pip install -r requirements.txtClone the repository:
git clone https://github.com/snlabs-tech/SN-Rating-Model.git
cd SN-Rating-Model(Editable install is optional; you can also run directly from source.)
pip install -e .The recommended source‑based entry point is a small script (e.g. run_sn_rating.py) that calls the Excel‑driven runner and writes the report to output/.
From the project root:
python run_sn_rating.pyThis will execute the rating model using the Excel files in src/input/ or windows_bundle/input/ (depending on how run_sn_rating.py is configured) and write the report into an output/ directory.
The Python implementation lives under:
src/sn_rating/
- Loads configuration from
sn_rating_config.xlsxor code defaults. - Manages:
SCORE_TO_RATINGand derivedRATING_SCALE- Ratio scoring bands (
RATIOS_LOWER_BETTER,RATIOS_HIGHER_BETTER) DISTRESS_BANDSandMAX_DISTRESS_NOTCHES(dynamic distress notching)- Optional
DISTRESS_TREND_METRICSfor distress‑trend‑based outlook
Contains the core rating logic, including:
- Financial ratio scoring and bucket averages
- Qualitative factor scoring
- Weighted score aggregation and base rating
- Distress / hardstop notching driven by
DISTRESS_BANDS, with fallback to the three core metrics if the config is empty - Peer positioning (if enabled)
- Sovereign cap logic and final outlook computation.
Provides utilities such as:
BandConfig(band lookup and direction detection)compute_altman_z_from_componentscompute_effective_weightsfor quant vs qual blocksderive_outlook_band_only(band‑based base outlook)derive_outlook_with_distress_trend(adjusts outlook when distress is present and distress metrics are deteriorating; usesDISTRESS_TREND_METRICSif set, or falls back to["interest_coverage", "dscr", "altman_z"]).
Responsible for:
- Reading Excel inputs
- Validating input structures
- Preparing data structures used by
RatingModel.
- Generates the final rating report Excel workbook, typically in the
output/directory.
Implements the Excel‑driven workflow:
- Loads configuration and input workbooks
- Calls the rating model
- Returns structured results that your runner (or the .exe) can write to Excel.
windows_bundle/input/sn_rating_input.xlsx
Contains sheets such as:
metadata– Company identifiers and model switches (sovereign rating/outlook, enable flags, quantitative/qualitative weights).fin_ratios– Financial ratios or base financials used in quantitative scoring (model currently uses T0; prior years can be kept for reference).components– Altman‑Z input components when Altman‑Z is not directly provided as a ratio.qual_factors– 1–5 expert scores for qualitative dimensions.peers_t0– Peer company data for T0, used for peer comparison tables.
See docs/1_User_Manual.md for a detailed field‑by‑field description.
windows_bundle/input/sn_rating_config.xlsx
Defines model parameters including:
-
Ratio scoring bands / thresholds (
lower_better/higher_bettersheets) -
Ratio and family weights
-
Direction assignments (
higher_bettervslower_better) -
Distress configuration:
distress_bandssheet defining metric‑level distress thresholds andnotches_down, plusMAX_DISTRESS_NOTCHESin theotherssheet.Note: The
distress_bandssheet fully overrides the built‑in defaults; if it contains any rows, only the metrics listed there are used for distress. If it is missing or empty, the model falls back to the default bands forinterest_coverage,dscr, andaltman_z. -
Optional quantitative/qualitative global weights and other switches
The current version keeps qualitative mappings (1–5 → points) and some score→grade defaults in code rather than in Excel.
- Distress bands are dynamic: any metric listed in
DISTRESS_BANDS(from defaults or Excel) can trigger covenant‑style hardstops when its value breaches one of the configured thresholds. - The total distress effect is aggregated into
distress_notchesand applied as a downgrade overlay to the base rating, with a floor atMAX_DISTRESS_NOTCHES. - The ratio log in the report includes a
DistressNotchescolumn showing, per metric, whether it contributed to the hardstop. - Distress also feeds into the outlook: when
distress_notches < 0, the model examines trends in selected distress metrics (fromDISTRESS_TREND_METRICSor the default trio) to differentiate weak‑but‑improving from weak‑and‑deteriorating profiles.
See docs/6_Hardstop_Rating_Workflow.md for full details and examples.
For the Windows bundle, results are written to:
windows_bundle/output/
For the Python workflow, results are written to:
output/
(depending on how run_sn_rating.py is configured).
The main output is an Excel rating report that includes:
- The final alphanumeric rating (e.g. BBB, BB+) and total score
- Outlook (e.g. Stable, Positive, Negative)
- A one‑page A4‑style summary of key ratios and qualitative factors
- Peer comparison tables (if peers are provided)
- A log / calculations sheet showing the detailed scoring steps, including per‑ratio bands, weights, distress notches, and peer flags
The model is designed to be configurable via Excel for most practical adjustments.
You can safely adjust:
- Ratio scoring bands and breakpoints
- Ratio and category weights
- Direction assignments for ratios (higher vs lower is better)
- Quantitative vs qualitative block weights (in the
metadatasheet) - Distress bands (
distress_bandssheet) andMAX_DISTRESS_NOTCHES - Sovereign and peer features via TRUE/FALSE flags on
metadata
Avoid changing:
- Sheet names
- Required column headers
- Expected data types and ranges
Structural changes (e.g. adding/removing sheets, changing layouts, modifying qualitative mappings or grade cutoffs) may require updates to the Python source.
This project is licensed under the terms described in the LICENSE file (MIT).
SN Labs
For questions, improvements, or issues, please open an issue in this repository.