BalanceSheetLiquidity.java

  1. package org.drip.capital.bcbs;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  *
  9.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  10.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  11.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  12.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  13.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  14.  *      and computational support.
  15.  *  
  16.  *      https://lakshmidrip.github.io/DROP/
  17.  *  
  18.  *  DROP is composed of three modules:
  19.  *  
  20.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  21.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  22.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  23.  *
  24.  *  DROP Product Core implements libraries for the following:
  25.  *  - Fixed Income Analytics
  26.  *  - Loan Analytics
  27.  *  - Transaction Cost Analytics
  28.  *
  29.  *  DROP Portfolio Core implements libraries for the following:
  30.  *  - Asset Allocation Analytics
  31.  *  - Asset Liability Management Analytics
  32.  *  - Capital Estimation Analytics
  33.  *  - Exposure Analytics
  34.  *  - Margin Analytics
  35.  *  - XVA Analytics
  36.  *
  37.  *  DROP Computational Core implements libraries for the following:
  38.  *  - Algorithm Support
  39.  *  - Computation Support
  40.  *  - Function Analysis
  41.  *  - Model Validation
  42.  *  - Numerical Analysis
  43.  *  - Numerical Optimizer
  44.  *  - Spline Builder
  45.  *  - Statistical Learning
  46.  *
  47.  *  Documentation for DROP is Spread Over:
  48.  *
  49.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  50.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  51.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  52.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  53.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  54.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  55.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  56.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  57.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  58.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  59.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  60.  *
  61.  *  Licensed under the Apache License, Version 2.0 (the "License");
  62.  *      you may not use this file except in compliance with the License.
  63.  *  
  64.  *  You may obtain a copy of the License at
  65.  *      http://www.apache.org/licenses/LICENSE-2.0
  66.  *  
  67.  *  Unless required by applicable law or agreed to in writing, software
  68.  *      distributed under the License is distributed on an "AS IS" BASIS,
  69.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  70.  *  
  71.  *  See the License for the specific language governing permissions and
  72.  *      limitations under the License.
  73.  */

  74. /**
  75.  * <i>BalanceSheetLiquidity</i> holds the Liquidity Related Fields needed for computing the Compliance
  76.  * Ratios. The References are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Basel Committee on Banking Supervision (2017): Basel III Leverage Ratio Framework and Disclosure
  82.  *              Requirements https://www.bis.org/publ/bcbs270.pdf
  83.  *      </li>
  84.  *      <li>
  85.  *          Central Banking (2013): Fed and FDIC agree 6% Leverage Ratio for US SIFIs
  86.  *              https://www.centralbanking.com/central-banking/news/2280726/fed-and-fdic-agree-6-leverage-ratio-for-us-sifis
  87.  *      </li>
  88.  *      <li>
  89.  *          European Banking Agency (2013): Implementing Basel III in Europe: CRD IV Package
  90.  *              https://eba.europa.eu/regulation-and-policy/implementing-basel-iii-europe
  91.  *      </li>
  92.  *      <li>
  93.  *          Federal Reserve (2013): Liquidity Coverage Ratio – Liquidity Risk Measurements, Standards, and
  94.  *              Monitoring
  95.  *              https://web.archive.org/web/20131102074614/http:/www.federalreserve.gov/FR_notice_lcr_20131024.pdf
  96.  *      </li>
  97.  *      <li>
  98.  *          Wikipedia (2018): Basel III https://en.wikipedia.org/wiki/Basel_III
  99.  *      </li>
  100.  *  </ul>
  101.  *
  102.  *  <br><br>
  103.  *  <ul>
  104.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  105.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/CapitalAnalyticsLibrary.md">Capital Analytics</a></li>
  106.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/capital/README.md">Basel Market Risk and Operational Capital</a></li>
  107.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/capital/bcbs/README.md">BCBS and Jurisdictional Capital Ratios</a></li>
  108.  *  </ul>
  109.  *
  110.  * @author Lakshmi Krishnamurthy
  111.  */

  112. public class BalanceSheetLiquidity
  113. {
  114.     private boolean _usePeakCumulative = false;
  115.     private java.lang.String _netCashOutflowPeriod = "";
  116.     private double _netCashOutflowAmount = java.lang.Double.NaN;
  117.     private org.drip.capital.bcbs.HighQualityLiquidAsset _highQualityLiquidAsset = null;

  118.     /**
  119.      * Construct the Basel III Standard Version of Balance Sheet Liquidity
  120.      *
  121.      * @param highQualityLiquidAsset High Quality Liquid Asset Instance
  122.      * @param netCashOutflowAmount Net Cash Outflow Amount
  123.      * @param usePeakCumulative TRUE - The Net Outflow is to be determined off of the Peak Cumulative Period
  124.      *
  125.      * @return Basel III Standard Version of Balance Sheet Liquidity
  126.      */

  127.     public static final BalanceSheetLiquidity Basel_III (
  128.         final org.drip.capital.bcbs.HighQualityLiquidAsset highQualityLiquidAsset,
  129.         final double netCashOutflowAmount,
  130.         final boolean usePeakCumulative)
  131.     {
  132.         try
  133.         {
  134.             return new BalanceSheetLiquidity (
  135.                 highQualityLiquidAsset,
  136.                 netCashOutflowAmount,
  137.                 "30D",
  138.                 usePeakCumulative
  139.             );
  140.         }
  141.         catch (java.lang.Exception e)
  142.         {
  143.             e.printStackTrace();
  144.         }

  145.         return null;
  146.     }

  147.     /**
  148.      * Construct the Basel III Standard Version of Balance Sheet Liquidity for Large BHC's
  149.      *
  150.      * @param highQualityLiquidAsset High Quality Liquid Asset Instance
  151.      * @param netCashOutflowAmount Net Cash Outflow Amount
  152.      *
  153.      * @return Basel III Standard Version of Balance Sheet Liquidity for Large BHC's
  154.      */

  155.     public static final BalanceSheetLiquidity LargeBHC (
  156.         final org.drip.capital.bcbs.HighQualityLiquidAsset highQualityLiquidAsset,
  157.         final double netCashOutflowAmount)
  158.     {
  159.         return Basel_III (
  160.             highQualityLiquidAsset,
  161.             netCashOutflowAmount,
  162.             true
  163.         );
  164.     }

  165.     /**
  166.      * Construct the Basel III Standard Version of Balance Sheet Liquidity for Regional BHC's
  167.      *
  168.      * @param highQualityLiquidAsset High Quality Liquid Asset Instance
  169.      * @param netCashOutflowAmount Net Cash Outflow Amount
  170.      *
  171.      * @return Basel III Standard Version of Balance Sheet Liquidity for Regional BHC's
  172.      */

  173.     public static final BalanceSheetLiquidity RegionalBHC (
  174.         final org.drip.capital.bcbs.HighQualityLiquidAsset highQualityLiquidAsset,
  175.         final double netCashOutflowAmount)
  176.     {
  177.         try
  178.         {
  179.             return new BalanceSheetLiquidity (
  180.                 highQualityLiquidAsset,
  181.                 netCashOutflowAmount,
  182.                 "21D",
  183.                 false
  184.             );
  185.         }
  186.         catch (java.lang.Exception e)
  187.         {
  188.             e.printStackTrace();
  189.         }

  190.         return null;
  191.     }

  192.     /**
  193.      * BalanceSheetLiquidity Constructor
  194.      *
  195.      * @param highQualityLiquidAsset High Quality Liquid Asset Instance
  196.      * @param netCashOutflowAmount Net Cash Outflow Amount
  197.      * @param netCashOutflowPeriod Net Cash Outflow Period
  198.      * @param usePeakCumulative TRUE - The Net Outflow is to be determined off of the Peak Cumulative Period
  199.      *
  200.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  201.      */

  202.     public BalanceSheetLiquidity (
  203.         final org.drip.capital.bcbs.HighQualityLiquidAsset highQualityLiquidAsset,
  204.         final double netCashOutflowAmount,
  205.         final java.lang.String netCashOutflowPeriod,
  206.         final boolean usePeakCumulative)
  207.         throws java.lang.Exception
  208.     {
  209.         if (null == (_highQualityLiquidAsset = highQualityLiquidAsset) ||
  210.             !org.drip.numerical.common.NumberUtil.IsValid (_netCashOutflowAmount = netCashOutflowAmount) ||
  211.                 0. > _netCashOutflowAmount ||
  212.             null == (_netCashOutflowPeriod = netCashOutflowPeriod) || _netCashOutflowPeriod.isEmpty())
  213.         {
  214.             throw new java.lang.Exception ("BalanceSheetLiquidity Constructor => Invalid Inputs");
  215.         }

  216.         _usePeakCumulative = usePeakCumulative;
  217.     }

  218.     /**
  219.      * Retrieve the High Quality Liquid Asset Instance
  220.      *
  221.      * @return The High Quality Liquid Asset Instance
  222.      */

  223.     public org.drip.capital.bcbs.HighQualityLiquidAsset highQualityLiquidAsset()
  224.     {
  225.         return _highQualityLiquidAsset;
  226.     }

  227.     /**
  228.      * Retrieve the Net Cash Outflow Amount
  229.      *
  230.      * @return The Net Cash Outflow Amount
  231.      */

  232.     public double netCashOutflowAmount()
  233.     {
  234.         return _netCashOutflowAmount;
  235.     }

  236.     /**
  237.      * Retrieve the Net Cash Outflow Period
  238.      *
  239.      * @return The Net Cash Outflow Period
  240.      */

  241.     public java.lang.String netCashOutflowPeriod()
  242.     {
  243.         return _netCashOutflowPeriod;
  244.     }

  245.     /**
  246.      * Indicate if the Net Outflow is to be determined off of the Peak Cumulative Period
  247.      *
  248.      * @return TRUE - The Net Outflow is to be determined off of the Peak Cumulative Period
  249.      */

  250.     public boolean usePeakCumulative()
  251.     {
  252.         return _usePeakCumulative;
  253.     }

  254.     /**
  255.      * Compute the Liquidity Coverage Ratio
  256.      *  
  257.      * @param hqlaSettings THe HQLA Settings
  258.      *
  259.      * @return The Liquidity Coverage Ratio
  260.      *
  261.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  262.      */

  263.     public double liquidityCoverageRatio (
  264.         final org.drip.capital.bcbs.HighQualityLiquidAssetSettings hqlaSettings)
  265.         throws java.lang.Exception
  266.     {
  267.         return _highQualityLiquidAsset.totalRiskWeightAndHaircut (hqlaSettings) / _netCashOutflowAmount;
  268.     }
  269. }