Metadata-Version: 2.1
Name: pyratings
Version: 0.5.4
Summary: Collection of functions in order to translate ratings from various rating agencies into equivalent rating scores and vice versa.
Keywords: ratings,credit ratings,rating scores
Author-email: HSBC <opensource@hsbc.com>
Requires-Python: >=3.9
Description-Content-Type: text/x-rst
Classifier: Development Status :: 4 - Beta
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Topic :: Office/Business :: Financial
Classifier: Topic :: Office/Business :: Financial :: Accounting
Classifier: Topic :: Office/Business :: Financial :: Investment
Classifier: Typing :: Typed
Requires-Dist: numpy>=1.23.0
Requires-Dist: pandas>=1.4.3
Requires-Dist: black>=22.6.0 ; extra == "dev"
Requires-Dist: pytest>=7.1.2 ; extra == "dev"
Requires-Dist: pytest-cov>=3.0.0 ; extra == "dev"
Requires-Dist: tox>=3.25.1 ; extra == "dev"
Requires-Dist: jupyter>=1.0.0 ; extra == "doc"
Requires-Dist: nbsphinx>=0.8.9 ; extra == "doc"
Requires-Dist: numpydoc>=1.4.0 ; extra == "doc"
Requires-Dist: openpyxl>=3.0.10 ; extra == "doc"
Requires-Dist: pandoc>=2.2 ; extra == "doc"
Requires-Dist: sphinx>=5.0.2 ; extra == "doc"
Requires-Dist: sphinx-rtd-theme>=1.0.0 ; extra == "doc"
Project-URL: BugTracker, https://github.com/hsbc/pyratings/issues
Project-URL: Changelog, https://github.com/hsbc/pyratings/blob/main/CHANGELOG.rst
Project-URL: Documentation, https://hsbc.github.io/pyratings/
Project-URL: Homepage, https://github.com/hsbc/pyratings
Project-URL: Repository, https://github.com/hsbc/pyratings
Provides-Extra: dev
Provides-Extra: doc

***********************************************************************
pyratings - Working with credit ratings, professionally and efficiently
***********************************************************************

Documentation
=============
| The full documentation can be found at https://hsbc.github.io/pyratings/.
| A "Getting started" section shows the relevant functions provided by `pyratings` in
  order to compute an average credit rating for a portfolio with multiple securities.


Capabilities
=============

| This library consists of functions, which will be helpful in order to work with credit
  ratings in a ``pandas.DataFrame``.
| `pyratings` offers the following capabilities:

* Preparing regular ratings for further processing, i.e. stripping off of rating watches.
* Transform long- and short-term ratings into rating scores and vice versa.
* Compute best/second best/worst ratings on a security level basis within a
  portfolio context.
* Compute average ratings/rating scores on a portfolio level.
* Compute Weighted Average Rating Factor (WARF) on a portfolio level.
* Compute WARF buffer, i.e. distance from current WARF to next maxWARF.

Transformations from ratings to scores/WARF and vice versa will take place according to the following translation table:

Long-term ratings

+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
| Moody’s |  S&P | Fitch |  ICE | DBRS | Bloomberg | Score |  WARF | MinWARF* | MaxWARF* |
+=========+======+=======+======+======+===========+=======+=======+==========+==========+
|   Aaa   |  AAA |  AAA  |  AAA |  AAA |    AAA    |     1 |     1 |        1 |        5 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Aa1   |  AA+ |  AA+  |  AA+ |  AAH |    AA+    |     2 |    10 |        5 |       15 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Aa2   |  AA  |   AA  |  AA  |  AA  |     AA    |     3 |    20 |       15 |       30 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Aa3   |  AA- |  AA-  |  AA- |  AAL |    AA-    |     4 |    40 |       30 |       55 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    A1   |  A+  |   A+  |  A+  |  AH  |     A+    |     5 |    70 |       55 |       95 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    A2   |   A  |   A   |   A  |   A  |     A     |     6 |   120 |       95 |      150 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    A3   |  A-  |   A-  |  A-  |  AL  |     A-    |     7 |   180 |      150 |      220 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Baa1  | BBB+ |  BBB+ | BBB+ | BBBH |    BBB+   |     8 |   260 |      220 |      310 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Baa2  |  BBB |  BBB  |  BBB |  BBB |    BBB    |     9 |   360 |      310 |      485 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Baa3  | BBB- |  BBB- | BBB- | BBBL |    BBB-   |    10 |   610 |      485 |      775 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Ba1   |  BB+ |  BB+  |  BB+ |  BBH |    BB+    |    11 |   940 |      775 |     1145 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Ba2   |  BB  |   BB  |  BB  |  BB  |     BB    |    12 |  1350 |     1145 |     1558 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Ba3   |  BB- |  BB-  |  BB- |  BBL |    BB-    |    13 |  1766 |     1558 |     1993 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    B1   |  B+  |   B+  |  B+  |  BH  |     B+    |    14 |  2220 |     1993 |     2470 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    B2   |   B  |   B   |   B  |   B  |     B     |    15 |  2720 |     2470 |     3105 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    B3   |  B-  |   B-  |  B-  |  BL  |     B-    |    16 |  3490 |     3105 |     4130 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Caa1  | CCC+ |  CCC+ | CCC+ | CCCH |    CCC+   |    17 |  4770 |     4130 |     5635 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Caa2  |  CCC |  CCC  |  CCC |  CCC |    CCC    |    18 |  6500 |     5635 |     7285 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|   Caa3  | CCC- |  CCC- | CCC- | CCCL |    CCC-   |    19 |  8070 |     7285 |     9034 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    Ca   |  CC  |   CC  |  CC  |  CC  |     CC    |    20 |  9998 |     9034 |   9998.5 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    C    |   C  |   C   |   C  |   C  |     C     |    21 |  9999 |   9998.5 |   9999.5 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+
|    D    |   D  |   D   |   D  |   D  |    DDD    |    22 | 10000 |   9999.5 |    10000 |
+---------+------+-------+------+------+-----------+-------+-------+----------+----------+

`MinWARF` is inclusive, while `MaxWARF` is exclusive.

Short-term ratings

+---------+------+-------+------------+-------+
| Moody's |  S&P | Fitch |    DBRS    | Score |
+=========+======+=======+============+=======+
|   P-1   | A-1+ |  F1+  | R-1 (high) |     1 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  |  R-1 (mid) |     2 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  |  R-1 (low) |     3 |
+---------+------+-------+------------+-------+
|   ---   |  A-1 |   F1  | R-2 (high) |     5 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  |  R-2 (mid) |     6 |
+---------+------+-------+------------+-------+
|   P-2   |  A-2 |   F2  |  R-2 (low) |     7 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  | R-3 (high) |     8 |
+---------+------+-------+------------+-------+
|   P-3   |  A-3 |   F3  |  R-3 (mid) |     9 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  |  R-3 (low) |    10 |
+---------+------+-------+------------+-------+
|    NP   |   B  |  ---  |     R-4    |    12 |
+---------+------+-------+------------+-------+
|   ---   |  --- |  ---  |     R-5    |    15 |
+---------+------+-------+------------+-------+
|   ---   |   C  |  ---  |     ---    |    18 |
+---------+------+-------+------------+-------+
|   ---   |   D  |  ---  |      D     |    22 |
+---------+------+-------+------------+-------+

Dependencies
============
| This library supports Python >= 3.9.
| Under the hood `pyratings` only depends on the basic python libraries that are used
  for matrix and dataframe manipulation:

* numpy
* pandas
