SkillAgentSearch skills...

SystemicRisk

A framework for financial systemic risk valuation and analysis.

Install / Use

/learn @TommasoBelluzzo/SystemicRisk

README

Systemic Risk

This framework calculates, analyses and compares the following systemic risk measures:

Some of the aforementioned models have been improved or extended according to the methodologies described in the V-Lab Documentation, which represents a great source of systemic risk measurement.

The project has been published in "MATLAB Digest | Financial Services | May 2019".

If you found it useful to you, please consider making a donation to support its maintenance and development:

PayPal

Requirements

The minimum required MATLAB version is R2014b. In addition, the following products and toolboxes must be installed in order to properly execute the script:

  • Computer Vision System Toolbox
  • Curve Fitting Toolbox
  • Econometrics Toolbox
  • Financial Toolbox
  • Image Processing Toolbox
  • Optimization Toolbox
  • Parallel Computing Toolbox
  • Statistics and Machine Learning Toolbox
  • System Identification Toolbox

Usage

  1. Create a properly structured database (see the section below).
  2. Execute one of the following scripts (they can be edited following your needs and criteria):
    • run.m to perform the computation of systemic risk measures;
    • analyze.m to analyze previously computed systemic risk measures.

Dataset

Datasets must be built following the structure of default ones included in every release of the framework (see Datasets folder). Below a list of the supported Excel sheets and their respective content:

  • Shares: prices or returns expressed in logarithmic scale of the benchmark index (the column can be labeled with any desired name and must be placed just after observation dates) and the firms, with daily frequency.

  • Volumes: trading volume of the firms expressed in currency amount, with daily frequency.

  • Capitalizations: market capitalization of the firms, with daily frequency.

  • CDS: the risk-free rate expressed in decimals (the column must be called RF and must be placed just after observation dates) and the credit default swap spreads of the firms expressed in basis points, with daily frequency.

  • Balance Sheet Components: the balance sheet components of the firms expressed in omogeneous observations frequency, currency and scale, structured as below:

    • Assets: the book value of assets.
    • Equity: the book value of equity.
    • Separate Accounts: the separate accounts of insurance firms.
  • State Variables: systemic state variables, with daily frequency.

  • Groups: group definitions are based on three-value tuples where the Name field represents the group names, the Short Name field represents the group acronyms and the Count field represents the number of firms to include in the group. The sum of the Count fields must be equal to the number of firms. For example, the following groups definition:

    Firms in the Shares Sheet: A, B, C, D, E, F, G, H
    Insurance Companies: 2
    Investment Banks: 2
    Commercial Banks: 3
    Government-sponsored Enterprises: 1

    produces the following outcome:

    "Insurance Companies" contains A and B
    "Investment Banks" contains C and D
    "Commercial Banks" contains E, F and G
    "Government-sponsored Enterprises" contains H

  • Crises: crises can be defined using two different approaches:

    • By Events: based on two-value tuples where the Date field represents the event dates and the Name field represents the event names; every dataset observation matching an event date is considered to be associated to a distress occurrence.
    • By Ranges: based on three-value tuples where the Name field represents the crisis names, the Start Date field represents the crisis start dates and the End Date field represents the crisis end dates; every dataset observation falling inside a crisis range is considered to be part of a distress period.

Notes

  • The minimum allowed dataset must include the Shares sheet with a benchmark index and at least 3 firms. Observations must have a daily frequency and, in order to run consistent calculations, their minimum required amount is 253 for prices (which translates into a full business year plus an additional observation at the beginning of the time series, lost during the computation of returns) or 252 for logarithmic returns. They must have been previously validated and preprocessed by:

    • discarding illiquid series (unless necessary);
    • detecting and removing outliers;
    • removing rows with NaNs or filling the gaps through interpolation.
  • It is not mandatory to include financial time series used by unwanted measures. Optional financial time series used by included measures can be omitted, as long as their contribution isn't necessary. Below a list of required and optional time series for each category of measures:

    • Bubbles Detection Measures:
      • Required: shares (prices).
      • Optional: none.
    • Component Measures:
      • Required: shares (any).
      • Optional: none.
    • Connectedness Measures:
      • Required: shares (any).
      • Optional: groups.
    • Cross-Entropy Measures:
      • Required: shares (any), cds.
      • Optional:
View on GitHub
GitHub Stars182
CategoryFinance
Updated21h ago
Forks81

Languages

MATLAB

Security Score

100/100

Audited on Mar 31, 2026

No findings