CreditDebtGroup.java

  1. package org.drip.xva.topology;

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

  75. /**
  76.  * <i>CreditDebtGroup</i> represents an Aggregation of Collateral Groups with a common Credit Debt
  77.  * Specification. The References are:
  78.  *
  79.  *  <br><br>
  80.  *  <ul>
  81.  *      <li>
  82.  *          Albanese, C., L. Andersen, and, S. Iabichino (2015): The FVA Puzzle: Accounting, Risk Management,
  83.  *              and Collateral Trading https://papers.ssrn.com/sol3/paper.cfm?abstract_id_2517301
  84.  *              <b>eSSRN</b>
  85.  *      </li>
  86.  *      <li>
  87.  *          Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party
  88.  *              Risk and Funding Costs <i>Journal of Credit Risk</i> <b>7 (3)</b> 1-19
  89.  *      </li>
  90.  *      <li>
  91.  *          Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  92.  *      </li>
  93.  *      <li>
  94.  *          Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk <i>Risk</i> <b>20 (2)</b>
  95.  *              86-90
  96.  *      </li>
  97.  *      <li>
  98.  *          Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing
  99.  *              <i>Risk</i> <b>21 (2)</b> 97-102
  100.  *      </li>
  101.  *  </ul>
  102.  *
  103.  *  <br><br>
  104.  *  <ul>
  105.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  106.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/XVAAnalyticsLibrary.md">XVA Analytics Library</a></li>
  107.  *      <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>
  108.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/xva/topology/README.md">Collateral, Credit/Debt, Funding Topologies</a></li>
  109.  *  </ul>
  110.  * <br><br>
  111.  *
  112.  * @author Lakshmi Krishnamurthy
  113.  */

  114. public class CreditDebtGroup extends org.drip.xva.proto.ObjectSpecification
  115. {
  116.     private org.drip.xva.proto.CreditDebtGroupSpecification _creditDebtGroupSpecification = null;
  117.     private java.util.Map<java.lang.String, org.drip.xva.topology.CollateralGroup> _collateralGroupMap =
  118.         null;

  119.     /**
  120.      * CreditDebtGroup Constructor
  121.      *
  122.      * @param id CreditDebtGroup ID
  123.      * @param name CreditDebtGroup Name
  124.      * @param creditDebtGroupSpecification The CreditDebtGroup Specification
  125.      *
  126.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  127.      */

  128.     public CreditDebtGroup (
  129.         final java.lang.String id,
  130.         final java.lang.String name,
  131.         final org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification)
  132.         throws java.lang.Exception
  133.     {
  134.         super (
  135.             id,
  136.             name
  137.         );

  138.         if (null == (_creditDebtGroupSpecification = creditDebtGroupSpecification))
  139.         {
  140.             throw new java.lang.Exception ("CreditDebtGroup Constructor => Invalid Inputs");
  141.         }

  142.         _collateralGroupMap = new
  143.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.xva.topology.CollateralGroup>();
  144.     }

  145.     /**
  146.      * Retrieve the Credit Debt Group Specification
  147.      *
  148.      * @return The Credit Debt Group Specification
  149.      */

  150.     public org.drip.xva.proto.CreditDebtGroupSpecification creditDebtGroupSpecification()
  151.     {
  152.         return _creditDebtGroupSpecification;
  153.     }

  154.     /**
  155.      * Retrieve the Collateral Group Map
  156.      *
  157.      * @return The Collateral Group Map
  158.      */

  159.     public java.util.Map<java.lang.String, org.drip.xva.topology.CollateralGroup> collateralGroupMap()
  160.     {
  161.         return _collateralGroupMap;
  162.     }

  163.     /**
  164.      * Add the specified Collateral Group
  165.      *
  166.      * @param collateralGroup The Collateral Group
  167.      *
  168.      * @return TRUE - The Collateral Group successfully added
  169.      */

  170.     public boolean addCollateralGroup (
  171.         final org.drip.xva.topology.CollateralGroup collateralGroup)
  172.     {
  173.         if (null == collateralGroup)
  174.         {
  175.             return false;
  176.         }

  177.         _collateralGroupMap.put (
  178.             collateralGroup.id(),
  179.             collateralGroup
  180.         );

  181.         return true;
  182.     }

  183.     /**
  184.      * Indicates if the Collateral Group identified by the specified ID
  185.      *
  186.      * @param collateralGroupID The Collateral Group ID
  187.      *
  188.      * @return TRUE - The Collateral Group Exists
  189.      */

  190.     public boolean containsCollateralGroup (
  191.         final java.lang.String collateralGroupID)
  192.     {
  193.         return null == collateralGroupID || collateralGroupID.isEmpty() ? false :
  194.             _collateralGroupMap.containsKey (collateralGroupID);
  195.     }

  196.     /**
  197.      * Retrieve the Collateral Group identified by the specified ID
  198.      *
  199.      * @param collateralGroupID The Collateral Group ID
  200.      *
  201.      * @return The Collateral Group
  202.      */

  203.     public org.drip.xva.topology.CollateralGroup collateralGroup (
  204.         final java.lang.String collateralGroupID)
  205.     {
  206.         return containsCollateralGroup (collateralGroupID) ? _collateralGroupMap.get (collateralGroupID) :
  207.             null;
  208.     }

  209.     /**
  210.      * Retrieve the Dealer Hazard Label
  211.      *
  212.      * @return The Dealer Hazard Label
  213.      */

  214.     public org.drip.state.identifier.EntityHazardLabel dealerHazardLabel()
  215.     {
  216.         return _creditDebtGroupSpecification.dealerHazardLabel();
  217.     }

  218.     /**
  219.      * Retrieve the Client Hazard Label
  220.      *
  221.      * @return The Client Hazard Label
  222.      */

  223.     public org.drip.state.identifier.EntityHazardLabel clientPartyHazardLabel()
  224.     {
  225.         return _creditDebtGroupSpecification.clientHazardLabel();
  226.     }

  227.     /**
  228.      * Retrieve the Dealer Senior Recovery Label
  229.      *
  230.      * @return The Dealer Senior Recovery Label
  231.      */

  232.     public org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel()
  233.     {
  234.         return _creditDebtGroupSpecification.dealerSeniorRecoveryLabel();
  235.     }

  236.     /**
  237.      * Retrieve the Dealer Subordinate Recovery Label
  238.      *
  239.      * @return The Dealer Subordinate Recovery Label
  240.      */

  241.     public org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel()
  242.     {
  243.         return _creditDebtGroupSpecification.dealerSubordinateRecoveryLabel();
  244.     }

  245.     /**
  246.      * Retrieve the Client Senior Recovery Label
  247.      *
  248.      * @return The Client Senior Recovery Label
  249.      */

  250.     public org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel()
  251.     {
  252.         return _creditDebtGroupSpecification.clientRecoveryLabel();
  253.     }

  254.     /**
  255.      * Retrieve the Overnight Label Map
  256.      *
  257.      * @return The Overnight Label Map
  258.      */

  259.     public java.util.Map<java.lang.String, org.drip.state.identifier.OvernightLabel> overnightLabelMap()
  260.     {
  261.         java.util.Map<java.lang.String, org.drip.state.identifier.OvernightLabel> overnightLabelMap = new
  262.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.state.identifier.OvernightLabel>();

  263.         for (java.util.Map.Entry<java.lang.String, org.drip.xva.topology.CollateralGroup>
  264.             collateralGroupMapEntry : _collateralGroupMap.entrySet())
  265.         {
  266.             org.drip.state.identifier.OvernightLabel overnightLabel =
  267.                 collateralGroupMapEntry.getValue().overnightLabel();

  268.             java.lang.String overnightLabelFQN = overnightLabel.fullyQualifiedName();

  269.             if (!overnightLabelMap.containsKey (overnightLabelFQN))
  270.             {
  271.                 overnightLabelMap.put (
  272.                     overnightLabelFQN,
  273.                     overnightLabel
  274.                 );
  275.             }
  276.         }

  277.         return overnightLabelMap;
  278.     }

  279.     /**
  280.      * Retrieve the CSA Label Map
  281.      *
  282.      * @return The CSA Label Map
  283.      */

  284.     public java.util.Map<java.lang.String, org.drip.state.identifier.CSALabel> csaLabelMap()
  285.     {
  286.         java.util.Map<java.lang.String, org.drip.state.identifier.CSALabel> csaLabelMap = new
  287.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.state.identifier.CSALabel>();

  288.         for (java.util.Map.Entry<java.lang.String, org.drip.xva.topology.CollateralGroup>
  289.             collateralGroupMapEntry : _collateralGroupMap.entrySet())
  290.         {
  291.             org.drip.state.identifier.CSALabel csaLabel = collateralGroupMapEntry.getValue().csaLabel();

  292.             java.lang.String csaLabelFQN = csaLabel.fullyQualifiedName();

  293.             if (!csaLabelMap.containsKey (csaLabelFQN))
  294.             {
  295.                 csaLabelMap.put (
  296.                     csaLabelFQN,
  297.                     csaLabel
  298.                 );
  299.             }
  300.         }

  301.         return csaLabelMap;
  302.     }
  303. }