ExposureAdjustmentAggregator.java

  1. package org.drip.xva.gross;

  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>ExposureAdjustmentAggregator</i> aggregates across Multiple Exposure/Adjustment Paths belonging to the
  78.  * Counter Party. The References are:
  79.  *
  80.  *  <br><br>
  81.  *  <ul>
  82.  *      <li>
  83.  *          Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party
  84.  *              Risk and Funding Costs <i>Journal of Credit Risk</i> <b>7 (3)</b> 1-19
  85.  *      </li>
  86.  *      <li>
  87.  *          Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  88.  *      </li>
  89.  *      <li>
  90.  *          Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk <i>Risk</i> <b>20 (2)</b>
  91.  *              86-90
  92.  *      </li>
  93.  *      <li>
  94.  *          Li, B., and Y. Tang (2007): <i>Quantitative Analysis, Derivatives Modeling, and Trading
  95.  *              Strategies in the Presence of Counter-party Credit Risk for the Fixed Income Market</i>
  96.  *              <b>World Scientific Publishing</b> Singapore
  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/gross/README.md">XVA Gross Adiabat Exposure Aggregation</a></li>
  110.  *  </ul>
  111.  * <br><br>
  112.  *
  113.  * @author Lakshmi Krishnamurthy
  114.  */

  115. public class ExposureAdjustmentAggregator
  116. {
  117.     private org.drip.xva.gross.PathExposureAdjustment[] _pathExposureAdjustmentArray = null;

  118.     /**
  119.      * ExposureAdjustmentAggregator Constructor
  120.      *
  121.      * @param pathExposureAdjustmentArray Array of the Counter Party Group Paths
  122.      *
  123.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  124.      */

  125.     public ExposureAdjustmentAggregator (
  126.         final org.drip.xva.gross.PathExposureAdjustment[] pathExposureAdjustmentArray)
  127.         throws java.lang.Exception
  128.     {
  129.         if (null == (_pathExposureAdjustmentArray = pathExposureAdjustmentArray) ||
  130.             0 == _pathExposureAdjustmentArray.length)
  131.         {
  132.             throw new java.lang.Exception ("ExposureAdjustmentAggregator Constructor => Invalid Inputs");
  133.         }
  134.     }

  135.     /**
  136.      * Retrieve the Array of Group Path Exposure Adjustments
  137.      *
  138.      * @return Array of Group Path Exposure Adjustments
  139.      */

  140.     public org.drip.xva.gross.PathExposureAdjustment[] pathExposureAdjustmentArray()
  141.     {
  142.         return _pathExposureAdjustmentArray;
  143.     }

  144.     /**
  145.      * Retrieve the Array of the Vertex Anchor Dates
  146.      *
  147.      * @return The Array of the Vertex Anchor Dates
  148.      */

  149.     public org.drip.analytics.date.JulianDate[] vertexDates()
  150.     {
  151.         return _pathExposureAdjustmentArray[0].vertexDates();
  152.     }

  153.     /**
  154.      * Retrieve the Array of Collateralized Exposures
  155.      *
  156.      * @return The Array of Collateralized Exposures
  157.      */

  158.     public double[] collateralizedExposure()
  159.     {
  160.         int vertexCount = vertexDates().length;

  161.         int pathCount = _pathExposureAdjustmentArray.length;
  162.         double[] collateralizedExposure = new double[vertexCount];

  163.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  164.         {
  165.             collateralizedExposure[vertexIndex] = 0.;
  166.         }

  167.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  168.         {
  169.             double[] pathCollateralizedExposure =
  170.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedExposure();

  171.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  172.             {
  173.                 collateralizedExposure[vertexIndex] += pathCollateralizedExposure[vertexIndex];
  174.             }
  175.         }

  176.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  177.         {
  178.             collateralizedExposure[vertexIndex] /= pathCount;
  179.         }

  180.         return collateralizedExposure;
  181.     }

  182.     /**
  183.      * Retrieve the Array of Collateralized Exposure PV's
  184.      *
  185.      * @return The Array of Collateralized Exposure PV's
  186.      */

  187.     public double[] collateralizedExposurePV()
  188.     {
  189.         int vertexCount = vertexDates().length;

  190.         int pathCount = _pathExposureAdjustmentArray.length;
  191.         double[] collateralizedExposurePV = new double[vertexCount];

  192.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  193.         {
  194.             collateralizedExposurePV[vertexIndex] = 0.;
  195.         }

  196.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  197.         {
  198.             double[] pathCollateralizedExposurePV =
  199.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedExposurePV();

  200.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  201.             {
  202.                 collateralizedExposurePV[vertexIndex] += pathCollateralizedExposurePV[vertexIndex];
  203.             }
  204.         }

  205.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  206.         {
  207.             collateralizedExposurePV[vertexIndex] /= pathCount;
  208.         }

  209.         return collateralizedExposurePV;
  210.     }

  211.     /**
  212.      * Retrieve the Array of Uncollateralized Exposures
  213.      *
  214.      * @return The Array of Uncollateralized Exposures
  215.      */

  216.     public double[] uncollateralizedExposure()
  217.     {
  218.         int vertexCount = vertexDates().length;

  219.         int pathCount = _pathExposureAdjustmentArray.length;
  220.         double[] uncollateralizedExposure = new double[vertexCount];

  221.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  222.         {
  223.             uncollateralizedExposure[vertexIndex] = 0.;
  224.         }

  225.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  226.         {
  227.             double[] pathUncollateralizedExposure =
  228.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedExposure();

  229.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  230.             {
  231.                 uncollateralizedExposure[vertexIndex] += pathUncollateralizedExposure[vertexIndex];
  232.             }
  233.         }

  234.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  235.             uncollateralizedExposure[vertexIndex] /= pathCount;

  236.         return uncollateralizedExposure;
  237.     }

  238.     /**
  239.      * Retrieve the Array of Uncollateralized Exposure PV's
  240.      *
  241.      * @return The Array of Uncollateralized Exposure PV's
  242.      */

  243.     public double[] uncollateralizedExposurePV()
  244.     {
  245.         int vertexCount = vertexDates().length;

  246.         int pathCount = _pathExposureAdjustmentArray.length;
  247.         double[] uncollateralizedExposurePV = new double[vertexCount];

  248.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  249.         {
  250.             uncollateralizedExposurePV[vertexIndex] = 0.;
  251.         }

  252.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  253.         {
  254.             double[] pathUncollateralizedExposurePV =
  255.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedExposurePV();

  256.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  257.             {
  258.                 uncollateralizedExposurePV[vertexIndex] +=
  259.                     pathUncollateralizedExposurePV[vertexIndex];
  260.             }
  261.         }

  262.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  263.         {
  264.             uncollateralizedExposurePV[vertexIndex] /= pathCount;
  265.         }

  266.         return uncollateralizedExposurePV;
  267.     }

  268.     /**
  269.      * Retrieve the Array of Collateralized Positive Exposures
  270.      *
  271.      * @return The Array of Collateralized Positive Exposures
  272.      */

  273.     public double[] collateralizedPositiveExposure()
  274.     {
  275.         int vertexCount = vertexDates().length;

  276.         int pathCount = _pathExposureAdjustmentArray.length;
  277.         double[] collateralizedPositiveExposure = new double[vertexCount];

  278.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  279.         {
  280.             collateralizedPositiveExposure[vertexIndex] = 0.;
  281.         }

  282.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  283.         {
  284.             double[] pathCollateralizedPositiveExposure =
  285.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedPositiveExposure();

  286.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  287.             {
  288.                 collateralizedPositiveExposure[vertexIndex] +=
  289.                     pathCollateralizedPositiveExposure[vertexIndex];
  290.             }
  291.         }

  292.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  293.         {
  294.             collateralizedPositiveExposure[vertexIndex] /= pathCount;
  295.         }

  296.         return collateralizedPositiveExposure;
  297.     }

  298.     /**
  299.      * Retrieve the Array of Collateralized Positive Exposure PV
  300.      *
  301.      * @return The Array of Collateralized Positive Exposure PV
  302.      */

  303.     public double[] collateralizedPositiveExposurePV()
  304.     {
  305.         int vertexCount = vertexDates().length;

  306.         int pathCount = _pathExposureAdjustmentArray.length;
  307.         double[] collateralizedPositiveExposurePV = new double[vertexCount];

  308.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  309.         {
  310.             collateralizedPositiveExposurePV[vertexIndex] = 0.;
  311.         }

  312.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  313.         {
  314.             double[] pathCollateralizedPositiveExposurePV =
  315.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedPositiveExposurePV();

  316.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  317.             {
  318.                 collateralizedPositiveExposurePV[vertexIndex] +=
  319.                     pathCollateralizedPositiveExposurePV[vertexIndex];
  320.             }
  321.         }

  322.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  323.         {
  324.             collateralizedPositiveExposurePV[vertexIndex] /= pathCount;
  325.         }

  326.         return collateralizedPositiveExposurePV;
  327.     }

  328.     /**
  329.      * Retrieve the Array of Uncollateralized Positive Exposures
  330.      *
  331.      * @return The Array of Uncollateralized Positive Exposures
  332.      */

  333.     public double[] uncollateralizedPositiveExposure()
  334.     {
  335.         int vertexCount = vertexDates().length;

  336.         int pathCount = _pathExposureAdjustmentArray.length;
  337.         double[] uncollateralizedPositiveExposure = new double[vertexCount];

  338.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  339.         {
  340.             uncollateralizedPositiveExposure[vertexIndex] = 0.;
  341.         }

  342.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  343.         {
  344.             double[] pathUncollateralizedPositiveExposure =
  345.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedPositiveExposure();

  346.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  347.             {
  348.                 uncollateralizedPositiveExposure[vertexIndex] +=
  349.                     pathUncollateralizedPositiveExposure[vertexIndex];
  350.             }
  351.         }

  352.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  353.         {
  354.             uncollateralizedPositiveExposure[vertexIndex] /= pathCount;
  355.         }

  356.         return uncollateralizedPositiveExposure;
  357.     }

  358.     /**
  359.      * Retrieve the Array of Uncollateralized Positive Exposure PV
  360.      *
  361.      * @return The Array of Uncollateralized Positive Exposure PV
  362.      */

  363.     public double[] uncollateralizedPositiveExposurePV()
  364.     {
  365.         int vertexCount = vertexDates().length;

  366.         int pathCount = _pathExposureAdjustmentArray.length;
  367.         double[] uncollateralizedPositiveExposurePV = new double[vertexCount];

  368.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  369.         {
  370.             uncollateralizedPositiveExposurePV[vertexIndex] = 0.;
  371.         }

  372.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  373.         {
  374.             double[] pathUncollateralizedPositiveExposurePV =
  375.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedPositiveExposurePV();

  376.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  377.             {
  378.                 uncollateralizedPositiveExposurePV[vertexIndex] +=
  379.                     pathUncollateralizedPositiveExposurePV[vertexIndex];
  380.             }
  381.         }

  382.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  383.         {
  384.             uncollateralizedPositiveExposurePV[vertexIndex] /= pathCount;
  385.         }

  386.         return uncollateralizedPositiveExposurePV;
  387.     }

  388.     /**
  389.      * Retrieve the Array of Collateralized Negative Exposures
  390.      *
  391.      * @return The Array of Collateralized Negative Exposures
  392.      */

  393.     public double[] collateralizedNegativeExposure()
  394.     {
  395.         int vertexCount = vertexDates().length;

  396.         int pathCount = _pathExposureAdjustmentArray.length;
  397.         double[] collateralizedNegativeExposure = new double[vertexCount];

  398.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  399.         {
  400.             collateralizedNegativeExposure[vertexIndex] = 0.;
  401.         }

  402.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  403.         {
  404.             double[] pathCollateralizedNegativeExposure =
  405.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedNegativeExposure();

  406.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  407.             {
  408.                 collateralizedNegativeExposure[vertexIndex] +=
  409.                     pathCollateralizedNegativeExposure[vertexIndex];
  410.             }
  411.         }

  412.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  413.         {
  414.             collateralizedNegativeExposure[vertexIndex] /= pathCount;
  415.         }

  416.         return collateralizedNegativeExposure;
  417.     }

  418.     /**
  419.      * Retrieve the Array of Collateralized Negative Exposure PV
  420.      *
  421.      * @return The Array of Collateralized Negative Exposure PV
  422.      */

  423.     public double[] collateralizedNegativeExposurePV()
  424.     {
  425.         int vertexCount = vertexDates().length;

  426.         int pathCount = _pathExposureAdjustmentArray.length;
  427.         double[] collateralizedNegativeExposurePV = new double[vertexCount];

  428.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  429.         {
  430.             collateralizedNegativeExposurePV[vertexIndex] = 0.;
  431.         }

  432.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  433.         {
  434.             double[] pathCollateralizedNegativeExposurePV =
  435.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedNegativeExposurePV();

  436.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  437.             {
  438.                 collateralizedNegativeExposurePV[vertexIndex] +=
  439.                     pathCollateralizedNegativeExposurePV[vertexIndex];
  440.             }
  441.         }

  442.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  443.         {
  444.             collateralizedNegativeExposurePV[vertexIndex] /= pathCount;
  445.         }

  446.         return collateralizedNegativeExposurePV;
  447.     }

  448.     /**
  449.      * Retrieve the Array of Uncollateralized Negative Exposures
  450.      *
  451.      * @return The Array of Uncollateralized Negative Exposures
  452.      */

  453.     public double[] uncollateralizedNegativeExposure()
  454.     {
  455.         int vertexCount = vertexDates().length;

  456.         int pathCount = _pathExposureAdjustmentArray.length;
  457.         double[] uncollateralizedNegativeExposure = new double[vertexCount];

  458.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  459.         {
  460.             uncollateralizedNegativeExposure[vertexIndex] = 0.;
  461.         }

  462.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  463.         {
  464.             double[] pathUncollateralizedNegativeExposure =
  465.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedNegativeExposure();

  466.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  467.             {
  468.                 uncollateralizedNegativeExposure[vertexIndex] +=
  469.                     pathUncollateralizedNegativeExposure[vertexIndex];
  470.             }
  471.         }

  472.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  473.         {
  474.             uncollateralizedNegativeExposure[vertexIndex] /= pathCount;
  475.         }

  476.         return uncollateralizedNegativeExposure;
  477.     }

  478.     /**
  479.      * Retrieve the Array of Uncollateralized Negative Exposure PV
  480.      *
  481.      * @return The Array of Uncollateralized Negative Exposure PV
  482.      */

  483.     public double[] uncollateralizedNegativeExposurePV()
  484.     {
  485.         int vertexCount = vertexDates().length;

  486.         int pathCount = _pathExposureAdjustmentArray.length;
  487.         double[] uncollateralizedNegativeExposurePV = new double[vertexCount];

  488.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  489.         {
  490.             uncollateralizedNegativeExposurePV[vertexIndex] = 0.;
  491.         }

  492.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  493.         {
  494.             double[] pathUncollateralizedNegativeExposurePV =
  495.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedNegativeExposurePV();

  496.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  497.             {
  498.                 uncollateralizedNegativeExposurePV[vertexIndex] +=
  499.                     pathUncollateralizedNegativeExposurePV[vertexIndex];
  500.             }
  501.         }

  502.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  503.         {
  504.             uncollateralizedNegativeExposurePV[vertexIndex] /= pathCount;
  505.         }

  506.         return uncollateralizedNegativeExposurePV;
  507.     }

  508.     /**
  509.      * Retrieve the Array of Funding Exposures
  510.      *
  511.      * @return The Array of Funding Exposures
  512.      */

  513.     public double[] fundingExposure()
  514.     {
  515.         int vertexCount = vertexDates().length;

  516.         double[] fundingExposure = new double[vertexCount];
  517.         int pathCount = _pathExposureAdjustmentArray.length;

  518.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  519.         {
  520.             fundingExposure[vertexIndex] = 0.;
  521.         }

  522.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  523.         {
  524.             double[] pathFundingExposure = _pathExposureAdjustmentArray[pathIndex].vertexFundingExposure();

  525.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  526.             {
  527.                 fundingExposure[vertexIndex] += pathFundingExposure[vertexIndex];
  528.             }
  529.         }

  530.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  531.         {
  532.             fundingExposure[vertexIndex] /= pathCount;
  533.         }

  534.         return fundingExposure;
  535.     }

  536.     /**
  537.      * Retrieve the Array of Funding Exposure PV
  538.      *
  539.      * @return The Array of Funding Exposure PV
  540.      */

  541.     public double[] fundingExposurePV()
  542.     {
  543.         int vertexCount = vertexDates().length;

  544.         int pathCount = _pathExposureAdjustmentArray.length;
  545.         double[] fundingExposurePV = new double[vertexCount];

  546.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  547.         {
  548.             fundingExposurePV[vertexIndex] = 0.;
  549.         }

  550.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  551.         {
  552.             double[] pathFundingExposurePV =
  553.                 _pathExposureAdjustmentArray[pathIndex].vertexFundingExposurePV();

  554.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  555.             {
  556.                 fundingExposurePV[vertexIndex] += pathFundingExposurePV[vertexIndex];
  557.             }
  558.         }

  559.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  560.         {
  561.             fundingExposurePV[vertexIndex] /= pathCount;
  562.         }

  563.         return fundingExposurePV;
  564.     }

  565.     /**
  566.      * Retrieve the Expected Bilateral Collateral VA
  567.      *
  568.      * @return The Expected Bilateral Collateral VA
  569.      */

  570.     public org.drip.xva.basel.ValueAdjustment ftdcolva()
  571.     {
  572.         double ftdcolva = 0.;
  573.         int pathCount = _pathExposureAdjustmentArray.length;

  574.         try
  575.         {
  576.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  577.             {
  578.                 ftdcolva += _pathExposureAdjustmentArray[pathIndex].bilateralCollateralAdjustment();
  579.             }
  580.         }
  581.         catch (java.lang.Exception e)
  582.         {
  583.             e.printStackTrace();

  584.             return null;
  585.         }

  586.         return org.drip.xva.basel.ValueAdjustment.COLVA (ftdcolva / pathCount);
  587.     }

  588.     /**
  589.      * Retrieve the Expected Collateral VA
  590.      *
  591.      * @return The Expected Collateral VA
  592.      */

  593.     public org.drip.xva.basel.ValueAdjustment colva()
  594.     {
  595.         double colva = 0.;
  596.         int pathCount = _pathExposureAdjustmentArray.length;

  597.         try
  598.         {
  599.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  600.             {
  601.                 colva += _pathExposureAdjustmentArray[pathIndex].bilateralCollateralAdjustment();
  602.             }
  603.         }
  604.         catch (java.lang.Exception e)
  605.         {
  606.             e.printStackTrace();

  607.             return null;
  608.         }

  609.         return org.drip.xva.basel.ValueAdjustment.COLVA (colva / pathCount);
  610.     }

  611.     /**
  612.      * Retrieve the Expected Unilateral CVA
  613.      *
  614.      * @return The Expected Unilateral CVA
  615.      */

  616.     public org.drip.xva.basel.ValueAdjustment ucva()
  617.     {
  618.         double ucva = 0.;
  619.         int pathCount = _pathExposureAdjustmentArray.length;

  620.         try
  621.         {
  622.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  623.             {
  624.                 ucva += _pathExposureAdjustmentArray[pathIndex].unilateralCreditAdjustment();
  625.             }
  626.         }
  627.         catch (java.lang.Exception e)
  628.         {
  629.             e.printStackTrace();

  630.             return null;
  631.         }

  632.         return org.drip.xva.basel.ValueAdjustment.UCVA (ucva / pathCount);
  633.     }

  634.     /**
  635.      * Retrieve the Expected Bilateral/FTD CVA
  636.      *
  637.      * @return The Expected Bilateral/FTD CVA
  638.      */

  639.     public org.drip.xva.basel.ValueAdjustment ftdcva()
  640.     {
  641.         double ftdcva = 0.;
  642.         int pathCount = _pathExposureAdjustmentArray.length;

  643.         try
  644.         {
  645.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  646.             {
  647.                 ftdcva += _pathExposureAdjustmentArray[pathIndex].bilateralCreditAdjustment();
  648.             }
  649.         }
  650.         catch (java.lang.Exception e)
  651.         {
  652.             e.printStackTrace();

  653.             return null;
  654.         }

  655.         return org.drip.xva.basel.ValueAdjustment.FTDCVA (ftdcva / pathCount);
  656.     }

  657.     /**
  658.      * Retrieve the Expected CVA
  659.      *
  660.      * @return The Expected CVA
  661.      */

  662.     public org.drip.xva.basel.ValueAdjustment cva()
  663.     {
  664.         return ftdcva();
  665.     }

  666.     /**
  667.      * Retrieve the Expected CVA Contra-Liability
  668.      *
  669.      * @return The Expected CVA Contra-Liability
  670.      */

  671.     public org.drip.xva.basel.ValueAdjustment cvacl()
  672.     {
  673.         double cvacl = 0.;
  674.         int pathCount = _pathExposureAdjustmentArray.length;

  675.         try
  676.         {
  677.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  678.             {
  679.                 cvacl += _pathExposureAdjustmentArray[pathIndex].contraLiabilityCreditAdjustment();
  680.             }
  681.         }
  682.         catch (java.lang.Exception e)
  683.         {
  684.             e.printStackTrace();

  685.             return null;
  686.         }

  687.         return org.drip.xva.basel.ValueAdjustment.CVACL (cvacl / pathCount);
  688.     }

  689.     /**
  690.      * Retrieve the Expected Unilateral DVA
  691.      *
  692.      * @return The Expected Unilateral DVA
  693.      */

  694.     public org.drip.xva.basel.ValueAdjustment udva()
  695.     {
  696.         double udva = 0.;
  697.         int pathCount = _pathExposureAdjustmentArray.length;

  698.         try {
  699.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  700.             {
  701.                 udva += _pathExposureAdjustmentArray[pathIndex].unilateralDebtAdjustment();
  702.             }
  703.         }
  704.         catch (java.lang.Exception e)
  705.         {
  706.             e.printStackTrace();

  707.             return null;
  708.         }

  709.         return org.drip.xva.basel.ValueAdjustment.DVA (udva / pathCount);
  710.     }

  711.     /**
  712.      * Retrieve the Expected Bilateral DVA
  713.      *
  714.      * @return The Expected Bilateral DVA
  715.      */

  716.     public org.drip.xva.basel.ValueAdjustment ftddva()
  717.     {
  718.         double ftddva = 0.;
  719.         int pathCount = _pathExposureAdjustmentArray.length;

  720.         try {
  721.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  722.             {
  723.                 ftddva += _pathExposureAdjustmentArray[pathIndex].bilateralDebtAdjustment();
  724.             }
  725.         }
  726.         catch (java.lang.Exception e)
  727.         {
  728.             e.printStackTrace();

  729.             return null;
  730.         }

  731.         return org.drip.xva.basel.ValueAdjustment.DVA (ftddva / pathCount);
  732.     }

  733.     /**
  734.      * Retrieve the Expected DVA
  735.      *
  736.      * @return The Expected DVA
  737.      */

  738.     public org.drip.xva.basel.ValueAdjustment dva()
  739.     {
  740.         double dva = 0.;
  741.         int pathCount = _pathExposureAdjustmentArray.length;

  742.         try {
  743.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  744.             {
  745.                 dva += _pathExposureAdjustmentArray[pathIndex].debtAdjustment();
  746.             }
  747.         }
  748.         catch (java.lang.Exception e)
  749.         {
  750.             e.printStackTrace();

  751.             return null;
  752.         }

  753.         return org.drip.xva.basel.ValueAdjustment.DVA (dva / pathCount);
  754.     }

  755.     /**
  756.      * Retrieve the Expected FVA
  757.      *
  758.      * @return The Expected FVA
  759.      */

  760.     public org.drip.xva.basel.ValueAdjustment fva()
  761.     {
  762.         double fva = 0.;
  763.         int pathCount = _pathExposureAdjustmentArray.length;

  764.         try
  765.         {
  766.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  767.             {
  768.                 fva += _pathExposureAdjustmentArray[pathIndex].fundingValueAdjustment();
  769.             }
  770.         }
  771.         catch (java.lang.Exception e)
  772.         {
  773.             e.printStackTrace();

  774.             return null;
  775.         }

  776.         return org.drip.xva.basel.ValueAdjustment.FVA (fva / pathCount);
  777.     }

  778.     /**
  779.      * Retrieve the Expected FDA
  780.      *
  781.      * @return The Expected FDA
  782.      */

  783.     public org.drip.xva.basel.ValueAdjustment fda()
  784.     {
  785.         double fda = 0.;
  786.         int pathCount = _pathExposureAdjustmentArray.length;

  787.         try
  788.         {
  789.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  790.             {
  791.                 fda += _pathExposureAdjustmentArray[pathIndex].fundingDebtAdjustment();
  792.             }
  793.         }
  794.         catch (java.lang.Exception e)
  795.         {
  796.             e.printStackTrace();

  797.             return null;
  798.         }

  799.         return org.drip.xva.basel.ValueAdjustment.FDA (fda / pathCount);
  800.     }

  801.     /**
  802.      * Retrieve the Expected DVA2
  803.      *
  804.      * @return The Expected DVA2
  805.      */

  806.     public org.drip.xva.basel.ValueAdjustment dva2()
  807.     {
  808.         return fda();
  809.     }

  810.     /**
  811.      * Retrieve the Expected FCA
  812.      *
  813.      * @return The Expected FCA
  814.      */

  815.     public org.drip.xva.basel.ValueAdjustment fca()
  816.     {
  817.         double fca = 0.;
  818.         int pathCount = _pathExposureAdjustmentArray.length;

  819.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  820.         {
  821.             fca += _pathExposureAdjustmentArray[pathIndex].fundingCostAdjustment();
  822.         }

  823.         return org.drip.xva.basel.ValueAdjustment.HYBRID (fca / pathCount);
  824.     }

  825.     /**
  826.      * Retrieve the Expected FBA
  827.      *
  828.      * @return The Expected FBA
  829.      */

  830.     public org.drip.xva.basel.ValueAdjustment fba()
  831.     {
  832.         double fba = 0.;
  833.         int pathCount = _pathExposureAdjustmentArray.length;

  834.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  835.         {
  836.             fba += _pathExposureAdjustmentArray[pathIndex].fundingBenefitAdjustment();
  837.         }

  838.         return org.drip.xva.basel.ValueAdjustment.HYBRID (fba / pathCount);
  839.     }

  840.     /**
  841.      * Retrieve the Expected SFVA
  842.      *
  843.      * @return The Expected SFVA
  844.      */

  845.     public org.drip.xva.basel.ValueAdjustment sfva()
  846.     {
  847.         double sfva = 0.;
  848.         int pathCount = _pathExposureAdjustmentArray.length;

  849.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  850.         {
  851.             sfva += _pathExposureAdjustmentArray[pathIndex].symmetricFundingValueAdjustment();
  852.         }

  853.         return org.drip.xva.basel.ValueAdjustment.HYBRID (sfva / pathCount);
  854.     }

  855.     /**
  856.      * Retrieve the Total VA
  857.      *
  858.      * @return The Total VA
  859.      */

  860.     public double total()
  861.     {
  862.         return cva().amount() + dva().amount() + fva().amount() + colva().amount();
  863.     }

  864.     /**
  865.      * Generate the "Digest" containing the "Thin" Path Statistics
  866.      *
  867.      * @return The "Digest" containing the "Thin" Path Statistics
  868.      */

  869.     public org.drip.xva.gross.ExposureAdjustmentDigest digest()
  870.     {
  871.         int vertexCount = vertexDates().length;

  872.         int pathCount = _pathExposureAdjustmentArray.length;
  873.         double[] pathCVA = new double[pathCount];
  874.         double[] pathDVA = new double[pathCount];
  875.         double[] pathFBA = new double[pathCount];
  876.         double[] pathFCA = new double[pathCount];
  877.         double[] pathFDA = new double[pathCount];
  878.         double[] pathFVA = new double[pathCount];
  879.         double[] pathUCVA = new double[pathCount];
  880.         double[] pathSFVA = new double[pathCount];
  881.         double[] pathCVACL = new double[pathCount];
  882.         double[] pathFTDCVA = new double[pathCount];
  883.         double[] pathCOLVA = new double[pathCount];
  884.         double[] pathTotalVA = new double[pathCount];
  885.         double[] pathFTDCOLVA = new double[pathCount];
  886.         double[][] fundingExposure = new double[vertexCount][pathCount];
  887.         double[][] fundingExposurePV = new double[vertexCount][pathCount];
  888.         double[][] collateralizedExposure = new double[vertexCount][pathCount];
  889.         double[][] uncollateralizedExposure = new double[vertexCount][pathCount];
  890.         double[][] collateralizedExposurePV = new double[vertexCount][pathCount];
  891.         double[][] uncollateralizedExposurePV = new double[vertexCount][pathCount];
  892.         double[][] collateralizedPositiveExposure = new double[vertexCount][pathCount];
  893.         double[][] collateralizedNegativeExposure = new double[vertexCount][pathCount];
  894.         double[][] uncollateralizedPositiveExposure = new double[vertexCount][pathCount];
  895.         double[][] uncollateralizedNegativeExposure = new double[vertexCount][pathCount];
  896.         double[][] collateralizedPositiveExposurePV = new double[vertexCount][pathCount];
  897.         double[][] collateralizedNegativeExposurePV = new double[vertexCount][pathCount];
  898.         double[][] uncollateralizedPositiveExposurePV = new double[vertexCount][pathCount];
  899.         double[][] uncollateralizedNegativeExposurePV = new double[vertexCount][pathCount];

  900.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  901.         {
  902.             for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  903.             {
  904.                 collateralizedExposure[vertexIndex][pathIndex] = 0.;
  905.                 uncollateralizedExposure[vertexIndex][pathIndex] = 0.;
  906.                 collateralizedExposurePV[vertexIndex][pathIndex] = 0.;
  907.                 uncollateralizedExposurePV[vertexIndex][pathIndex] = 0.;
  908.                 collateralizedPositiveExposure[vertexIndex][pathIndex] = 0.;
  909.                 collateralizedNegativeExposure[vertexIndex][pathIndex] = 0.;
  910.                 uncollateralizedPositiveExposure[vertexIndex][pathIndex] = 0.;
  911.                 uncollateralizedNegativeExposure[vertexIndex][pathIndex] = 0.;
  912.                 collateralizedPositiveExposurePV[vertexIndex][pathIndex] = 0.;
  913.                 collateralizedNegativeExposurePV[vertexIndex][pathIndex] = 0.;
  914.                 uncollateralizedPositiveExposurePV[vertexIndex][pathIndex] = 0.;
  915.                 uncollateralizedNegativeExposurePV[vertexIndex][pathIndex] = 0.;
  916.             }
  917.         }

  918.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  919.         {
  920.             double[] pathCollateralizedExposure =
  921.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedExposure();

  922.             double[] pathCollateralizedExposurePV =
  923.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedExposurePV();

  924.             double[] pathCollateralizedPositiveExposure =
  925.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedPositiveExposure();

  926.             double[] pathCollateralizedPositiveExposurePV =
  927.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedPositiveExposurePV();

  928.             double[] pathCollateralizedNegativeExposure =
  929.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedNegativeExposure();

  930.             double[] pathCollateralizedNegativeExposurePV =
  931.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedNegativeExposurePV();

  932.             double[] pathUncollateralizedExposure =
  933.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedExposure();

  934.             double[] pathUncollateralizedExposurePV =
  935.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedExposurePV();

  936.             double[] pathUncollateralizedPositiveExposure =
  937.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedPositiveExposure();

  938.             double[] pathUncollateralizedPositiveExposurePV =
  939.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedPositiveExposurePV();

  940.             double[] pathUncollateralizedNegativeExposure =
  941.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedNegativeExposure();

  942.             double[] pathUncollateralizedNegativeExposurePV =
  943.                 _pathExposureAdjustmentArray[pathIndex].vertexUncollateralizedNegativeExposurePV();

  944.             double[] pathFundingExposure = _pathExposureAdjustmentArray[pathIndex].vertexFundingExposure();

  945.             double[] pathFundingExposurePV =
  946.                 _pathExposureAdjustmentArray[pathIndex].vertexFundingExposurePV();

  947.             try
  948.             {
  949.                 pathCVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].creditAdjustment();

  950.                 pathDVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].debtAdjustment();

  951.                 pathFCA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].fundingCostAdjustment();

  952.                 pathFDA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].fundingDebtAdjustment();

  953.                 pathFVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].fundingValueAdjustment();

  954.                 pathFBA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].fundingBenefitAdjustment();

  955.                 pathUCVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].unilateralCreditAdjustment();

  956.                 pathSFVA[pathIndex] =
  957.                     _pathExposureAdjustmentArray[pathIndex].symmetricFundingValueAdjustment();

  958.                 pathCVACL[pathIndex] =
  959.                     _pathExposureAdjustmentArray[pathIndex].contraLiabilityCreditAdjustment();

  960.                 pathFTDCVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].bilateralCreditAdjustment();

  961.                 pathCOLVA[pathIndex] =
  962.                     _pathExposureAdjustmentArray[pathIndex].bilateralCollateralAdjustment();

  963.                 pathFTDCOLVA[pathIndex] =
  964.                     _pathExposureAdjustmentArray[pathIndex].bilateralCollateralAdjustment();

  965.                 pathTotalVA[pathIndex] = _pathExposureAdjustmentArray[pathIndex].totalAdjustment();
  966.             }
  967.             catch (java.lang.Exception e)
  968.             {
  969.                 e.printStackTrace();

  970.                 return null;
  971.             }

  972.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  973.             {
  974.                 collateralizedExposure[vertexIndex][pathIndex] =
  975.                     pathCollateralizedExposure[vertexIndex];
  976.                 collateralizedExposurePV[vertexIndex][pathIndex] =
  977.                     pathCollateralizedExposurePV[vertexIndex];
  978.                 collateralizedPositiveExposure[vertexIndex][pathIndex] =
  979.                     pathCollateralizedPositiveExposure[vertexIndex];
  980.                 collateralizedPositiveExposurePV[vertexIndex][pathIndex] =
  981.                     pathCollateralizedPositiveExposurePV[vertexIndex];
  982.                 collateralizedNegativeExposure[vertexIndex][pathIndex] =
  983.                     pathCollateralizedNegativeExposure[vertexIndex];
  984.                 collateralizedNegativeExposurePV[vertexIndex][pathIndex] =
  985.                     pathCollateralizedNegativeExposurePV[vertexIndex];
  986.                 uncollateralizedExposure[vertexIndex][pathIndex] =
  987.                     pathUncollateralizedExposure[vertexIndex];
  988.                 uncollateralizedExposurePV[vertexIndex][pathIndex] =
  989.                     pathUncollateralizedExposurePV[vertexIndex];
  990.                 uncollateralizedPositiveExposure[vertexIndex][pathIndex] =
  991.                     pathUncollateralizedPositiveExposure[vertexIndex];
  992.                 uncollateralizedPositiveExposurePV[vertexIndex][pathIndex] =
  993.                     pathUncollateralizedPositiveExposurePV[vertexIndex];
  994.                 uncollateralizedNegativeExposure[vertexIndex][pathIndex] =
  995.                     pathUncollateralizedNegativeExposure[vertexIndex];
  996.                 uncollateralizedNegativeExposurePV[vertexIndex][pathIndex] =
  997.                     pathUncollateralizedNegativeExposurePV[vertexIndex];
  998.                 fundingExposure[vertexIndex][pathIndex] = pathFundingExposure[vertexIndex];
  999.                 fundingExposurePV[vertexIndex][pathIndex] = pathFundingExposurePV[vertexIndex];
  1000.             }
  1001.         }

  1002.         try
  1003.         {
  1004.             return new org.drip.xva.gross.ExposureAdjustmentDigest (
  1005.                 pathCOLVA,
  1006.                 pathFTDCOLVA,
  1007.                 pathUCVA,
  1008.                 pathFTDCVA,
  1009.                 pathCVA,
  1010.                 pathCVACL,
  1011.                 pathDVA,
  1012.                 pathFVA,
  1013.                 pathFDA,
  1014.                 pathFCA,
  1015.                 pathFBA,
  1016.                 pathSFVA,
  1017.                 pathTotalVA,
  1018.                 collateralizedExposure,
  1019.                 collateralizedExposurePV,
  1020.                 collateralizedPositiveExposure,
  1021.                 collateralizedPositiveExposurePV,
  1022.                 collateralizedNegativeExposure,
  1023.                 collateralizedNegativeExposurePV,
  1024.                 uncollateralizedExposure,
  1025.                 uncollateralizedExposurePV,
  1026.                 uncollateralizedPositiveExposure,
  1027.                 uncollateralizedPositiveExposurePV,
  1028.                 uncollateralizedNegativeExposure,
  1029.                 uncollateralizedNegativeExposurePV,
  1030.                 fundingExposure,
  1031.                 fundingExposurePV
  1032.             );
  1033.         }
  1034.         catch (java.lang.Exception e)
  1035.         {
  1036.             e.printStackTrace();
  1037.         }

  1038.         return null;
  1039.     }

  1040.     /**
  1041.      * Generate the Basel Exposure Digest
  1042.      *
  1043.      * @param standardizedExposureGeneratorScheme The Standardized Basel Exposure Generation Scheme
  1044.      *
  1045.      * @return The Basel Exposure Digest
  1046.      */

  1047.     public org.drip.xva.gross.BaselExposureDigest baselExposureDigest (
  1048.         final org.drip.xva.settings.StandardizedExposureGeneratorScheme standardizedExposureGeneratorScheme)
  1049.     {
  1050.         if (null == standardizedExposureGeneratorScheme)
  1051.         {
  1052.             return null;
  1053.         }

  1054.         org.drip.analytics.date.JulianDate[] vertexJulianDateArray = vertexDates();

  1055.         int vertexCount = vertexJulianDateArray.length;
  1056.         int[] vertexDateArray = new int[vertexCount];
  1057.         int pathCount = _pathExposureAdjustmentArray.length;
  1058.         double[] collateralizedPositiveExposure = new double[vertexCount];
  1059.         double[] effectiveCollateralizedPositiveExposure = new double[vertexCount];
  1060.         org.drip.spline.params.SegmentCustomBuilderControl[] collateralizedExposureSegmentBuilderControlArray
  1061.             = new org.drip.spline.params.SegmentCustomBuilderControl[vertexCount - 1];
  1062.         org.drip.spline.params.SegmentCustomBuilderControl[]
  1063.             collateralizedPositiveExposureSegmentBuilderControlArray = new
  1064.                 org.drip.spline.params.SegmentCustomBuilderControl[vertexCount - 1];

  1065.         org.drip.spline.params.SegmentCustomBuilderControl collateralizedExposureSegmentBuilderControl =
  1066.             standardizedExposureGeneratorScheme.collateralizedExposureSegmentBuilderControl();

  1067.         org.drip.spline.params.SegmentCustomBuilderControl
  1068.             collateralizedPositiveExposureSegmentBuilderControl =
  1069.                 standardizedExposureGeneratorScheme.collateralizedPositiveExposureSegmentBuilderControl();

  1070.         for (int i = 0; i < vertexCount - 1; ++i)
  1071.         {
  1072.             collateralizedExposureSegmentBuilderControlArray[i] =
  1073.                 collateralizedExposureSegmentBuilderControl;
  1074.             collateralizedPositiveExposureSegmentBuilderControlArray[i] =
  1075.                 collateralizedPositiveExposureSegmentBuilderControl;
  1076.         }

  1077.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  1078.         {
  1079.             collateralizedPositiveExposure[vertexIndex] = 0.;

  1080.             vertexDateArray[vertexIndex] = vertexJulianDateArray[vertexIndex].julian();
  1081.         }

  1082.         for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex)
  1083.         {
  1084.             double[] pathCollateralizedPositiveExposure =
  1085.                 _pathExposureAdjustmentArray[pathIndex].vertexCollateralizedPositiveExposure();

  1086.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  1087.             {
  1088.                 collateralizedPositiveExposure[vertexIndex] +=
  1089.                     pathCollateralizedPositiveExposure[vertexIndex];
  1090.             }
  1091.         }

  1092.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  1093.         {
  1094.             collateralizedPositiveExposure[vertexIndex] /= pathCount;

  1095.             if (0 == vertexIndex)
  1096.             {
  1097.                 effectiveCollateralizedPositiveExposure[0] = collateralizedPositiveExposure[0];
  1098.             }
  1099.             else
  1100.             {
  1101.                 effectiveCollateralizedPositiveExposure[vertexIndex] =
  1102.                     collateralizedPositiveExposure[vertexIndex] >
  1103.                     effectiveCollateralizedPositiveExposure[vertexIndex - 1] ?
  1104.                     collateralizedPositiveExposure[vertexIndex] :
  1105.                     effectiveCollateralizedPositiveExposure[vertexIndex - 1];
  1106.             }
  1107.         }

  1108.         try
  1109.         {
  1110.             org.drip.spline.stretch.MultiSegmentSequence multiSegmentSequenceCollateralizedPositiveExposure =
  1111.                 org.drip.spline.stretch.MultiSegmentSequenceBuilder.CreateCalibratedStretchEstimator (
  1112.                     "CollateralizedPositiveExposure",
  1113.                     vertexDateArray,
  1114.                     collateralizedPositiveExposure,
  1115.                     collateralizedExposureSegmentBuilderControlArray,
  1116.                     null,
  1117.                     org.drip.spline.stretch.BoundarySettings.NaturalStandard(),
  1118.                     org.drip.spline.stretch.MultiSegmentSequence.CALIBRATE
  1119.                 );

  1120.             org.drip.spline.stretch.MultiSegmentSequence
  1121.                 multiSegmentSequenceEffectiveCollateralizedPositiveExposure =
  1122.                     org.drip.spline.stretch.MultiSegmentSequenceBuilder.CreateCalibratedStretchEstimator (
  1123.                         "EffectiveCollateralizedPositiveExposure",
  1124.                         vertexDateArray,
  1125.                         effectiveCollateralizedPositiveExposure,
  1126.                         collateralizedPositiveExposureSegmentBuilderControlArray,
  1127.                         null,
  1128.                         org.drip.spline.stretch.BoundarySettings.NaturalStandard(),
  1129.                         org.drip.spline.stretch.MultiSegmentSequence.CALIBRATE
  1130.                     );

  1131.             if (null == multiSegmentSequenceCollateralizedPositiveExposure ||
  1132.                 null == multiSegmentSequenceEffectiveCollateralizedPositiveExposure)
  1133.             {
  1134.                 return null;
  1135.             }

  1136.             int exposureGeneratorTimeIntegrand = standardizedExposureGeneratorScheme.timeIntegrand();

  1137.             int integrandFinishDate = vertexDateArray[0] + exposureGeneratorTimeIntegrand;

  1138.             double effectiveExpectedPositiveExposure =
  1139.                 multiSegmentSequenceEffectiveCollateralizedPositiveExposure.toAU().integrate (
  1140.                     vertexDateArray[0],
  1141.                     integrandFinishDate
  1142.                 ) / exposureGeneratorTimeIntegrand;

  1143.             return new BaselExposureDigest (
  1144.                 collateralizedPositiveExposure[0],
  1145.                 multiSegmentSequenceCollateralizedPositiveExposure.toAU().integrate (
  1146.                     vertexDateArray[0],
  1147.                     integrandFinishDate
  1148.                 ) / exposureGeneratorTimeIntegrand,
  1149.                 effectiveCollateralizedPositiveExposure[vertexCount - 1],
  1150.                 effectiveExpectedPositiveExposure,
  1151.                 effectiveExpectedPositiveExposure * standardizedExposureGeneratorScheme.eadMultiplier()
  1152.             );
  1153.         }
  1154.         catch (java.lang.Exception e)
  1155.         {
  1156.             e.printStackTrace();
  1157.         }

  1158.         return null;
  1159.     }
  1160. }