Skip to main content

A Python powered library for calculating semi-analytic credit portfolio loss metrics

Project description

portfolioAnalytics

portfolioAnalytics is a Python powered library for the calculation of semi-analytic approximations to portfolio credit models

Functionality

You can use portfolioAnalytics to create semi-analytic loss distributions for a variety of stylized credit portfolios. The library provides semi-analytical functions useful for testing the accuracy of credit portfolio simulation models. The basic formulas are reasonably simple and well known: They underpin the calculation of RWA (risk weighted assets), and in turn required capital, thus ensuring stability for the entire banking systems worldwide. You can also use the library to estimate transition thresholds for stochastic processes

NB: portfolioAnalytics is still in active development. If you encounter issues please raise them in our github repository

Vasicek Portfolio Models Library

Dependencies: scipy, sympy

Portfolio Model Examples

Check the jupyter notebooks and python scripts

Current Functions

  • vasicek_base

  • vasicek_base_el

  • vasicek_base_ul

  • vasicek_lim

  • vasicek_lim_el

  • vasicek_lim_ul

  • vasicek_lim_q

The Vasicek Base family produces finite pool loss probabilities and measures (EL, UL)

The Vasicek Lim family produces asymptotic pool loss probabities and measures (EL, UL, Quantile)

Limitations

The portfolioAnalytics library provides a range of powerful modelling functionalities that are are of relevance in real credit portfolio management activities. Yet achieving the tractability and usability of a semi-analytic calculation suite is not without some tradeoffs. Several simplifications are made (extensively documented in the Mathematical Documentation). Those simplifications imply that when using the portfolioAnalytics models to assess the risk in actual portfolios it is important to assess

Installation

You can install and use the portfolioAnalytics package in any system that supports the Scipy ecosystem of tools

Dependencies

  • portfolioAnalytics requires Python 3

  • the thresholds module depends on the Open Risk transitionMatrix and correlationMatrix libraries

  • It depends on numerical and data processing Python libraries (Numpy, Scipy, Pandas)

  • The Visualization API depends on Matplotlib

  • The precise dependencies are listed in the requirements.txt file.

  • portfolioAnalytics may work with earlier versions of these packages but this has not been tested

From PyPi

pip3 install pandas
pip3 install matplotlib
pip3 install portfolioAnalytics

From sources

Download the sources to your preferred directory:

git clone https://github.com/open-risk/portfolioAnalytics

Using virtualenv

It is advisable to install the package in a virtualenv so as not to interfere with your system’s python distribution

virtualenv -p python3 tm_test
source tm_test/bin/activate

If you do not have pandas already installed make sure you install it first (will also install numpy)

pip3 install pandas
pip3 install matplotlib
pip3 install -r requirements.txt

Finally issue the install command and you are ready to go!

python3 setup.py install

File structure

The distribution has the following structure:

portfolioAnalytics The library source code
estimators Estimator methods (TODO)
utils Helper classes and methods
thresholds Algorithms for calibrating AR(n) process thresholds to input transition rates
vasicek Collection of portfolio analytic solutions
creditmetrics Analytic calculation of variance for credit metrics style models
examples Usage examples
datasets Contains a variety of datasets useful for getting started with portfolioAnalytics
tests Testing suite

Testing Framework

It is a good idea to run the test-suite. Before you get started:

  • Adjust the source directory path in portfolioAnalytics/__init__ and then issue the following in at the root of the distribution

  • Unzip the data files in the datasets directory

python3 test.py

Getting Started

Check the Examples pages in this documentation

Look at the examples directory for a variety of typical workflows.

For more in depth study, the Open Risk Academy has courses elaborating on the use of the library

Project details


Release history Release notifications | RSS feed

This version

0.4

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

creditPortfolioAnalytics-0.4.tar.gz (148.2 kB view details)

Uploaded Source

Built Distribution

creditPortfolioAnalytics-0.4-py2.py3-none-any.whl (81.2 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file creditPortfolioAnalytics-0.4.tar.gz.

File metadata

  • Download URL: creditPortfolioAnalytics-0.4.tar.gz
  • Upload date:
  • Size: 148.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.8.0 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for creditPortfolioAnalytics-0.4.tar.gz
Algorithm Hash digest
SHA256 3d4c8af43395890159693c868e966fe518b06f7a30c78dd65b8eb8bd95e34c6b
MD5 012fcabfd4db8bf0b69ca1121c78fb46
BLAKE2b-256 7f2e23336a5d58e0a0bcdb9c28e9295c11b0248e5105151452a992c165827130

See more details on using hashes here.

File details

Details for the file creditPortfolioAnalytics-0.4-py2.py3-none-any.whl.

File metadata

  • Download URL: creditPortfolioAnalytics-0.4-py2.py3-none-any.whl
  • Upload date:
  • Size: 81.2 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.3 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.8.0 tqdm/4.51.0 CPython/3.6.9

File hashes

Hashes for creditPortfolioAnalytics-0.4-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 ba410d8dae4792a5aacce03f67a96694d4fc56b83a02defa694c9b797fbf74da
MD5 3d17437e2a5fb3989ebb87b846c467f2
BLAKE2b-256 31b6c1ec1b33e010196a2e8fe86e8f3a4c10026216668638c583ffc20844d631

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page