GithubHelp home page GithubHelp logo

agjftucker / network-pricing Goto Github PK

View Code? Open in Web Editor NEW

This project forked from marcobardoscia/neva

0.0 1.0 0.0 6.09 MB

Network valuation in financial systems

License: GNU Lesser General Public License v3.0

Python 92.81% Jupyter Notebook 7.19%

network-pricing's Introduction

(AT) My contribution is contained mainly in the file lattice.py. It may be invoked thus:

import neva

# parsing data
bsys, params = neva.parse_csv('data/balance_sheets.csv', 'data/exposures_table.csv', 'data/covar_list.csv')

# Geometric Brownian Motion on external assets, with covariance matrix supplied.
covar = {(b1, b2): params[b1]['covar'][b2] for b1 in params for b2 in params[b1]['covar']}
bsys = neva.BankingSystemCorrelatedGBM.with_covar_asset(bsys, covar)

equity_delta = [0.0 for _ in bsys]
neva.shock_and_solve(bsys, equity_delta, method='', solve_assets=False)

Neva: Network Valuation in financial systems

This package is an implementation of the Neva framework introduced in [1]. Neva allows to perform the valuation of equities of banks that hold cross-holding of debt. Several known contagion algorithms (e.g. Furfine, Eisenberg and Noe, and Linear DebtRank) are special cases of Neva.

The package has been used to run the simulations in [2].

Advice

Users of the package should read (at least) the documentation in the following modules:

  • bank.py: for a general overview of the model
  • ibeval.py: for an introduction to valuation functions
  • parse.py: for the format of input data

Data

Input data can be in several formats. The simplest possibility is to provide two files, one holding the information on banks' balance sheets and one containing the exposures. Exposures can be given either as a list or as a table. For examples, see balance_sheets.csv, exposures_list.csv, and exposures_table.csv.

It is also possible to provide all data in a single JSON file, see parse.py for a full specification.

Simplest example

In the simplest example we will run the Eisenberg and Noe algorithm without any shocks to equities.

import neva

# parsing data
bsys, params = neva.parse_csv('balance_sheets.csv', 'exposures_table.csv')

# running Eisenberg and Noe (without any shock to equities)
equity_shock = [0.0 for _ in bsys]
neva.shock_and_solve(bsys, equity_shock, method='eisenberg_noe',
                                         solve_assets=False)

# reading final equities
equity_final = bsys.history[-1]

# computing payment vectors
pay_vec = [bnk.ibliabtot if bnk.equity >= 0 else
           max(bnk.equity + bnk.ibliabtot, 0.0) for bnk in bsys]

A more complex example

Here we run an analysis simalr to that run in [2].

import neva

# parsing data
bsys, params = neva.parse_csv('balance_sheets.csv', 'exposures_table.csv')

# Geometric Browianian Motion on external assets, whose volatility is
# estimated via the volatility of equities.
sigma_equity = [float(params[bnk]['sigma_equity']) for bnk in params]
bsys = neva.BankingSystemGBMse.with_sigma_equity(bsys, sigma_equity)
    
# storing initial equity
equity_start = bsys.get_equity()

# shocks to initial equity: 50%
equity_delta = equity_start[:]
equity_delta = [e * 0.5 for e in equity_start]

# running ex-ante Black and Cox, as in [2] 
# with recovery rate equal to 60%
recovery_rate = [0.6 for _ in bsys] 
neva.shock_and_solve(bsys, equity_delta, 'exante_en_blackcox_gbm', 
                     solve_assets=False, recovery_rate=recovery_rate)

# reading equities after one round and after all rounds   
equity_direct = bsys.history[1]
equity_final = bsys.history[-1]

Compatibility

We will target the latest release of Python 3 and, as long as possible, Python 2.7. Only built-in packages are required.

References

[1] Paolo Barucca, Marco Bardoscia, Fabio Caccioli, Marco D'Errico, Gabriele Visentin, Stefano Battiston, and Guido Caldarelli. Network Valuation in Financial Systems (2016). Available at SSRN.

[2] Marco Bardoscia, Paolo Barucca, Adam Brinley Codd, John Hill. The decline of solvency contagion risk (2017). Bank of England Staff Working Paper No. 662.

network-pricing's People

Contributors

agjftucker avatar marcobardoscia avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.