portfolioAnalytics.utils subpackage

portfolioAnalytics.utils contents

This module contains various helper classes and functions that do not fit into any of the main modules of the library

portfolioAnalytics.utils Submodules

portfolioAnalytics.utils.converters module

Converter utilities to help switch between various formats.

portfolioAnalytics.utils.converters.datetime_to_float(dataframe)[source]

Datetime to float. f .. _Datetime_to_float:

Converts dates from string format to the canonical float format

Parameters

dataframe – Pandas dataframe with dates in string format

Returns

Pandas dataframe with dates in float format

Return type

object

Note

The date string must be recognizable by the pandas to_datetime function.

portfolioAnalytics.utils.dataset_portfolio module

This module provides simple functionality for holding portfolio data for calculation purposes.

  • Portfolio implements a simple portfolio data container

class portfolioAnalytics.utils.portfolio.Portfolio(psize=0, rating=[], exposure=[], factor=[])[source]

Bases: object

The Portfolio object implements a simple portfolio data structure. See loan tape for more general structures.

loadjson(data)[source]

Load portfolio data from JSON object.

The data format for the input json object is a list of dictionaries as follows

[{"ID":"1","PD":"0.015","EAD":"40","FACTOR":0},
  ...
 {"ID":"2","PD":"0.286","EAD":"20","FACTOR":0}]
preprocess_portfolio()[source]

Produce some portfolio statistics like total number of entities and exposure weighted average probability of default :return:

portfolioAnalytics.utils.bivariatenormal module

Implementation of the bivariate normal function.

portfolioAnalytics.utils.bivariatenormal.BivariateNormalDensity(a, b, rho)[source]

Bivariate Normal Density.

portfolioAnalytics.utils.bivariatenormal.BivariateNormalDistribution(a, b, rho)[source]

Bivariate Normal Distribution.

based on Z. Drezner, “Computation of the bivariate normal integral”, Mathematics of Computation 32, pp. 277-279, 1978. uses 8-point Gaussian quadrature

portfolioAnalytics.utils.bivariatenormal.N(x)[source]

Standard Normal.

portfolioAnalytics.utils.bivariatenormal.Phi_Sum(a, b, rho)[source]

Phi Sum Helper Function.

portfolioAnalytics.utils.bivariatenormal.rhoc(a, b, rho)[source]

Rho_c Helper Function.