Apache License 2.0

技术解读

以下内容由 GitRead 中文社区 编辑团队基于项目 README 与官方资料整理, 结合中文开发者的常见使用场景补充技术选型建议。具体以项目官方文档为准。

项目背景与痛点

金融系统的稳定性是全球经济健康运行的关键,而系统性金融风险始终是影响这一稳定性的主要因素之一。在这样的背景下,“SystemicRisk” 框架应运而生,其核心目标是通过提供一套工具和算法库,帮助金融机构和监管机构及时评估和分析金融系统的系统性风险。这一框架解决了业界一个长久存在的痛点——缺乏一套标准化且易于使用的系统,来对复杂的金融市场数据进行有效分析,并捕捉风险信号。

核心技术揭秘

“SystemicRisk” 框架的设计体现了事务性和灵活性之间的平衡。通过采用先进的数据处理技术和模型构建技术,该框架实现了对金融市场的复杂数据进行高效率和高准确性的处理与分析。

技术栈与实现原理

  1. 技术栈:框架主要使用 Python 语言实现,结合 NumPy、Pandas、SciPy 等科学计算库,以及 Matplotlib、Seaborn 等绘制库,确保数据处理效率和可视化效果。
  2. 设计模式:该框架采用模块化设计,将不同功能划分为多个类和函数,既保证了系统的灵活性,也便于功能的迭代和扩展。
  3. 数据流:数据从外部系统导入到框架后,会经过预处理、特征提取、风险模型训练与预测等步骤,最终输出风险评估报告。
关键数据流图
graph TD A[数据导入] --> B[数据预处理] B --> C[特征提取] C --> D[模型训练] D --> E[风险预测] E --> F[报告生成] classDef default fill:#fff; class A,B,C,D,E,F default;

功能亮点与差异

“SystemicRisk” 的功能强大且独特。首先,其高度模块化的架构设计,允许开发者根据特定需求定制和扩展功能模块;其次,框架内置了多种流行的风险评估模型,涵盖了从复杂网络分析到经济计量模型的各种方法;最后,框架提供了丰富的可视化功能,支持生成详细的分析报告,帮助用户快速理解模型输出。

应用场景与落地建议

在技术选型上,该框架适用于已经有一定金融数据处理基础,且对系统性金融风险有较高预警需求的金融机构和监管机构。团队成员需要熟练掌握 Python 编程,并对金融时间序列分析、复杂网络理论有一定了解。另外,需要注意的是,框架的稳定性与准确度很大程度上依赖于输入数据的质量,因此在实战部署中,对数据源进行严格的清洗与质量控制是必不可少的。

综合评价

优点

  • 模块化设计大大增加了框架的灵活性和扩展性。
  • 集成了多种金融风险评估模型,适用面广。
  • 提供了丰富的可视化工具和高度定制化的报告生成能力。

缺点

  • 核心功能依赖于复杂的科学计算库,可能提升开发者入门门槛。
  • 框架的质量严重依赖数据质量,需要投入额外精力对数据进行清洗与验证。

“SystemicRisk” 项目是一个优秀的融合了理论与实践的开源框架,其不仅实现了金融系统性风险评估领域的初步技术沉淀,也为未来的进一步发展奠定了基础。对于那些希望快速构建金融风险评估系统的团队,它无疑是一个值得考虑的强大工具。

关于

GitHub 原始描述(英文)

A framework for financial systemic risk valuation and analysis.

描述取自 GitHub 官方 API,保持仓库作者书写的原文。

语言占比

MATLAB

