EntityDynamicsContainer.java

  1. package org.drip.exposure.evolver;

  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>EntityDynamicsContainer</i> contains the Dealer and the Client Hazard and Recovery Latent State
  77.  * Evolvers. The References are:
  78.  *  
  79.  * <br><br>
  80.  *      <ul>
  81.  *          <li>
  82.  *              Burgard, C., and M. Kjaer (2013): Funding Costs, Funding Strategies <i>Risk</i> <b>23
  83.  *                  (12)</b> 82-87
  84.  *          </li>
  85.  *          <li>
  86.  *              Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  87.  *          </li>
  88.  *          <li>
  89.  *              Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-
  90.  *                  party Risk and Funding Costs <i>Journal of Credit Risk</i> <b>7 (3)</b> 1-19
  91.  *          </li>
  92.  *          <li>
  93.  *              Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk <i>Risk</i> <b>20 (2)</b>
  94.  *                  86-90
  95.  *          </li>
  96.  *          <li>
  97.  *              Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives
  98.  *                  Pricing <i>Risk</i> <b>21 (2)</b> 97-102
  99.  *          </li>
  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/ExposureAnalyticsLibrary.md">Exposure Analytics</a></li>
  107.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/exposure/README.md">Exposure Group Level Collateralized/Uncollateralized Exposure</a></li>
  108.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/exposure/evolver/README.md">Securities and Exposure States Evolvers</a></li>
  109.  *  </ul>
  110.  *  
  111.  * @author Lakshmi Krishnamurthy
  112.  */

  113. public class EntityDynamicsContainer extends org.drip.exposure.evolver.DynamicsContainer
  114. {
  115.     private org.drip.state.identifier.EntityHazardLabel _clientHazardLabel = null;
  116.     private org.drip.state.identifier.EntityHazardLabel _dealerHazardLabel = null;
  117.     private org.drip.state.identifier.EntityRecoveryLabel _clientRecoveryLabel = null;
  118.     private org.drip.state.identifier.EntityRecoveryLabel _dealerSeniorRecoveryLabel = null;
  119.     private org.drip.state.identifier.EntityRecoveryLabel _dealerSubordinateRecoveryLabel = null;

  120.     /**
  121.      * EntityDynamicsContainer Constructor
  122.      *
  123.      * @param dealerHazardLatentState The Dealer Hazard Rate Latent State
  124.      * @param dealerSeniorRecoveryLatentState The Dealer Senior Recovery Rate Latent State
  125.      * @param dealerSubordinateRecoveryLatentState The Dealer Subordinate Rate Latent State
  126.      * @param clientHazardLatentState The Client Hazard Rate Latent State
  127.      * @param clientRecoveryLatentState The Client Recovery Rate Latent State
  128.      *
  129.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  130.      */

  131.     public EntityDynamicsContainer (
  132.         final org.drip.exposure.evolver.TerminalLatentState dealerHazardLatentState,
  133.         final org.drip.exposure.evolver.TerminalLatentState dealerSeniorRecoveryLatentState,
  134.         final org.drip.exposure.evolver.TerminalLatentState dealerSubordinateRecoveryLatentState,
  135.         final org.drip.exposure.evolver.TerminalLatentState clientHazardLatentState,
  136.         final org.drip.exposure.evolver.TerminalLatentState clientRecoveryLatentState)
  137.         throws java.lang.Exception
  138.     {
  139.         if (null == dealerHazardLatentState ||
  140.             null == dealerSeniorRecoveryLatentState ||
  141.             null == clientHazardLatentState ||
  142.             null == clientRecoveryLatentState)
  143.         {
  144.             throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs");
  145.         }

  146.         org.drip.state.identifier.LatentStateLabel dealerHazardLabel = dealerHazardLatentState.label();

  147.         org.drip.state.identifier.LatentStateLabel dealerSeniorRecoveryLabel =
  148.             dealerSeniorRecoveryLatentState.label();

  149.         org.drip.state.identifier.LatentStateLabel clientHazardLabel = clientHazardLatentState.label();

  150.         org.drip.state.identifier.LatentStateLabel clientRecoveryLabel = clientRecoveryLatentState.label();

  151.         if (!(dealerHazardLabel instanceof org.drip.state.identifier.EntityHazardLabel) ||
  152.             !(dealerSeniorRecoveryLabel instanceof org.drip.state.identifier.EntityRecoveryLabel) ||
  153.             !(clientHazardLabel instanceof org.drip.state.identifier.EntityHazardLabel) ||
  154.             !(clientRecoveryLabel instanceof org.drip.state.identifier.EntityRecoveryLabel) ||
  155.             !addTerminalLatentState (dealerHazardLatentState) ||
  156.             !addTerminalLatentState (dealerSeniorRecoveryLatentState) ||
  157.             !addTerminalLatentState (clientHazardLatentState) ||
  158.             !addTerminalLatentState (clientRecoveryLatentState))
  159.         {
  160.             throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs");
  161.         }

  162.         _dealerHazardLabel = (org.drip.state.identifier.EntityHazardLabel) dealerHazardLabel;
  163.         _clientHazardLabel = (org.drip.state.identifier.EntityHazardLabel) clientHazardLabel;
  164.         _dealerSeniorRecoveryLabel = (org.drip.state.identifier.EntityRecoveryLabel)
  165.             dealerSeniorRecoveryLabel;
  166.         _clientRecoveryLabel = (org.drip.state.identifier.EntityRecoveryLabel) clientRecoveryLabel;

  167.         if (null != dealerSubordinateRecoveryLatentState)
  168.         {
  169.             org.drip.state.identifier.LatentStateLabel dealerSubordinateRecoveryLabel =
  170.                 dealerSubordinateRecoveryLatentState.label();

  171.             if (!(dealerSubordinateRecoveryLabel instanceof org.drip.state.identifier.EntityRecoveryLabel) ||
  172.                 !addTerminalLatentState (dealerSubordinateRecoveryLatentState))
  173.             {
  174.                 throw new java.lang.Exception ("EntityDynamicsContainer Constructor => Invalid Inputs");
  175.             }

  176.             _dealerSubordinateRecoveryLabel = (org.drip.state.identifier.EntityRecoveryLabel)
  177.                 dealerSubordinateRecoveryLabel;
  178.         }
  179.     }

  180.     /**
  181.      * Retrieve the Dealer Hazard Rate Evolver
  182.      *
  183.      * @return The Dealer Hazard Rate Evolver
  184.      */

  185.     public org.drip.measure.process.DiffusionEvolver dealerHazardRateEvolver()
  186.     {
  187.         return terminalLatentStateContainer().entityHazard (_dealerHazardLabel).evolver();
  188.     }

  189.     /**
  190.      * Retrieve the Dealer Senior Recovery Rate Evolver
  191.      *
  192.      * @return The Dealer Senior Recovery Rate Evolver
  193.      */

  194.     public org.drip.measure.process.DiffusionEvolver dealerSeniorRecoveryRateEvolver()
  195.     {
  196.         return terminalLatentStateContainer().entityRecovery (_dealerSeniorRecoveryLabel).evolver();
  197.     }

  198.     /**
  199.      * Retrieve the Dealer Subordinate Recovery Rate Evolver
  200.      *
  201.      * @return The Dealer Subordinate Recovery Rate Evolver
  202.      */

  203.     public org.drip.measure.process.DiffusionEvolver dealerSubordinateRecoveryRateEvolver()
  204.     {
  205.         org.drip.exposure.evolver.TerminalLatentState terminalLatentStateDealerSubordinateRecovery =
  206.             terminalLatentStateContainer().entityRecovery (_dealerSubordinateRecoveryLabel);

  207.         return null == terminalLatentStateDealerSubordinateRecovery ? null :
  208.             terminalLatentStateDealerSubordinateRecovery.evolver();
  209.     }

  210.     /**
  211.      * Retrieve the Client Hazard Rate Evolver
  212.      *
  213.      * @return The Client Hazard Rate Evolver
  214.      */

  215.     public org.drip.measure.process.DiffusionEvolver clientHazardRateEvolver()
  216.     {
  217.         return terminalLatentStateContainer().entityHazard (_clientHazardLabel).evolver();
  218.     }

  219.     /**
  220.      * Retrieve the Client Recovery Rate Evolver
  221.      *
  222.      * @return The Client Recovery Rate Evolver
  223.      */

  224.     public org.drip.measure.process.DiffusionEvolver clientRecoveryRateEvolver()
  225.     {
  226.         return terminalLatentStateContainer().entityRecovery (_clientRecoveryLabel).evolver();
  227.     }

  228.     /**
  229.      * Retrieve the Client Hazard Label
  230.      *
  231.      * @return The Client Hazard Label
  232.      */

  233.     public org.drip.state.identifier.EntityHazardLabel clientHazardLabel()
  234.     {
  235.         return _clientHazardLabel;
  236.     }

  237.     /**
  238.      * Retrieve the Client Recovery Label
  239.      *
  240.      * @return The Client Recovery Label
  241.      */

  242.     public org.drip.state.identifier.EntityRecoveryLabel clientRecoveryLabel()
  243.     {
  244.         return _clientRecoveryLabel;
  245.     }

  246.     /**
  247.      * Retrieve the Dealer Hazard Label
  248.      *
  249.      * @return The Dealer Hazard Label
  250.      */

  251.     public org.drip.state.identifier.EntityHazardLabel dealerHazardLabel()
  252.     {
  253.         return _dealerHazardLabel;
  254.     }

  255.     /**
  256.      * Retrieve the Dealer Senior Recovery Label
  257.      *
  258.      * @return The Dealer Senior Recovery Label
  259.      */

  260.     public org.drip.state.identifier.EntityRecoveryLabel dealerSeniorRecoveryLabel()
  261.     {
  262.         return _dealerSeniorRecoveryLabel;
  263.     }

  264.     /**
  265.      * Retrieve the Dealer Subordinate Recovery Label
  266.      *
  267.      * @return The Dealer Subordinate Recovery Label
  268.      */

  269.     public org.drip.state.identifier.EntityRecoveryLabel dealerSubordinateRecoveryLabel()
  270.     {
  271.         return _dealerSubordinateRecoveryLabel;
  272.     }
  273. }