BalanceSheetVertex.java

  1. package org.drip.xva.basel;

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

  76. /**
  77.  * <i>BalanceSheetVertex</i> implements the Balance Sheet Vertex Component of the Streamlined Accounting
  78.  * Framework for OTC Derivatives, as described in Albanese and Andersen (2014). The References are:
  79.  *  
  80.  *  <br><br>
  81.  *  <ul>
  82.  *      <li>
  83.  *          Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and the
  84.  *              Re-Hypothecation Option https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955
  85.  *              <b>eSSRN</b>
  86.  *      </li>
  87.  *      <li>
  88.  *          BCBS (2012): <i>Consultative Document: Application of Own Credit Risk Adjustments to
  89.  *              Derivatives</i> <b>Basel Committee on Banking Supervision</b>
  90.  *      </li>
  91.  *      <li>
  92.  *          Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party
  93.  *              Risk and Funding Costs <i>Journal of Credit Risk</i> <b>7 (3)</b> 1-19
  94.  *      </li>
  95.  *      <li>
  96.  *          Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  97.  *      </li>
  98.  *      <li>
  99.  *          Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing
  100.  *              <i>Risk</i> <b>21 (2)</b> 97-102
  101.  *      </li>
  102.  *  </ul>
  103.  *
  104.  *  <br><br>
  105.  *  <ul>
  106.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  107.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/XVAAnalyticsLibrary.md">XVA Analytics Library</a></li>
  108.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/xva/README.md">Valuation Adjustments that account for Collateral, CC Credit/Debt and Funding Overhead</a></li>
  109.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/xva/basel/README.md">XVA Based Basel Accounting Measures</a></li>
  110.  *  </ul>
  111.  * <br><br>
  112.  *
  113.  * @author Lakshmi Krishnamurthy
  114.  */

  115. public class BalanceSheetVertex
  116. {
  117.     private double _cash = java.lang.Double.NaN;
  118.     private double _asset = java.lang.Double.NaN;
  119.     private double _liability = java.lang.Double.NaN;
  120.     private double _contraAsset = java.lang.Double.NaN;
  121.     private double _contraLiability = java.lang.Double.NaN;
  122.     private double _retainedEarnings = java.lang.Double.NaN;

  123.     /**
  124.      * Unrealized Instance of BalanceSheetVertex
  125.      *
  126.      * @param asset The Asset Account
  127.      * @param liability The Liability Account
  128.      * @param contraAsset The Contra Asset Account
  129.      * @param contraLiability The Contra Liability Account
  130.      * @param retainedEarnings The Retained Earnings Account
  131.      *
  132.      * @return The Unrealized BalanceSheetVertex Instance
  133.      */

  134.     public static final BalanceSheetVertex Unrealized (
  135.         final double asset,
  136.         final double liability,
  137.         final double contraAsset,
  138.         final double contraLiability,
  139.         final double retainedEarnings)
  140.     {
  141.         try
  142.         {
  143.             return new BalanceSheetVertex (
  144.                 asset,
  145.                 liability,
  146.                 contraAsset,
  147.                 contraLiability,
  148.                 retainedEarnings,
  149.                 0.
  150.             );
  151.         }
  152.         catch (java.lang.Exception e)
  153.         {
  154.             e.printStackTrace();
  155.         }

  156.         return null;
  157.     }

  158.     /**
  159.      * BalanceSheetVertex Constructor
  160.      *
  161.      * @param asset The Asset Account
  162.      * @param liability The Liability Account
  163.      * @param contraAsset The Contra Asset Account
  164.      * @param contraLiability The Contra Liability Account
  165.      * @param retainedEarnings The Retained Earnings Account
  166.      * @param cash The Cash Account
  167.      *
  168.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  169.      */

  170.     public BalanceSheetVertex (
  171.         final double asset,
  172.         final double liability,
  173.         final double contraAsset,
  174.         final double contraLiability,
  175.         final double retainedEarnings,
  176.         final double cash)
  177.         throws java.lang.Exception
  178.     {
  179.         if (!org.drip.numerical.common.NumberUtil.IsValid (_cash = cash) ||
  180.             !org.drip.numerical.common.NumberUtil.IsValid (_asset = asset) ||
  181.             !org.drip.numerical.common.NumberUtil.IsValid (_liability = liability) ||
  182.             !org.drip.numerical.common.NumberUtil.IsValid (_contraAsset = contraAsset) ||
  183.             !org.drip.numerical.common.NumberUtil.IsValid (_contraLiability = contraLiability) ||
  184.             !org.drip.numerical.common.NumberUtil.IsValid (_retainedEarnings = retainedEarnings))
  185.         {
  186.             throw new java.lang.Exception ("BalanceSheetVertex Constructor => Invalid Inputs");
  187.         }
  188.     }

  189.     /**
  190.      * Retrieve the Asset Account
  191.      *
  192.      * @return The Asset Account
  193.      */

  194.     public double asset()
  195.     {
  196.         return _asset;
  197.     }

  198.     /**
  199.      * Retrieve the Liability Account
  200.      *
  201.      * @return The Liability Account
  202.      */

  203.     public double liability()
  204.     {
  205.         return _liability;
  206.     }

  207.     /**
  208.      * Retrieve the Contra Asset Account
  209.      *
  210.      * @return The Contra Asset Account
  211.      */

  212.     public double contraAsset()
  213.     {
  214.         return _contraAsset;
  215.     }

  216.     /**
  217.      * Retrieve the Contra Liability Account
  218.      *
  219.      * @return The Contra Liability Account
  220.      */

  221.     public double contraLiability()
  222.     {
  223.         return _contraLiability;
  224.     }

  225.     /**
  226.      * Retrieve the Retained Earnings Account
  227.      *
  228.      * @return The Retained Earnings Account
  229.      */

  230.     public double retainedEarnings()
  231.     {
  232.         return _retainedEarnings;
  233.     }

  234.     /**
  235.      * Retrieve the Cash Account
  236.      *
  237.      * @return The Cash Account
  238.      */

  239.     public double cash()
  240.     {
  241.         return _cash;
  242.     }

  243.     /**
  244.      * Estimate the Portfolio Value (PFV)
  245.      *
  246.      * @return The Portfolio Value (PFV)
  247.      */

  248.     public double pfv()
  249.     {
  250.         return _asset - _liability;
  251.     }

  252.     /**
  253.      * Estimate the Equity Account
  254.      *
  255.      * @return The Equity Account
  256.      */

  257.     public double equity()
  258.     {
  259.         return _cash + _asset - _liability - _contraAsset + _contraLiability + _retainedEarnings;
  260.     }

  261.     /**
  262.      * Estimate the Core Equity Tier I (CET1) Capital
  263.      *
  264.      * @return The Core Equity Tier I (CET1) Capital
  265.      */

  266.     public double cet1()
  267.     {
  268.         return _cash + _asset - _liability - _contraAsset + _retainedEarnings;
  269.     }
  270. }