PrimarySecurityDynamicsContainer.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.  * 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>PrimarySecurityDynamicsContainer</i> holds the Economy with the following Traded Assets - the Overnight
  78.  * Index Numeraire, the Collateral Scheme Numeraire, the Default-able Dealer Bond Numeraire, the Array of
  79.  * Default-able Client Numeraires, and an Asset that follows Brownian Motion. The References are:
  80.  *  
  81.  * <br><br>
  82.  *      <ul>
  83.  *          <li>
  84.  *              Albanese, C., and L. Andersen (2014): Accounting for OTC Derivatives: Funding Adjustments and
  85.  *                  the Re-Hypothecation Option https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2482955
  86.  *                  <b>eSSRN</b>
  87.  *          </li>
  88.  *          <li>
  89.  *              Burgard, C., and M. Kjaer (2013): Funding Costs, Funding Strategies <i>Risk</i> <b>23
  90.  *                  (12)</b> 82-87
  91.  *          </li>
  92.  *          <li>
  93.  *              Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  94.  *          </li>
  95.  *          <li>
  96.  *              Burgard, C., and M. Kjaer (2017): Derivatives Funding, Netting, and Accounting
  97.  *                  https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2534011 <b>eSSRN</b>
  98.  *          </li>
  99.  *          <li>
  100.  *              Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives
  101.  *                  Pricing <i>Risk</i> <b>21 (2)</b> 97-102
  102.  *          </li>
  103.  *          <li>
  104.  *      </ul>
  105.  *
  106.  *  <br><br>
  107.  *  <ul>
  108.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  109.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ExposureAnalyticsLibrary.md">Exposure Analytics</a></li>
  110.  *      <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>
  111.  *      <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>
  112.  *  </ul>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public class PrimarySecurityDynamicsContainer extends org.drip.exposure.evolver.DynamicsContainer
  117. {
  118.     private java.lang.String _csaID = null;
  119.     private java.lang.String _overnightID = null;
  120.     private java.lang.String _clientFundingID = null;
  121.     private java.lang.String _dealerSeniorFundingID = null;
  122.     private java.lang.String _dealerSubordinateFundingID = null;
  123.     private java.util.List<java.lang.String> _assetIDList = null;

  124.     /**
  125.      * PrimarySecurityDynamicsContainer Constructor
  126.      *
  127.      * @param assetList The List of Asset Primary Securities
  128.      * @param overnight The Overnight Index Primary Security
  129.      * @param csa The CSA Primary Security
  130.      * @param dealerSeniorFunding Dealer Senior Funding Primary Security
  131.      * @param dealerSubordinateFunding Dealer Subordinate Funding Primary Security
  132.      * @param clientFunding Client Funding Primary Security
  133.      *
  134.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  135.      */

  136.     public PrimarySecurityDynamicsContainer (
  137.         final java.util.List<org.drip.exposure.evolver.PrimarySecurity> assetList,
  138.         final org.drip.exposure.evolver.PrimarySecurity overnight,
  139.         final org.drip.exposure.evolver.PrimarySecurity csa,
  140.         final org.drip.exposure.evolver.PrimarySecurity dealerSeniorFunding,
  141.         final org.drip.exposure.evolver.PrimarySecurity dealerSubordinateFunding,
  142.         final org.drip.exposure.evolver.PrimarySecurity clientFunding)
  143.         throws java.lang.Exception
  144.     {
  145.         if (!addPrimarySecurity (overnight) ||
  146.             !addPrimarySecurity (csa) ||
  147.             !addPrimarySecurity (dealerSeniorFunding) ||
  148.             !addPrimarySecurity (clientFunding) ||
  149.             !addPrimarySecurity (dealerSubordinateFunding))
  150.         {
  151.             throw new java.lang.Exception ("PrimarySecurityDynamicsContainer Constructor => Invalid Inputs");
  152.         }

  153.         if (null != assetList && 0 != assetList.size())
  154.         {
  155.             _assetIDList = new java.util.ArrayList<java.lang.String>();

  156.             for (org.drip.exposure.evolver.PrimarySecurity asset : assetList)
  157.             {
  158.                 addPrimarySecurity (asset);

  159.                 if (null != asset)
  160.                 {
  161.                     _assetIDList.add (asset.id());
  162.                 }
  163.             }
  164.         }

  165.         org.drip.state.identifier.LatentStateLabel csaLabel = csa.label();

  166.         org.drip.state.identifier.LatentStateLabel overnightLabel = overnight.label();

  167.         org.drip.state.identifier.LatentStateLabel clientFundingLabel = clientFunding.label();

  168.         org.drip.state.identifier.LatentStateLabel dealerSeniorFundingLabel = dealerSeniorFunding.label();

  169.         org.drip.state.identifier.LatentStateLabel dealerSubordinateFundingLabel = null ==
  170.             dealerSubordinateFunding ? null : dealerSubordinateFunding.label();

  171.         if (!(csaLabel instanceof org.drip.state.identifier.CSALabel) ||
  172.             !(overnightLabel instanceof org.drip.state.identifier.OvernightLabel) ||
  173.             !(dealerSeniorFundingLabel instanceof org.drip.state.identifier.EntityFundingLabel) ||
  174.             !(clientFundingLabel instanceof org.drip.state.identifier.EntityFundingLabel) ||
  175.             (null != dealerSubordinateFundingLabel && !(dealerSubordinateFundingLabel instanceof
  176.                 org.drip.state.identifier.EntityFundingLabel)))
  177.         {
  178.             throw new java.lang.Exception ("PrimarySecurityDynamicsContainer Constructor => Invalid Inputs");
  179.         }

  180.         _csaID = csa.id();

  181.         _overnightID = overnight.id();

  182.         _clientFundingID = clientFunding.id();

  183.         _dealerSeniorFundingID = dealerSeniorFunding.id();

  184.         _dealerSubordinateFundingID = null == dealerSubordinateFundingLabel ? null :
  185.             dealerSubordinateFunding.id();
  186.     }

  187.     /**
  188.      * Retrieve the Asset Primary Security List
  189.      *
  190.      * @return The Asset Primary Security List
  191.      */

  192.     public java.util.List<org.drip.exposure.evolver.PrimarySecurity> assetList()
  193.     {
  194.         if (null == _assetIDList || 0 == _assetIDList.size())
  195.         {
  196.             return null;
  197.         }

  198.         java.util.List<org.drip.exposure.evolver.PrimarySecurity> assetList = new
  199.             java.util.ArrayList<org.drip.exposure.evolver.PrimarySecurity>();

  200.         for (java.lang.String assetID : _assetIDList)
  201.         {
  202.             assetList.add (primarySecurity (assetID));
  203.         }

  204.         return assetList;
  205.     }

  206.     /**
  207.      * Retrieve the Overnight Index Primary Security
  208.      *
  209.      * @return The Overnight Index Primary Security
  210.      */

  211.     public org.drip.exposure.evolver.PrimarySecurity overnight()
  212.     {
  213.         return primarySecurity (_overnightID);
  214.     }

  215.     /**
  216.      * Retrieve the CSA Primary Security
  217.      *
  218.      * @return The CSA Primary Security
  219.      */

  220.     public org.drip.exposure.evolver.PrimarySecurity csa()
  221.     {
  222.         return primarySecurity (_csaID);
  223.     }

  224.     /**
  225.      * Retrieve the Dealer Senior Funding Primary Security
  226.      *
  227.      * @return The Dealer Senior Funding Primary Security
  228.      */

  229.     public org.drip.exposure.evolver.PrimarySecurity dealerSeniorFunding()
  230.     {
  231.         return primarySecurity (_dealerSeniorFundingID);
  232.     }

  233.     /**
  234.      * Retrieve the Dealer Subordinate Funding Primary Security
  235.      *
  236.      * @return The Dealer Subordinate Funding Primary Security
  237.      */

  238.     public org.drip.exposure.evolver.PrimarySecurity dealerSubordinateFunding()
  239.     {
  240.         return primarySecurity (_dealerSubordinateFundingID);
  241.     }

  242.     /**
  243.      * Retrieve the Client Funding Primary Security
  244.      *
  245.      * @return The Client Funding Primary Security
  246.      */

  247.     public org.drip.exposure.evolver.PrimarySecurity clientFunding()
  248.     {
  249.         return primarySecurity (_clientFundingID);
  250.     }
  251. }