Release

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: capitalizations, balance sheet, groups.
    • Cross-Quantilogram Measures:
      • Required: shares (any).
      • Optional: state variables.
    • Cross-Sectional Measures:
      • Required: shares (any), capitalizations, balance sheet.
      • Optional: separate accounts, state variables.
    • Default Measures:
      • Required: shares (any), capitalizations, cds, balance sheet.
      • Optional: none.
    • Liquidity Measures:
      • Required: shares (prices), volumes, capitalizations.
      • Optional: state variables.
    • Regime-Switching Measures:
      • Required: shares (any).
      • Optional: none.
    • Spillover Measures:
      • Required: shares (any).
      • Optional: none.
    • Tail Dependence Measures:
      • Required: shares (any).
      • Optional: state variables.
  • Firms whose time series value is constantly equal to 0 in the tail, for a span that includes a customizable percentage of total observations (by default 5%), are considered to be defaulted. Firms whose Equity value is constantly negative in the tail, for a span that includes a customizable percentage of total observations (by default 5%), are considered to be insolvent. This allows the scripts to exclude them from computations starting from a certain point in time onward; defaulted firms are excluded by all the measures, insolvent firms are excluded only by SCCA default measures.

  • Once a dataset has been parsed, the script stores its output in the form of a .mat file; therefore, the parsing process is executed only during the first run. The file last modification date is taken into account by the script and the dataset is parsed once again if the Excel spreadsheet is modified.

  • The dataset parsing process might present issues related to version, bitness and regional settings of the OS, Excel and/or MATLAB. Due to the high number of users asking for help, support is no more guaranteed; the guidelines below can help solving the majority of problems:

    • A bitness mismatch between the OS and Excel may cause errors that are difficult to track. Using the same bitness for both is recommended.
    • An Excel locale other than English may produce wrong outputs related to date formats, text values and numerical values with decimals and/or thousands separators. A locale switch is recommended.
    • Both Excel 2019 and Excel 365 may present compatibility issues with MATLAB versions prior to R2019b. In later versions, the built-in function readtable may still not handle some Excel spreadsheets properly. A downgrade to Excel 2016 is recommended.
    • Some Excel spreadsheets might contain empty but defined cells in columns or rows located far away from the area in which data is stored. Those cells extend the range being read by the parser, producing false positives when checking for missing values.
    • The dataset parsing process takes place inside the ScriptsDataset\parse_dataset.m function. It is important to check the correctness of the arguments being passed to the function call. Error messages thrown by the aforementioned function are pretty straightforward and a debugging session should be enough to find the underlying causes and fix datasets and/or internal functions accordingly.
    • If the dataset parsing process is too slow, the best way to speed it up is to provide a standard Excel spreadsheet (.xlsx) with no filters and styles, or a binary Excel spreadsheet (.xlsb).
  • Some scripts may take very long time to finish in presence of huge datasets and/or extreme parametrizations. The performance of calculations may vary depending on the CPU processing speed and the number of CPU cores available for parallel computing.

Example Datasets

The Datasets folder includes many premade datasets. The main one (Example_Large.xlsx), based on the US financial sector, defines the following entities and data over a period of time ranging from 2002 to 2019 (both included):

Benchmark Index: S&P 500
Financial Institutions (20):
  • Group 1: Insurance Companies (5)
    • American International Group Inc. (AIG)
    • The Allstate Corp. (ALL)
    • Berkshire Hathaway Inc. (BRK)
    • MetLife Inc. (MET)
    • Prudential Financial Inc. (PRU)
  • Group 2: Investment Banks (6)
    • Bank of America Corp. (BAC)
    • Citigroup Inc. ©
    • The Goldman Sachs Group Inc. (GS)
    • J.P. Morgan Chase & Co. (JPM)
    • Lehman Brothers Holdings Inc. (LEH)
    • Morgan Stanley (MS)
  • Group 3: Commercial Banks (7)
    • American Express Co. (AXP)
    • Bank of New York Mellon Corp. (BK)
    • Capital One Financial Corp. (COF)
    • PNC Financial Services Inc. (PNC)
    • State Street Corp. (STT)
    • US Bancorp (USB)
    • Wells Fargo & Co. (WFC)
  • Group 4: Government-sponsored Enterprises (2)
    • Federal Home Loan Mortgage Corp / Freddie Mac (FMCC)
    • Federal National Mortgage Association / Fannie Mae (FNMA)
Risk-Free Rate: 3M Treasury Bill Rate
State Variables (8):
  • FFR: the effective federal funds rate.
  • TBILL_DELTA: the percent change in the 3M treasury bill rate.
  • CREDIT_SPREAD: the difference between the BAA corporate bond rate and the 10Y treasury bond rate.
  • LIQUIDITY_SPREAD: the difference between the 3M GC repo rate and the 3M treasury bill rate.
  • TED_SPREAD: the difference between the 3M USD LIBOR rate and the 3M treasury bill rate.
  • YIELD_SPREAD: the difference between the 10Y treasury bond rate and the 3M treasury bond rate.
  • DJ_CA_EXC: the excess returns of the DJ US Composite Average with respect to the S&P 500.
  • DJ_RESI_EXC: the excess returns of the DJ US Select Real Estate Securities Index with respect to the S&P 500.
  • VIX: the implied volatility index.

Screenshots

Screenshots

评论

暂无评论