portfolioAnalytics.thresholds subpackage

Warning

The Thresholds subpackage has a dependency on transitionMatrix that need to be installed in the same python environment

portfolioAnalytics.thresholds.model module

This module is part of the portfolioAnalytics package.

class portfolioAnalytics.thresholds.model.ConditionalTransitionMatrix(*args: Any, **kwargs: Any)[source]

Bases: TransitionMatrixSet

The ConditionalTransitionMatrix object stores a family of TransitionMatrix objects as a time ordered list.

Its main functionality is to allow conditioning (stressing) the values in accordance with a predefined model

fit(AR_Model, Scenario, rho, ri)[source]

Calculate conditional transition rates given thresholds and stochastic model

plot_densities(period=None, state=0)[source]

Plot densities.

print_matrix(format_type='Standard', accuracy=2, state=None)[source]

Pretty print a threshold matrix set

Parameters
  • format_type (str) – formating options (Standard, Percent)

  • accuracy (int) – number of decimals to display

class portfolioAnalytics.thresholds.model.ThresholdSet(ratings=None, periods=None, TMSet=None, json_file=None)[source]

Bases: object

The Threshold set object stores a multiperiod migration/default threshold structure as a numpy array.

Todo

Separate integration method from transition data

fit(AR_Model, ri, dt=1.0)[source]

Fit Thresholds given autoregressive model and transition matrix given the initial state ri.

Note

The threshold corresponding to the starting rating is set by convention to NaN. The threshold corresponding to a defaulted state is set by convention to - Infinity. These values are stored in memory as numpy NaN and Infinity value respectively. They are serialized as strings “nan” and “-inf” respectively.

from_json(json_file)[source]

Read from JSON.

plot(rating)[source]

Plot.

print(format_type='Standard', accuracy=2)[source]

Pretty print a threshold matrix set

Parameters
  • format_type (str) – formating options (Standard, Percent)

  • accuracy (int) – number of decimals to display

to_json(json_file=None, accuracy=5)[source]

Convert to JSON.

validate(AR_Model)[source]

Validate calculated Thresholds given autoregressive model

The comparison is accomplished by producing the implied transition matrix and setting against the input set

Todo

Automate the comparison when a new set is produced

portfolioAnalytics.thresholds.model.integrate_f(ff, x, an, dx, dt, mu, phi_1)[source]

Integrate F.

portfolioAnalytics.thresholds.model.integrate_g(ff, x, an, dx, dt, mu, phi_1)[source]

Integrate G.

ThresholdSet

The Threshold set object stores a multiperiod migration/default threshold structure as a numpy array.

Todo

Separate integration method from transition data

Integrate G

Integrate G.

Integrate F

Integrate F.