FundingGroupPath.java

  1. package org.drip.xva.netting;

  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>FundingGroupPath</i> holds up the Strategy Abstract Realizations of the Sequence in a Single Path
  78.  * Projection Run over Multiple Collateral Groups onto a Single Funding Group - the Purpose being to
  79.  * calculate Funding Valuation Adjustments. The References are:
  80.  *
  81.  *  <br><br>
  82.  *  <ul>
  83.  *      <li>
  84.  *          Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party
  85.  *              Risk and Funding Costs <i>Journal of Credit Risk</i> <b>7 (3)</b> 1-19
  86.  *      </li>
  87.  *      <li>
  88.  *          Burgard, C., and M. Kjaer (2014): In the Balance <i>Risk</i> <b>24 (11)</b> 72-75
  89.  *      </li>
  90.  *      <li>
  91.  *          Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk <i>Risk</i> <b>20 (2)</b>
  92.  *              86-90
  93.  *      </li>
  94.  *      <li>
  95.  *          Li, B., and Y. Tang (2007): <i>Quantitative Analysis, Derivatives Modeling, and Trading
  96.  *              Strategies in the Presence of Counter-party Credit Risk for the Fixed Income Market</i>
  97.  *              <b>World Scientific Publishing</b> Singapore
  98.  *      </li>
  99.  *      <li>
  100.  *          Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing
  101.  *              <i>Risk</i> <b>21 (2)</b> 97-102
  102.  *      </li>
  103.  *  </ul>
  104.  *
  105.  *  <br><br>
  106.  *  <ul>
  107.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  108.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/XVAAnalyticsLibrary.md">XVA Analytics Library</a></li>
  109.  *      <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>
  110.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/xva/netting/README.md">Credit/Debt/Funding Netting Groups</a></li>
  111.  *  </ul>
  112.  * <br><br>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public abstract class FundingGroupPath
  117. {
  118.     private org.drip.exposure.universe.MarketPath _marketPath = null;
  119.     private org.drip.xva.netting.CreditDebtGroupPath[] _creditDebtGroupPathArray = null;

  120.     protected FundingGroupPath (
  121.         final org.drip.xva.netting.CreditDebtGroupPath[] creditDebtGroupPathArray,
  122.         final org.drip.exposure.universe.MarketPath marketPath)
  123.         throws java.lang.Exception
  124.     {
  125.         if (null == (_creditDebtGroupPathArray = creditDebtGroupPathArray) ||
  126.             null == (_marketPath = marketPath))
  127.         {
  128.             throw new java.lang.Exception ("FundingGroupPath Constructor => Invalid Inputs");
  129.         }
  130.     }

  131.     /**
  132.      * Retrieve the Array of CreditDebtGroupPath
  133.      *
  134.      * @return The Array of CreditDebtGroupPath
  135.      */

  136.     public org.drip.xva.netting.CreditDebtGroupPath[] creditDebtGroupPathArray()
  137.     {
  138.         return _creditDebtGroupPathArray;
  139.     }

  140.     /**
  141.      * Retrieve the Market Path
  142.      *
  143.      * @return The Market Path
  144.      */

  145.     public org.drip.exposure.universe.MarketPath marketPath()
  146.     {
  147.         return _marketPath;
  148.     }

  149.     /**
  150.      * Retrieve the Array of the Vertex Anchor Dates
  151.      *
  152.      * @return The Array of the Vertex Anchor Dates
  153.      */

  154.     public org.drip.analytics.date.JulianDate[] vertexDates()
  155.     {
  156.         return _creditDebtGroupPathArray[0].vertexDates();
  157.     }

  158.     /**
  159.      * Compute Path Symmetric Funding Value Spread 01
  160.      *
  161.      * @return The Path Symmetric Funding Value Spread 01
  162.      */

  163.     public double symmetricFundingValueSpread01()
  164.     {
  165.         double symmetricFundingSpread01 = 0.;
  166.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  167.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  168.             ++creditDebtGroupIndex)
  169.         {
  170.             symmetricFundingSpread01 +=
  171.                 _creditDebtGroupPathArray[creditDebtGroupIndex].symmetricFundingValueSpread01();
  172.         }

  173.         return symmetricFundingSpread01;
  174.     }

  175.     /**
  176.      * Compute Path Unilateral Funding Value Spread 01
  177.      *
  178.      * @return The Path Unilateral Funding Value Spread 01
  179.      */

  180.     public double unilateralFundingValueSpread01()
  181.     {
  182.         double unilateralFundingValueSpread01 = 0.;
  183.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  184.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  185.             ++creditDebtGroupIndex)
  186.         {
  187.             unilateralFundingValueSpread01 +=
  188.                 _creditDebtGroupPathArray[creditDebtGroupIndex].unilateralFundingValueSpread01();
  189.         }

  190.         return 0. > unilateralFundingValueSpread01 ? 0. : unilateralFundingValueSpread01;
  191.     }

  192.     /**
  193.      * Compute Path Bilateral Funding Value Spread 01
  194.      *
  195.      * @return The Path Bilateral Funding Value Spread 01
  196.      */

  197.     public double bilateralFundingValueSpread01()
  198.     {
  199.         double bilateralFundingValueSpread01 = 0.;
  200.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  201.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  202.             ++creditDebtGroupIndex)
  203.         {
  204.             bilateralFundingValueSpread01 +=
  205.                 _creditDebtGroupPathArray[creditDebtGroupIndex].bilateralFundingValueSpread01();
  206.         }

  207.         return 0. > bilateralFundingValueSpread01 ? 0. : bilateralFundingValueSpread01;
  208.     }

  209.     /**
  210.      * Compute Period Symmetric Funding Value Spread 01
  211.      *
  212.      * @return The Period Symmetric Funding Value Spread 01
  213.      */

  214.     public double[] periodSymmetricFundingValueSpread01()
  215.     {
  216.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  217.         int periodCount = marketVertexArray.length - 1;
  218.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  219.         double[] periodSymmetricFundingValueSpread01 = new double[periodCount];

  220.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  221.         {
  222.             periodSymmetricFundingValueSpread01[periodIndex] = 0.;
  223.         }

  224.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  225.             ++creditDebtGroupIndex)
  226.         {
  227.             double[] periodCreditDebtGroupSymmetricFundingValueSpread01 =
  228.                 _creditDebtGroupPathArray[creditDebtGroupIndex].periodSymmetricFundingValueSpread01();

  229.             for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  230.             {
  231.                 periodSymmetricFundingValueSpread01[periodIndex] +=
  232.                     periodCreditDebtGroupSymmetricFundingValueSpread01[periodIndex];
  233.             }
  234.         }

  235.         return periodSymmetricFundingValueSpread01;
  236.     }

  237.     /**
  238.      * Compute Period Unilateral Funding Value Spread 01
  239.      *
  240.      * @return The Period Unilateral Funding Value Spread 01
  241.      */

  242.     public double[] periodUnilateralFundingValueSpread01()
  243.     {
  244.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  245.         int periodCount = marketVertexArray.length - 1;
  246.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  247.         double[] periodUnilateralFundingValueSpread01 = new double[periodCount];

  248.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  249.         {
  250.             periodUnilateralFundingValueSpread01[periodIndex] = 0.;
  251.         }

  252.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  253.             ++creditDebtGroupIndex)
  254.         {
  255.             double[] periodCreditDebtGroupUnilateralFundingValueSpread01 =
  256.                 _creditDebtGroupPathArray[creditDebtGroupIndex].periodUnilateralFundingValueSpread01();

  257.             for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  258.             {
  259.                 periodUnilateralFundingValueSpread01[periodIndex] +=
  260.                     periodCreditDebtGroupUnilateralFundingValueSpread01[periodIndex];
  261.             }
  262.         }

  263.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  264.         {
  265.             if (0. > periodUnilateralFundingValueSpread01[periodIndex])
  266.             {
  267.                 periodUnilateralFundingValueSpread01[periodIndex] = 0.;
  268.             }
  269.         }

  270.         return periodUnilateralFundingValueSpread01;
  271.     }

  272.     /**
  273.      * Compute Period Bilateral Funding Value Spread 01
  274.      *
  275.      * @return The Period Bilateral Funding Value Spread 01
  276.      */

  277.     public double[] periodBilateralFundingValueSpread01()
  278.     {
  279.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  280.         int periodCount = marketVertexArray.length - 1;
  281.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  282.         double[] periodBilateralFundingValueSpread01 = new double[periodCount];

  283.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  284.         {
  285.             periodBilateralFundingValueSpread01[periodIndex] = 0.;
  286.         }

  287.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  288.             ++creditDebtGroupIndex)
  289.         {
  290.             double[] periodCreditDebtGroupBilateralFundingValueSpread01 =
  291.                 _creditDebtGroupPathArray[creditDebtGroupIndex].periodBilateralFundingValueSpread01();

  292.             for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  293.             {
  294.                 periodBilateralFundingValueSpread01[periodIndex] +=
  295.                     periodCreditDebtGroupBilateralFundingValueSpread01[periodIndex];
  296.             }
  297.         }

  298.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  299.         {
  300.             if (0. > periodBilateralFundingValueSpread01[periodIndex])
  301.             {
  302.                 periodBilateralFundingValueSpread01[periodIndex] = 0.;
  303.             }
  304.         }

  305.         return periodBilateralFundingValueSpread01;
  306.     }

  307.     /**
  308.      * Compute Path Symmetric Funding Value Adjustment
  309.      *
  310.      * @return The Path Symmetric Funding Value Adjustment
  311.      */

  312.     public double symmetricFundingValueAdjustment()
  313.     {
  314.         double[] periodSymmetricFundingValueSpread01 = periodSymmetricFundingValueSpread01();

  315.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  316.         int periodCount = periodSymmetricFundingValueSpread01.length;
  317.         double symmetricFundingValueAdjustment = 0.;

  318.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  319.         {
  320.             symmetricFundingValueAdjustment +=
  321.                 0.5 * periodSymmetricFundingValueSpread01[periodIndex] * (
  322.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  323.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  324.                 );
  325.         }

  326.         return symmetricFundingValueAdjustment;
  327.     }

  328.     /**
  329.      * Compute Path Unilateral Funding Value Adjustment
  330.      *
  331.      * @return The Path Unilateral Funding Value Adjustment
  332.      */

  333.     public double unilateralFundingValueAdjustment()
  334.     {
  335.         double[] periodUnilateralFundingValueSpread01 = periodUnilateralFundingValueSpread01();

  336.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  337.         int periodCount = periodUnilateralFundingValueSpread01.length;
  338.         double unilateralFundingValueAdjustment = 0.;

  339.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  340.         {
  341.             unilateralFundingValueAdjustment -=
  342.                 0.5 * periodUnilateralFundingValueSpread01[periodIndex] * (
  343.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  344.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  345.                 );
  346.         }

  347.         return unilateralFundingValueAdjustment;
  348.     }

  349.     /**
  350.      * Compute Path Bilateral Funding Value Adjustment
  351.      *
  352.      * @return The Path Bilateral Funding Value Adjustment
  353.      */

  354.     public double bilateralFundingValueAdjustment()
  355.     {
  356.         double[] periodBilateralFundingValueSpread01 = periodBilateralFundingValueSpread01();

  357.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  358.         int periodCount = periodBilateralFundingValueSpread01.length;
  359.         double bilateralFundingValueAdjustment = 0.;

  360.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  361.         {
  362.             bilateralFundingValueAdjustment -=
  363.                 0.5 * periodBilateralFundingValueSpread01[periodIndex] * (
  364.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  365.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  366.                 );
  367.         }

  368.         return bilateralFundingValueAdjustment;
  369.     }

  370.     /**
  371.      * Compute Path Unilateral Funding Debt Adjustment
  372.      *
  373.      * @return The Path Unilateral Funding Debt Adjustment
  374.      */

  375.     public double unilateralFundingDebtAdjustment()
  376.     {
  377.         double[] periodUnilateralFundingDebtAdjustment = periodUnilateralFundingDebtAdjustment();

  378.         int periodCount = periodUnilateralFundingDebtAdjustment.length;
  379.         double unilateralFundingDebtAdjustment = 0.;

  380.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  381.         {
  382.             unilateralFundingDebtAdjustment += periodUnilateralFundingDebtAdjustment[periodIndex];
  383.         }

  384.         return unilateralFundingDebtAdjustment;
  385.     }

  386.     /**
  387.      * Compute Path Bilateral Funding Debt Adjustment
  388.      *
  389.      * @return The Path Bilateral Funding Debt Adjustment
  390.      */

  391.     public double bilateralFundingDebtAdjustment()
  392.     {
  393.         double[] periodBilateralFundingDebtAdjustment = periodBilateralFundingDebtAdjustment();

  394.         int periodCount = periodBilateralFundingDebtAdjustment.length;
  395.         double bilateralFundingDebtAdjustment = 0.;

  396.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  397.         {
  398.             bilateralFundingDebtAdjustment += periodBilateralFundingDebtAdjustment[periodIndex];
  399.         }

  400.         return bilateralFundingDebtAdjustment;
  401.     }

  402.     /**
  403.      * Compute Vertex Path Collateralized Exposure
  404.      *
  405.      * @return The Vertex Path Collateralized Exposure
  406.      */

  407.     public double[] vertexCollateralizedExposure()
  408.     {
  409.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  410.         int vertexCount = marketVertexArray.length;
  411.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  412.         double[] vertexCollateralizedExposure = new double[vertexCount];

  413.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  414.         {
  415.             vertexCollateralizedExposure[vertexIndex] = 0.;
  416.         }

  417.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  418.             ++creditDebtGroupIndex)
  419.         {
  420.             double[] creditDebtGroupVertexCollateralizedExposure =
  421.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedExposure();

  422.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  423.             {
  424.                 vertexCollateralizedExposure[vertexIndex] +=
  425.                     creditDebtGroupVertexCollateralizedExposure[vertexIndex];
  426.             }
  427.         }

  428.         return vertexCollateralizedExposure;
  429.     }

  430.     /**
  431.      * Compute Vertex Path Collateralized Exposure PV
  432.      *
  433.      * @return The Vertex Path Collateralized Exposure PV
  434.      */

  435.     public double[] vertexCollateralizedExposurePV()
  436.     {
  437.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  438.         int vertexCount = marketVertexArray.length;
  439.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  440.         double[] vertexCollateralizedExposurePV = new double[vertexCount];

  441.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  442.         {
  443.             vertexCollateralizedExposurePV[vertexIndex] = 0.;
  444.         }

  445.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  446.             ++creditDebtGroupIndex)
  447.         {
  448.             double[] creditDebtGroupVertexCollateralizedExposurePV =
  449.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedExposurePV();

  450.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  451.             {
  452.                 vertexCollateralizedExposurePV[vertexIndex] +=
  453.                     creditDebtGroupVertexCollateralizedExposurePV[vertexIndex];
  454.             }
  455.         }

  456.         return vertexCollateralizedExposurePV;
  457.     }

  458.     /**
  459.      * Compute Vertex Path Collateralized Positive Exposure
  460.      *
  461.      * @return The Vertex Path Collateralized Positive Exposure
  462.      */

  463.     public double[] vertexCollateralizedPositiveExposure()
  464.     {
  465.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  466.         int vertexCount = marketVertexArray.length;
  467.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  468.         double[] vertexCollateralizedPositiveExposure = new double[vertexCount];

  469.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  470.         {
  471.             vertexCollateralizedPositiveExposure[vertexIndex] = 0.;
  472.         }

  473.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  474.             ++creditDebtGroupIndex)
  475.         {
  476.             double[] creditDebtGroupVertexCollateralizedPositiveExposure =
  477.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedPositiveExposure();

  478.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  479.             {
  480.                 vertexCollateralizedPositiveExposure[vertexIndex] +=
  481.                     creditDebtGroupVertexCollateralizedPositiveExposure[vertexIndex];
  482.             }
  483.         }

  484.         return vertexCollateralizedPositiveExposure;
  485.     }

  486.     /**
  487.      * Compute Vertex Path Collateralized Positive Exposure PV
  488.      *
  489.      * @return The Vertex Path Collateralized Positive Exposure PV
  490.      */

  491.     public double[] vertexCollateralizedPositiveExposurePV()
  492.     {
  493.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  494.         int vertexCount = marketVertexArray.length;
  495.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  496.         double[] vertexCollateralizedPositiveExposurePV = new double[vertexCount];

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

  501.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  502.             ++creditDebtGroupIndex)
  503.         {
  504.             double[] creditDebtGroupVertexCollateralizedPositiveExposurePV =
  505.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedPositiveExposurePV();

  506.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  507.             {
  508.                 vertexCollateralizedPositiveExposurePV[vertexIndex] +=
  509.                     creditDebtGroupVertexCollateralizedPositiveExposurePV[vertexIndex];
  510.             }
  511.         }

  512.         return vertexCollateralizedPositiveExposurePV;
  513.     }

  514.     /**
  515.      * Compute Vertex Path Collateralized Negative Exposure
  516.      *
  517.      * @return The Vertex Path Collateralized Negative Exposure
  518.      */

  519.     public double[] vertexCollateralizedNegativeExposure()
  520.     {
  521.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  522.         int vertexCount = marketVertexArray.length;
  523.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  524.         double[] vertexCollateralizedNegativeExposure = new double[vertexCount];

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

  529.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  530.             ++creditDebtGroupIndex)
  531.         {
  532.             double[] creditDebtGroupVertexCollateralizedNegativeExposure =
  533.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedNegativeExposure();

  534.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  535.             {
  536.                 vertexCollateralizedNegativeExposure[vertexIndex] +=
  537.                     creditDebtGroupVertexCollateralizedNegativeExposure[vertexIndex];
  538.             }
  539.         }

  540.         return vertexCollateralizedNegativeExposure;
  541.     }

  542.     /**
  543.      * Compute Vertex Path Collateralized Negative Exposure PV
  544.      *
  545.      * @return The Vertex Path Collateralized Negative Exposure PV
  546.      */

  547.     public double[] vertexCollateralizedNegativeExposurePV()
  548.     {
  549.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  550.         int vertexCount = marketVertexArray.length;
  551.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  552.         double[] vertexCollateralizedNegativeExposurePV = new double[vertexCount];

  553.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  554.         {
  555.             vertexCollateralizedNegativeExposurePV[vertexIndex] = 0.;
  556.         }

  557.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  558.             ++creditDebtGroupIndex)
  559.         {
  560.             double[] creditDebtGroupVertexCollateralizedNegativeExposurePV =
  561.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexCollateralizedNegativeExposurePV();

  562.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  563.             {
  564.                 vertexCollateralizedNegativeExposurePV[vertexIndex] +=
  565.                     creditDebtGroupVertexCollateralizedNegativeExposurePV[vertexIndex];
  566.             }
  567.         }

  568.         return vertexCollateralizedNegativeExposurePV;
  569.     }

  570.     /**
  571.      * Compute Vertex Path Uncollateralized Exposure
  572.      *
  573.      * @return The Vertex Path Uncollateralized Exposure
  574.      */

  575.     public double[] vertexUncollateralizedExposure()
  576.     {
  577.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  578.         int vertexCount = marketVertexArray.length;
  579.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  580.         double[] vertexUncollateralizedExposure = new double[vertexCount];

  581.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  582.         {
  583.             vertexUncollateralizedExposure[vertexIndex] = 0.;
  584.         }

  585.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  586.             ++creditDebtGroupIndex)
  587.         {
  588.             double[] creditDebtGroupVertexCollateralizedExposure =
  589.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedExposure();

  590.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  591.             {
  592.                 vertexUncollateralizedExposure[vertexIndex] +=
  593.                     creditDebtGroupVertexCollateralizedExposure[vertexIndex];
  594.             }
  595.         }

  596.         return vertexUncollateralizedExposure;
  597.     }

  598.     /**
  599.      * Compute Vertex Path Uncollateralized Exposure PV
  600.      *
  601.      * @return The Vertex Path Uncollateralized Exposure PV
  602.      */

  603.     public double[] vertexUncollateralizedExposurePV()
  604.     {
  605.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  606.         int vertexCount = marketVertexArray.length;
  607.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  608.         double[] vertexUncollateralizedExposurePV = new double[vertexCount];

  609.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  610.         {
  611.             vertexUncollateralizedExposurePV[vertexIndex] = 0.;
  612.         }

  613.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  614.             ++creditDebtGroupIndex)
  615.         {
  616.             double[] creditDebtGroupVertexCollateralizedExposurePV =
  617.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedExposurePV();

  618.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  619.             {
  620.                 vertexUncollateralizedExposurePV[vertexIndex] +=
  621.                     creditDebtGroupVertexCollateralizedExposurePV[vertexIndex];
  622.             }
  623.         }

  624.         return vertexUncollateralizedExposurePV;
  625.     }

  626.     /**
  627.      * Compute Vertex Path Uncollateralized Positive Exposure
  628.      *
  629.      * @return The Vertex Path Uncollateralized Positive Exposure
  630.      */

  631.     public double[] vertexUncollateralizedPositiveExposure()
  632.     {
  633.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  634.         int vertexCount = marketVertexArray.length;
  635.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  636.         double[] vertexUncollateralizedPositiveExposure = new double[vertexCount];

  637.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  638.         {
  639.             vertexUncollateralizedPositiveExposure[vertexIndex] = 0.;
  640.         }

  641.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  642.             ++creditDebtGroupIndex)
  643.         {
  644.             double[] creditDebtGroupVertexUncollateralizedPositiveExposure =
  645.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedPositiveExposure();

  646.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  647.             {
  648.                 vertexUncollateralizedPositiveExposure[vertexIndex] +=
  649.                     creditDebtGroupVertexUncollateralizedPositiveExposure[vertexIndex];
  650.             }
  651.         }

  652.         return vertexUncollateralizedPositiveExposure;
  653.     }

  654.     /**
  655.      * Compute Vertex Path Uncollateralized Positive Exposure PV
  656.      *
  657.      * @return The Vertex Path Uncollateralized Positive Exposure PV
  658.      */

  659.     public double[] vertexUncollateralizedPositiveExposurePV()
  660.     {
  661.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  662.         int vertexCount = marketVertexArray.length;
  663.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  664.         double[] vertexUncollateralizedPositiveExposurePV = new double[vertexCount];

  665.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  666.         {
  667.             vertexUncollateralizedPositiveExposurePV[vertexIndex] = 0.;
  668.         }

  669.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  670.             ++creditDebtGroupIndex)
  671.         {
  672.             double[] creditDebtGroupVertexUncollateralizedPositiveExposurePV =
  673.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedPositiveExposurePV();

  674.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  675.             {
  676.                 vertexUncollateralizedPositiveExposurePV[vertexIndex] +=
  677.                     creditDebtGroupVertexUncollateralizedPositiveExposurePV[vertexIndex];
  678.             }
  679.         }

  680.         return vertexUncollateralizedPositiveExposurePV;
  681.     }

  682.     /**
  683.      * Compute Vertex Path Uncollateralized Negative Exposure
  684.      *
  685.      * @return The Vertex Path Uncollateralized Negative Exposure
  686.      */

  687.     public double[] vertexUncollateralizedNegativeExposure()
  688.     {
  689.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  690.         int vertexCount = marketVertexArray.length;
  691.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  692.         double[] vertexUncollateralizedNegativeExposure = new double[vertexCount];

  693.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  694.         {
  695.             vertexUncollateralizedNegativeExposure[vertexIndex] = 0.;
  696.         }

  697.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  698.             ++creditDebtGroupIndex)
  699.         {
  700.             double[] creditDebtGroupVertexUncollateralizedNegativeExposure =
  701.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedNegativeExposure();

  702.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  703.             {
  704.                 vertexUncollateralizedNegativeExposure[vertexIndex] +=
  705.                     creditDebtGroupVertexUncollateralizedNegativeExposure[vertexIndex];
  706.             }
  707.         }

  708.         return vertexUncollateralizedNegativeExposure;
  709.     }

  710.     /**
  711.      * Compute Vertex Path Uncollateralized Negative Exposure PV
  712.      *
  713.      * @return The Vertex Path Uncollateralized Negative Exposure PV
  714.      */

  715.     public double[] vertexUncollateralizedNegativeExposurePV()
  716.     {
  717.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  718.         int vertexCount = marketVertexArray.length;
  719.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  720.         double[] vertexUncollateralizedNegativeExposurePV = new double[vertexCount];

  721.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  722.         {
  723.             vertexUncollateralizedNegativeExposurePV[vertexIndex] = 0.;
  724.         }

  725.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  726.             ++creditDebtGroupIndex)
  727.         {
  728.             double[] creditDebtGroupVertexUncollateralizedNegativeExposurePV =
  729.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexUncollateralizedNegativeExposurePV();

  730.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  731.             {
  732.                 vertexUncollateralizedNegativeExposurePV[vertexIndex] +=
  733.                     creditDebtGroupVertexUncollateralizedNegativeExposurePV[vertexIndex];
  734.             }
  735.         }

  736.         return vertexUncollateralizedNegativeExposurePV;
  737.     }

  738.     /**
  739.      * Compute Vertex Path Funding Exposure
  740.      *
  741.      * @return The Vertex Path Funding Exposure
  742.      */

  743.     public double[] vertexFundingExposure()
  744.     {
  745.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  746.         int vertexCount = marketVertexArray.length;
  747.         double[] vertexFundingExposure = new double[vertexCount];
  748.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  749.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  750.         {
  751.             vertexFundingExposure[vertexIndex] = 0.;
  752.         }

  753.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  754.             ++creditDebtGroupIndex)
  755.         {
  756.             double[] creditDebtGroupVertexFundingExposure =
  757.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexFundingExposure();

  758.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  759.             {
  760.                 vertexFundingExposure[vertexIndex] += creditDebtGroupVertexFundingExposure[vertexIndex];
  761.             }
  762.         }

  763.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  764.         {
  765.             if (0. > vertexFundingExposure[vertexIndex])
  766.             {
  767.                 vertexFundingExposure[vertexIndex] = 0.;
  768.             }
  769.         }

  770.         return vertexFundingExposure;
  771.     }

  772.     /**
  773.      * Compute Vertex Path Funding Exposure PV
  774.      *
  775.      * @return The Vertex Path Funding Exposure PV
  776.      */

  777.     public double[] vertexFundingExposurePV()
  778.     {
  779.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  780.         int vertexCount = marketVertexArray.length;
  781.         double[] vertexFundingExposurePV = new double[vertexCount];
  782.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  783.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  784.         {
  785.             vertexFundingExposurePV[vertexIndex] = 0.;
  786.         }

  787.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  788.             ++creditDebtGroupIndex)
  789.         {
  790.             double[] creditDebtGroupVertexFundingExposurePV =
  791.                 _creditDebtGroupPathArray[creditDebtGroupIndex].vertexFundingExposurePV();

  792.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  793.             {
  794.                 vertexFundingExposurePV[vertexIndex] += creditDebtGroupVertexFundingExposurePV[vertexIndex];
  795.             }
  796.         }

  797.         for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  798.         {
  799.             if (0. > vertexFundingExposurePV[vertexIndex])
  800.             {
  801.                 vertexFundingExposurePV[vertexIndex] = 0.;
  802.             }
  803.         }

  804.         return vertexFundingExposurePV;
  805.     }

  806.     /**
  807.      * Compute Period-wise Path Symmetric Funding Value Adjustment
  808.      *
  809.      * @return The Period-wise Path Symmetric Funding Value Adjustment
  810.      */

  811.     public double[] periodSymmetricFundingValueAdjustment()
  812.     {
  813.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  814.         double[] periodSymmetricFundingValueSpread01 = periodSymmetricFundingValueSpread01();

  815.         int periodCount = periodSymmetricFundingValueSpread01.length;
  816.         double[] periodSymmetricFundingValueAdjustment = new double[periodCount];

  817.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  818.         {
  819.             periodSymmetricFundingValueAdjustment[periodIndex] =
  820.                 0.5 * periodSymmetricFundingValueSpread01[periodIndex] * (
  821.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  822.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  823.                 );
  824.         }

  825.         return periodSymmetricFundingValueAdjustment;
  826.     }

  827.     /**
  828.      * Compute Period-wise Unilateral Path Funding Value Adjustment
  829.      *
  830.      * @return The Period-wise Unilateral Path Funding Value Adjustment
  831.      */

  832.     public double[] periodUnilateralFundingValueAdjustment()
  833.     {
  834.         double[] periodUnilateralFundingValueSpread01 = periodUnilateralFundingValueSpread01();

  835.         int periodCount = periodUnilateralFundingValueSpread01.length;
  836.         double[] periodUnilateralFundingValueAdjustment = new double[periodCount];

  837.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  838.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  839.         {
  840.             periodUnilateralFundingValueAdjustment[periodIndex] =
  841.                 0.5 * periodUnilateralFundingValueSpread01[periodIndex] * (
  842.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  843.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  844.                 );
  845.         }

  846.         return periodUnilateralFundingValueAdjustment;
  847.     }

  848.     /**
  849.      * Compute Period-wise Bilateral Path Funding Value Adjustment
  850.      *
  851.      * @return The Period-wise Bilateral Path Funding Value Adjustment
  852.      */

  853.     public double[] periodBilateralFundingValueAdjustment()
  854.     {
  855.         double[] periodBilateralFundingValueSpread01 = periodBilateralFundingValueSpread01();

  856.         int periodCount = periodBilateralFundingValueSpread01.length;
  857.         double[] periodBilateralFundingValueAdjustment = new double[periodCount];

  858.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  859.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  860.         {
  861.             periodBilateralFundingValueAdjustment[periodIndex] =
  862.                 0.5 * periodBilateralFundingValueSpread01[periodIndex] * (
  863.                     marketVertexArray[periodIndex].dealer().seniorFundingSpread() +
  864.                     marketVertexArray[periodIndex + 1].dealer().seniorFundingSpread()
  865.                 );
  866.         }

  867.         return periodBilateralFundingValueAdjustment;
  868.     }

  869.     /**
  870.      * Compute Period-wise Path Unilateral Funding Debt Adjustment
  871.      *
  872.      * @return The Period-wise Path Unilateral Funding Debt Adjustment
  873.      */

  874.     public double[] periodUnilateralFundingDebtAdjustment()
  875.     {
  876.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  877.         int periodCount = marketVertexArray.length - 1;
  878.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  879.         double[] periodUnilateralFundingDebtAdjustment = new double[periodCount];

  880.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  881.         {
  882.             periodUnilateralFundingDebtAdjustment[periodIndex] = 0.;
  883.         }

  884.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  885.             ++creditDebtGroupIndex)
  886.         {
  887.             double[] periodUnilateralFundingDebtAdjustmentCreditDebtGroup =
  888.                 _creditDebtGroupPathArray[creditDebtGroupIndex].periodUnilateralFundingDebtAdjustment();

  889.             for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  890.             {
  891.                 periodUnilateralFundingDebtAdjustment[periodIndex] +=
  892.                     periodUnilateralFundingDebtAdjustmentCreditDebtGroup[periodIndex];
  893.             }
  894.         }

  895.         return periodUnilateralFundingDebtAdjustment;
  896.     }

  897.     /**
  898.      * Compute Period-wise Path Bilateral Funding Debt Adjustment
  899.      *
  900.      * @return The Period-wise Path Bilateral Funding Debt Adjustment
  901.      */

  902.     public double[] periodBilateralFundingDebtAdjustment()
  903.     {
  904.         org.drip.exposure.universe.MarketVertex[] marketVertexArray = _marketPath.marketVertexArray();

  905.         int periodCount = marketVertexArray.length - 1;
  906.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;
  907.         double[] periodBilateralFundingDebtAdjustment = new double[periodCount];

  908.         for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  909.         {
  910.             periodBilateralFundingDebtAdjustment[periodIndex] = 0.;
  911.         }

  912.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  913.             ++creditDebtGroupIndex)
  914.         {
  915.             double[] periodBilateralFundingDebtAdjustmentCreditDebtGroup =
  916.                 _creditDebtGroupPathArray[creditDebtGroupIndex].periodBilateralFundingDebtAdjustment();

  917.             for (int periodIndex = 0; periodIndex < periodCount; ++periodIndex)
  918.             {
  919.                 periodBilateralFundingDebtAdjustment[periodIndex] +=
  920.                     periodBilateralFundingDebtAdjustmentCreditDebtGroup[periodIndex];
  921.             }
  922.         }

  923.         return periodBilateralFundingDebtAdjustment;
  924.     }

  925.     /**
  926.      * Compute Path Unilateral Credit Value Adjustment
  927.      *
  928.      * @return The Path Unilateral Credit Value Adjustment
  929.      */

  930.     public double unilateralCreditAdjustment()
  931.     {
  932.         double unilateralCreditAdjustment = 0.;
  933.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  934.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  935.             ++creditDebtGroupIndex)
  936.         {
  937.             unilateralCreditAdjustment +=
  938.                 _creditDebtGroupPathArray[creditDebtGroupIndex].unilateralCreditAdjustment();
  939.         }

  940.         return unilateralCreditAdjustment;
  941.     }

  942.     /**
  943.      * Compute Path Bilateral Credit Value Adjustment
  944.      *
  945.      * @return The Path Bilateral Credit Value Adjustment
  946.      */

  947.     public double bilateralCreditAdjustment()
  948.     {
  949.         double bilateralCreditAdjustment = 0.;
  950.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  951.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  952.             ++creditDebtGroupIndex)
  953.         {
  954.             bilateralCreditAdjustment +=
  955.                 _creditDebtGroupPathArray[creditDebtGroupIndex].bilateralCreditAdjustment();
  956.         }

  957.         return bilateralCreditAdjustment;
  958.     }

  959.     /**
  960.      * Compute Path Contra-Liability Credit Adjustment
  961.      *
  962.      * @return The Path Contra-Liability Credit Adjustment
  963.      */

  964.     public double contraLiabilityCreditAdjustment()
  965.     {
  966.         double contraLiabilityCreditAdjustment = 0.;
  967.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  968.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  969.             ++creditDebtGroupIndex)
  970.         {
  971.             contraLiabilityCreditAdjustment +=
  972.                 _creditDebtGroupPathArray[creditDebtGroupIndex].contraLiabilityCreditAdjustment();
  973.         }

  974.         return contraLiabilityCreditAdjustment;
  975.     }

  976.     /**
  977.      * Compute Path Unilateral Debt Value Adjustment
  978.      *
  979.      * @return The Path Unilateral Debt Value Adjustment
  980.      */

  981.     public double unilateralDebtAdjustment()
  982.     {
  983.         double unilateralDebtAdjustment = 0.;
  984.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  985.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  986.             ++creditDebtGroupIndex)
  987.         {
  988.             unilateralDebtAdjustment +=
  989.                 _creditDebtGroupPathArray[creditDebtGroupIndex].unilateralDebtAdjustment();
  990.         }

  991.         return unilateralDebtAdjustment;
  992.     }

  993.     /**
  994.      * Compute Path Bilateral Debt Value Adjustment
  995.      *
  996.      * @return The Path Bilateral Credit Value Adjustment
  997.      */

  998.     public double bilateralDebtAdjustment()
  999.     {
  1000.         double bilateralDebtAdjustment = 0.;
  1001.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  1002.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  1003.             ++creditDebtGroupIndex)
  1004.         {
  1005.             bilateralDebtAdjustment +=
  1006.                 _creditDebtGroupPathArray[creditDebtGroupIndex].bilateralDebtAdjustment();
  1007.         }

  1008.         return bilateralDebtAdjustment;
  1009.     }

  1010.     /**
  1011.      * Compute Path Contra-Asset Debt Adjustment
  1012.      *
  1013.      * @return The Path Contra-Asset Debt Adjustment
  1014.      */

  1015.     public double contraAssetDebtAdjustment()
  1016.     {
  1017.         double contraAssetDebtAdjustment = 0.;
  1018.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  1019.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  1020.             ++creditDebtGroupIndex)
  1021.         {
  1022.             contraAssetDebtAdjustment +=
  1023.                 _creditDebtGroupPathArray[creditDebtGroupIndex].contraAssetDebtAdjustment();
  1024.         }

  1025.         return contraAssetDebtAdjustment;
  1026.     }

  1027.     /**
  1028.      * Compute Path Unilateral Collateral Value Adjustment
  1029.      *
  1030.      * @return The Path Unilateral Collateral Value Adjustment
  1031.      */

  1032.     public double unilateralCollateralAdjustment()
  1033.     {
  1034.         double unilateralCollateralAdjustment = 0.;
  1035.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  1036.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  1037.             ++creditDebtGroupIndex)
  1038.         {
  1039.             unilateralCollateralAdjustment +=
  1040.                 _creditDebtGroupPathArray[creditDebtGroupIndex].unilateralCollateralAdjustment();
  1041.         }

  1042.         return unilateralCollateralAdjustment;
  1043.     }

  1044.     /**
  1045.      * Compute Path Bilateral Collateral Value Adjustment
  1046.      *
  1047.      * @return The Path Bilateral Collateral Value Adjustment
  1048.      */

  1049.     public double bilateralCollateralAdjustment()
  1050.     {
  1051.         double bilateralCollateralAdjustment = 0.;
  1052.         int creditDebtGroupCount = _creditDebtGroupPathArray.length;

  1053.         for (int creditDebtGroupIndex = 0; creditDebtGroupIndex < creditDebtGroupCount;
  1054.             ++creditDebtGroupIndex)
  1055.         {
  1056.             bilateralCollateralAdjustment +=
  1057.                 _creditDebtGroupPathArray[creditDebtGroupIndex].bilateralCollateralAdjustment();
  1058.         }

  1059.         return bilateralCollateralAdjustment;
  1060.     }

  1061.     /**
  1062.      * Compute Path Funding Value Adjustment
  1063.      *
  1064.      * @return The Path Funding Value Adjustment
  1065.      */

  1066.     public abstract double fundingValueAdjustment();

  1067.     /**
  1068.      * Compute Path Funding Debt Adjustment
  1069.      *
  1070.      * @return The Path Funding Debt Adjustment
  1071.      */

  1072.     public abstract double fundingDebtAdjustment();

  1073.     /**
  1074.      * Compute Path Funding Cost Adjustment
  1075.      *
  1076.      * @return The Path Funding Cost Adjustment
  1077.      */

  1078.     public abstract double fundingCostAdjustment();

  1079.     /**
  1080.      * Compute Path Funding Benefit Adjustment
  1081.      *
  1082.      * @return The Path Funding Benefit Adjustment
  1083.      */

  1084.     public abstract double fundingBenefitAdjustment();

  1085.     /**
  1086.      * Compute Period-wise Path Funding Value Adjustment
  1087.      *
  1088.      * @return The Period-wise Path Funding Value Adjustment
  1089.      */

  1090.     public abstract double[] periodFundingValueAdjustment();

  1091.     /**
  1092.      * Compute Period-wise Path Funding Debt Adjustment
  1093.      *
  1094.      * @return The Period-wise Path Funding Debt Adjustment
  1095.      */

  1096.     public abstract double[] periodFundingDebtAdjustment();

  1097.     /**
  1098.      * Compute Period-wise Path Funding Cost Adjustment
  1099.      *
  1100.      * @return The Period-wise Path Funding Cost Adjustment
  1101.      */

  1102.     public abstract double[] periodFundingCostAdjustment();

  1103.     /**
  1104.      * Compute Period-wise Path Funding Benefit Adjustment
  1105.      *
  1106.      * @return The Period-wise Path Funding Benefit Adjustment
  1107.      */

  1108.     public abstract double[] periodFundingBenefitAdjustment();
  1109. }