Financial Research Data Services
Project description
FRDS - Financial Research Data Services
frds is an open-sourced Python package for computing a collection of major academic measures used in the finance literature in a simple and straightforward way.
Installation
pip install frds
Note
This library is still under development and breaking changes may be expected.
If there's any issue (likely), please contact me at mingze.gao@sydney.edu.au
Supported measures
More to be added. For a complete list of supported built-in measures, please check frds.io/measures/.
- Absorption Ratio in Kritzman, Li, Page, and Rigobon (2010).
- Contingent Claim Analysis in Gray and Jobst (2010).
- Distress Insurance Premium in Huang, Zhou, and Zhu (2009).
- Long-Run MES in Brownlees and Engle (2017).
- Marginal Expected Shortfall (MES) in Acharya, Pedersen, Philippon, and Richardson (2010).
- Modified Default Probability in Nagel and Purnanandam (2020)
- SRISK in Brownlees and Engle (2017).
- Systemic Expected Shortfall (SES) in Acharya, Pedersen, Philippon, and Richardson (2010).
- Z-score
Examples
The primary purpose of frds
is to offer ready-to-use functions.
Absorption Ratio
For example, Kritzman, Li, Page, and Rigobon (2010) propose an Absorption Ratio that measures the fraction of the total variance of a set of asset returns explained or absorbed by a fixed number of eigenvectors. It captures the extent to which markets are unified or tightly coupled.
>>> import numpy as np
>>> from frds.measures import absorption_ratio
>>> data = np.array( # Hypothetical 6 daily returns of 3 assets.
... [
... [0.015, 0.031, 0.007, 0.034, 0.014, 0.011],
... [0.012, 0.063, 0.027, 0.023, 0.073, 0.055],
... [0.072, 0.043, 0.097, 0.078, 0.036, 0.083],
... ]
... )
>>> absorption_ratio.estimate(data, fraction_eigenvectors=0.2)
0.7746543307660252
Distress Insurance Premium
Another example, Distress Insurance Premium (DIP) proposed by Huang, Zhou, and Zhu (2009) as a systemic risk measure of a hypothetical insurance premium against a systemic financial distress, defined as total losses that exceed a given threshold, say 15%, of total bank liabilities.
>>> from frds.measures import distress_insurance_premium
>>> # hypothetical implied default probabilities of 6 banks
>>> default_probabilities = np.array([0.02, 0.10, 0.03, 0.20, 0.50, 0.15]
>>> correlations = np.array(
... [
... [ 1.000, -0.126, -0.637, 0.174, 0.469, 0.283],
... [-0.126, 1.000, 0.294, 0.674, 0.150, 0.053],
... [-0.637, 0.294, 1.000, 0.073, -0.658, -0.085],
... [ 0.174, 0.674, 0.073, 1.000, 0.248, 0.508],
... [ 0.469, 0.150, -0.658, 0.248, 1.000, -0.370],
... [ 0.283, 0.053, -0.085, 0.508, -0.370, 1.000],
... ]
... )
>>> distress_insurance_premium.estimate(default_probabilities, correlations)
0.28661995758
Modified Default Probability (bank)
More examples. Nagel and Purnanandam (2020) introduce the Modified Default Probability for banks. Banks' assets are contingent claims on borrowers' collateral assets, hence banks' equity and debt are contingent claims on these contingent claims. While borrowers' assets value may follow a lognormal distribution, banks' assets do not.
Below is a one-liner replication of the simulations.
>>> from frds.measures.modified_merton import mod_merton_simulation
>>> mod_merton_simulation.simulate()
----------------------------------------------------------------------------
Borrower asset value
----------------------------------------
No shock +ve shock -ve shock
----------------------------------------------------------------------------
A. True properties
Agg. Borrower Asset Value 1.06 1.33 0.85
Bank Asset Value 0.74 0.79 0.67
Bank Market Equity/Market Assets 0.12 0.16 0.07
Bank 5Y RN Default Prob. 0.23 0.11 0.49
Bank Credit Spread (%) 0.50 0.19 1.37
----------------------------------------------------------------------------
B. Misspecified estimates based on standard Merton model
Merton 5Y RN Default Prob. 0.13 0.01 0.58
Merton Credit Spread (%) 0.12 0.00 1.54
----------------------------------------------------------------------------
These results are largely the same as Table 1 in Nagel and Purnanandam (2020). Additionally, several plots will be saved in the working directory, e.g., Figure 2:
And another sample output, Figure 4:
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for frds-2.0.0rc4-cp311-cp311-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f85eedd898d78e81c629b26675b7daf49bc305330309662576846e447b3c839 |
|
MD5 | 214199e9d25a44d0dbc4fdcc1e0c5893 |
|
BLAKE2b-256 | bcfab88d1334e049d0cae045381da3c696628cbbe57a38098ffde0b5ab3a7598 |
Hashes for frds-2.0.0rc4-cp311-cp311-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2e8f1928f241e97bfdf268d80ca87d251188315cfd2f75512afe5fb51a6f99db |
|
MD5 | 15b485bc691ad84c861c90576bf24f70 |
|
BLAKE2b-256 | d916a332e9144a117aabce970130279b279c8ec7c955074e6c30eba50467ec62 |
Hashes for frds-2.0.0rc4-cp311-cp311-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | beab7096cfee1c6e0778d6fc413d40b25ae4db4130c04219a589bff5dda32ce2 |
|
MD5 | 1c7df45561c4067858efc043eb5a4ae5 |
|
BLAKE2b-256 | d4cb1239b84c8d4e063f904c7235a3785d4acc40c786182a78a833ae74be4f24 |
Hashes for frds-2.0.0rc4-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 521e5c30a7f3a5036576c3a093a4f0fc417eae25a2227a2d242b655848b6496f |
|
MD5 | 9ff675e8b81235e0fd5c1c36e7956c07 |
|
BLAKE2b-256 | 99dfbd0150432648fb4204a931f02841dfabf23ef39ed624acc5ce2f6d9c7a66 |
Hashes for frds-2.0.0rc4-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c9b3de7244bab44ceac7063bb874ffb478278e56f9d5bb2cc985fc3ba6b32e9c |
|
MD5 | b1d3a02bdbcf292c773b7ad53f2d1f2a |
|
BLAKE2b-256 | e7e26f23534d48b155ddf1672fc3af6fd788a5de0c69d763c66538a1e5b064f4 |
Hashes for frds-2.0.0rc4-cp310-cp310-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 43b528dfed3e8c91c759c6b5a19bb106d23b374096c05146541ef22f4bf914e8 |
|
MD5 | 2deae503f0244e8969a18ae454133041 |
|
BLAKE2b-256 | 2ee448b4a988cd3dfd1bb7db6106e82a696da42b5f001fcd922a594d6d49afb0 |
Hashes for frds-2.0.0rc4-cp310-cp310-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 04762d299e30675f946165108bf76e3fb3071f6ad0fd770a842de57f44b22e32 |
|
MD5 | 472700572d4d5bf012b09b365ec6431e |
|
BLAKE2b-256 | 6ecd096dbe9e508659a495ce60689475836d5cf1e5abdaeca4b220b1062275a2 |
Hashes for frds-2.0.0rc4-cp310-cp310-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55f1fac86a5c830cadfc5d56660600c37bca15530e2286fe03d31204969ec333 |
|
MD5 | 642679af1e75c4309237ff788f88e2c0 |
|
BLAKE2b-256 | ed397e42ec5a233e70babfd3f572884b64c3906e64216c393b36a4bc4a95d276 |
Hashes for frds-2.0.0rc4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 666bae0281b6085f51116514d41236d2d52b3106c4fc8a47d78cd9c2793119d7 |
|
MD5 | 47299c621af77039a278e601e37c7122 |
|
BLAKE2b-256 | e51dcec19c37520f691dbe18fa71befa0c5959a20000d92c0559c969ab62fc13 |
Hashes for frds-2.0.0rc4-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0cae65cbfe71c08dbea81e914b1a3d695c085176e7ab92fca5857e397de952ae |
|
MD5 | 046611b84ad665a9455af1b028ff89c3 |
|
BLAKE2b-256 | 41b36259e07c7c4548e91521c1ed248e221ba316843e07c4262c7c8e4a5d3f1d |
Hashes for frds-2.0.0rc4-cp39-cp39-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 85bb20258c00e63c7b2ab5b77a5bf950ea70a226353b63f0a7ca83f7f134af51 |
|
MD5 | 388bf37d1ebfedba86c40f7c3e74d414 |
|
BLAKE2b-256 | a19198038e7b75869debaedd1fb2eef98f5735a57bbf9e4ed416109a47c5fe9f |
Hashes for frds-2.0.0rc4-cp39-cp39-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e23d1543a1774ab4e376b358e45715db4f37da17f4d9d04c5a2f2fe5d1078557 |
|
MD5 | 6ba2d4ff89397d7034abaa08c64ba35c |
|
BLAKE2b-256 | 0b4030aaed7455e5ca5d5a127b17cef2905363a32bd8ee8e1c06706813d86c49 |
Hashes for frds-2.0.0rc4-cp39-cp39-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d8b6ba49e342fa69bd776aabfaeb7c998da85b3f0624fe9a77bddd1a52e7158 |
|
MD5 | f86fc8a2122dbf25b65d80c52b39a8a3 |
|
BLAKE2b-256 | a7badf8959d3081dba86bd3271a89f26361cb14c2c001b5a0b061830afed6e54 |
Hashes for frds-2.0.0rc4-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0bf6676bf59fb20f0223b036c32a4c23e2efa06e1f423ab001f5c55606b59e7b |
|
MD5 | d6a2a3d28f305e95e2244eca3e0ffb2e |
|
BLAKE2b-256 | ac8f54941e04ed4dfc9419df45bc5c032f8113543c62dba213c435b17b83dc33 |
Hashes for frds-2.0.0rc4-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2526ada86a2273c9c3d09de2f5a704e11e3e72be5c5f3aa162c4cf60b6e311e9 |
|
MD5 | 7cc773ea21f1b9ee1d727eaaea55bb28 |
|
BLAKE2b-256 | 90fde4b43b00dfb60cd503187437987af9de5518403663ade7dce2b4960f6e97 |
Hashes for frds-2.0.0rc4-cp38-cp38-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec3af62f857ae9ed160c606ba4ff63462218a3b5ed82e254421482b995535ab7 |
|
MD5 | 2fbe8f0981ffb0f43a5c55b2ee95fc79 |
|
BLAKE2b-256 | 65019984237e0e2d04a64e1ad16045b4b046458ac8780893b585c4dc74a8505a |
Hashes for frds-2.0.0rc4-cp38-cp38-win32.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9227cdd4ec41da72259f35cb3927fc1c45ee96a1f3786f3c04430af9ea1c2141 |
|
MD5 | 118df8999a7197ea71fb577591e79d5e |
|
BLAKE2b-256 | 972b2493005716cae56135751a1ca5827da6e672716bd1819876c789a3544ceb |
Hashes for frds-2.0.0rc4-cp38-cp38-musllinux_1_1_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f91d0721208ceaeed78eae2c34995fced35a71dfea1b7b8a923cbf00a712039d |
|
MD5 | 45516553be48be5552519c3787b168c6 |
|
BLAKE2b-256 | 0665a897632eaf915bf574be1fbc6a27cf1d3bb5d7664a0cbfff4425a521d7aa |
Hashes for frds-2.0.0rc4-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0f586ddbd6f308ad652db1af116ed3c3e5ef08926aa382fc9a70e93362205903 |
|
MD5 | 4661b1dcb6f490bac4322105aea999ea |
|
BLAKE2b-256 | f868cf2107dc1104b4ca85872255a624d8963f1cf66ed663733f1b7c0d6d2d1a |
Hashes for frds-2.0.0rc4-cp38-cp38-macosx_10_9_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1af0c43df20ea8514400b1f6fc221b6f30ff415e23bdfb180b77cbfad3acb0d1 |
|
MD5 | d6f3995d1866f3458b804b573a74c069 |
|
BLAKE2b-256 | 64d62374952f3db92bc041cb9d2bd7d3a5c9237c2c45ba48f0e0d847b78683d2 |