fintech-algorithms
Using a coding agent? Give it the skill: npx skills add IslamBaraka90/Fintech-Algorithms-Library What it does →

Point-in-Time PD

Install and import#

bash
npm install fintech-algorithms
ts
import { pointInTimePd } from "fintech-algorithms/credit-risk-and-default/probability-of-default/point-in-time-pd";

Signature#

pointInTimePd(through_the_cycle_pd_value, borrower_log_odds_shift, macro_factor_z, macro_sensitivity, alert_threshold)

Overlays a borrower-specific shift and a macro shift on the log-odds of a through-the-cycle default probability, returning the resulting point-in-time probability and the size of each shift.

Parameters#

NameTypeNotes
through_the_cycle_pd_valuenumberThe long-run default probability used as the baseline. Converted to log-odds before the overlays are applied.
exclusive_min: 0 · exclusive_max: 1
borrower_log_odds_shiftnumberAn additive adjustment in log-odds space carrying borrower-specific information. Positive values raise the probability.
macro_factor_znumberThe macroeconomic factor value for the period, multiplied by macro_sensitivity to give the macro shift.
macro_sensitivitynumberHow strongly the log-odds respond to the macro factor. This package's convention requires it to be zero or greater.
min: 0
alert_thresholdnumberThe probability at or above which the borrower is flagged, compared with the point-in-time probability using a greater-than-or-equal test.
exclusive_min: 0 · exclusive_max: 1

Returns#

{ through_the_cycle_pd: number; baseline_log_odds: number; borrower_log_odds_shift: number; macro_log_odds_shift: number; point_in_time_pd: number; cycle_uplift: number; alert_threshold: number; state: string; reason: string }

baseline_log_odds is the log-odds of the supplied long-run probability and macro_log_odds_shift is sensitivity times factor. point_in_time_pd is the logistic transform of the baseline plus both shifts, and cycle_uplift is that probability minus the long-run one. state is at-or-above-alert or below-alert, and reason records that this overlay is a declared package convention rather than a universal regulatory or accounting formula.

Errors#

  • When any argument is not a finite number — throws Error
  • When through_the_cycle_pd_value or alert_threshold is not strictly between zero and one — throws Error
  • When macro_sensitivity is negative — throws Error

Complexity: time O(1), space O(1).

Worked example#

verified This is the worked example published in the article, replayed by the test suite on every run. The output cannot drift.

Input#

through_the_cycle_pd_value
0.03
borrower_log_odds_shift
0.25
macro_factor_z
0.8
macro_sensitivity
0.55
alert_threshold
0.06

Call#

pointInTimePd(through_the_cycle_pd_value, borrower_log_odds_shift, macro_factor_z, macro_sensitivity, alert_threshold)

Returns#

object with 9 fields: through_the_cycle_pd, baseline_log_odds, borrower_log_odds_shift, macro_log_odds_shift, point_in_time_pd, cycle_uplift, alert_threshold, state, …

{
  "through_the_cycle_pd": 0.03,
  "baseline_log_odds": -3.476098689835,
  "borrower_log_odds_shift": 0.25,
  "macro_log_odds_shift": 0.44,
  "point_in_time_pd": 0.058080015587,
  "cycle_uplift": 0.028080015587,
  "alert_threshold": 0.06,
  "state": "below-alert",
  "reason": "declared-log-odds-overlay-not-universal-ifrs-or-regulatory-formula"
}

Other exports#

This module also exports logisticPdModel, probitPdModel, throughTheCyclePd, mertonDistanceToDefault, campbellHilscherSzilagyiDistressProbability, bharathShumwayNaiveDistanceToDefault, calculate. Every module additionally exports run as an alias of its primary function, and a meta object carrying its catalog id, domain, family, shape and article URL.

Diagrams#

Point-in-Time PD — article hero
Point-in-Time PD — evidence clock
Point-in-Time PD — formula anatomy
Point-in-Time PD — method comparison
Point-in-Time PD — system map
Point-in-Time PD — validation layers

Calculation flow#

Point-in-Time PD calculation flow
flowchart LR
    S1["Freeze target horizon TTC anchor scenario vintage and "]
    S2["Convert TTC PD to baseline logodds"]
    S3["Calculate borrower and macro shifts separately"]
    S4["Add shifts and apply a stable sigmoid"]
    S5["Return PIT PD uplift contributions threshold state and"]
    S1 --> S2
    S2 --> S3
    S3 --> S4
    S4 --> S5
    S5 --> D{"the TTC anchor must lie strictly inside 01 and scenario di"}
    D --> O["point_in_time_pd + diagnostics"]
    O --> A["Audit: macrofactorz  0 and borrower shift  0 reproduces TTC PD"]

How it works#

This page states the contract — how to call it correctly. The article explains the concept: why it works, and where it breaks.

Read the article →

References#

The rest of the Probability of Default family#