MonoPathExposureAdjustment.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>MonoPathExposureAdjustment</i> aggregates the Exposures and the Adjustments across Multiple
  78.  * Netting/Funding Groups on a Single Path Projection Run along the Granularity of a Counter Party Group. The
  79.  * 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/gross/README.md">XVA Gross Adiabat Exposure Aggregation</a></li>
  111.  *  </ul>
  112.  * <br><br>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public class MonoPathExposureAdjustment implements org.drip.xva.gross.PathExposureAdjustment
  117. {
  118.     private org.drip.xva.netting.FundingGroupPath[] _fundingGroupPathArray = null;

  119.     /**
  120.      * MonoPathExposureAdjustment Constructor
  121.      *
  122.      * @param fundingGroupPathArray The Array of Funding Group Paths
  123.      *
  124.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  125.      */

  126.     public MonoPathExposureAdjustment (
  127.         final org.drip.xva.netting.FundingGroupPath[] fundingGroupPathArray)
  128.         throws java.lang.Exception
  129.     {
  130.         if (null == (_fundingGroupPathArray = fundingGroupPathArray))
  131.         {
  132.             throw new java.lang.Exception ("MonoPathExposureAdjustment Constructor => Invalid Inputs");
  133.         }

  134.         int fundingGroupCount = _fundingGroupPathArray.length;

  135.         if (0 == fundingGroupCount)
  136.         {
  137.             throw new java.lang.Exception ("MonoPathExposureAdjustment Constructor => Invalid Inputs");
  138.         }
  139.     }

  140.     /**
  141.      * Retrieve the Array of the Funding Group Trajectory Paths
  142.      *
  143.      * @return The Array of the Funding Group Trajectory Paths
  144.      */

  145.     public org.drip.xva.netting.FundingGroupPath[] fundingGroupTrajectoryPaths()
  146.     {
  147.         return _fundingGroupPathArray;
  148.     }

  149.     /**
  150.      * Retrieve the Array of Credit/Debt Netting Group Trajectory Paths
  151.      *
  152.      * @return The Array of Credit/Debt Netting Group Trajectory Paths
  153.      */

  154.     public org.drip.xva.netting.CreditDebtGroupPath[] creditDebtGroupTrajectoryPaths()
  155.     {
  156.         int creditDebtGroupPathIndex = 0;
  157.         int fundingGroupCount = _fundingGroupPathArray.length;

  158.         java.util.List<org.drip.xva.netting.CreditDebtGroupPath> creditDebtGroupPathList = new
  159.             java.util.ArrayList<org.drip.xva.netting.CreditDebtGroupPath>();

  160.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  161.         {
  162.             org.drip.xva.netting.CreditDebtGroupPath[] creditDebtGroupPathArray =
  163.                 _fundingGroupPathArray[fundingGroupIndex].creditDebtGroupPathArray();

  164.             for (org.drip.xva.netting.CreditDebtGroupPath creditDebtGroupPath : creditDebtGroupPathArray)
  165.             {
  166.                 creditDebtGroupPathList.add (creditDebtGroupPath);
  167.             }
  168.         }

  169.         org.drip.xva.netting.CreditDebtGroupPath[] creditDebtGroupPathArray = new
  170.             org.drip.xva.netting.CreditDebtGroupPath[creditDebtGroupPathList.size()];

  171.         for (org.drip.xva.netting.CreditDebtGroupPath creditDebtGroupPath : creditDebtGroupPathList)
  172.         {
  173.             creditDebtGroupPathArray[creditDebtGroupPathIndex++] = creditDebtGroupPath;
  174.         }

  175.         return creditDebtGroupPathArray;
  176.     }

  177.     @Override public org.drip.analytics.date.JulianDate[] vertexDates()
  178.     {
  179.         return _fundingGroupPathArray[0].vertexDates();
  180.     }

  181.     @Override public double[] vertexCollateralizedExposure()
  182.     {
  183.         int vertexCount = vertexDates().length;

  184.         double[] vertexCollateralizedExposure = new double[vertexCount];

  185.         for (int j = 0; j < vertexCount; ++j)
  186.         {
  187.             vertexCollateralizedExposure[j] = 0.;
  188.         }

  189.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  190.         {
  191.             double[] fundingGroupVertexCollateralizedExposure =
  192.                 fundingGroupPath.vertexCollateralizedExposure();

  193.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  194.             {
  195.                 vertexCollateralizedExposure[vertexIndex] +=
  196.                     fundingGroupVertexCollateralizedExposure[vertexIndex];
  197.             }
  198.         }

  199.         return vertexCollateralizedExposure;
  200.     }

  201.     @Override public double[] vertexCollateralizedExposurePV()
  202.     {
  203.         int vertexCount = vertexDates().length;

  204.         double[] vertexCollateralizedExposurePV = new double[vertexCount];

  205.         for (int j = 0; j < vertexCount; ++j)
  206.         {
  207.             vertexCollateralizedExposurePV[j] = 0.;
  208.         }

  209.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  210.         {
  211.             double[] fundingGroupVertexCollateralizedExposurePV =
  212.                 fundingGroupPath.vertexCollateralizedExposurePV();

  213.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  214.             {
  215.                 vertexCollateralizedExposurePV[vertexIndex] +=
  216.                     fundingGroupVertexCollateralizedExposurePV[vertexIndex];
  217.             }
  218.         }

  219.         return vertexCollateralizedExposurePV;
  220.     }

  221.     @Override public double[] vertexCollateralizedPositiveExposure()
  222.     {
  223.         int vertexCount = vertexDates().length;

  224.         double[] vertexCollateralizedPositiveExposure = new double[vertexCount];

  225.         for (int j = 0; j < vertexCount; ++j)
  226.         {
  227.             vertexCollateralizedPositiveExposure[j] = 0.;
  228.         }

  229.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  230.         {
  231.             double[] fundingGroupVertexCollateralizedPositiveExposure =
  232.                 fundingGroupPath.vertexCollateralizedPositiveExposure();

  233.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  234.             {
  235.                 vertexCollateralizedPositiveExposure[vertexIndex] +=
  236.                     fundingGroupVertexCollateralizedPositiveExposure[vertexIndex];
  237.             }
  238.         }

  239.         return vertexCollateralizedPositiveExposure;
  240.     }

  241.     @Override public double[] vertexCollateralizedPositiveExposurePV()
  242.     {
  243.         int vertexCount = vertexDates().length;

  244.         double[] vertexCollateralizedPositiveExposurePV = new double[vertexCount];

  245.         for (int j = 0; j < vertexCount; ++j)
  246.         {
  247.             vertexCollateralizedPositiveExposurePV[j] = 0.;
  248.         }

  249.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  250.         {
  251.             double[] fundingGroupVertexCollateralizedPositiveExposurePV =
  252.                 fundingGroupPath.vertexCollateralizedPositiveExposurePV();

  253.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  254.             {
  255.                 vertexCollateralizedPositiveExposurePV[vertexIndex] +=
  256.                     fundingGroupVertexCollateralizedPositiveExposurePV[vertexIndex];
  257.             }
  258.         }

  259.         return vertexCollateralizedPositiveExposurePV;
  260.     }

  261.     @Override public double[] vertexCollateralizedNegativeExposure()
  262.     {
  263.         int vertexCount = vertexDates().length;

  264.         double[] vertexCollateralizedNegativeExposure = new double[vertexCount];

  265.         for (int j = 0; j < vertexCount; ++j)
  266.         {
  267.             vertexCollateralizedNegativeExposure[j] = 0.;
  268.         }

  269.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  270.         {
  271.             double[] fundingGroupVertexCollateralizedNegativeExposure =
  272.                 fundingGroupPath.vertexCollateralizedNegativeExposure();

  273.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  274.             {
  275.                 vertexCollateralizedNegativeExposure[vertexIndex] +=
  276.                     fundingGroupVertexCollateralizedNegativeExposure[vertexIndex];
  277.             }
  278.         }

  279.         return vertexCollateralizedNegativeExposure;
  280.     }

  281.     @Override public double[] vertexCollateralizedNegativeExposurePV()
  282.     {
  283.         int vertexCount = vertexDates().length;

  284.         double[] vertexCollateralizedNegativeExposurePV = new double[vertexCount];

  285.         for (int j = 0; j < vertexCount; ++j)
  286.         {
  287.             vertexCollateralizedNegativeExposurePV[j] = 0.;
  288.         }

  289.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  290.         {
  291.             double[] fundingGroupVertexCollateralizedNegativeExposurePV =
  292.                 fundingGroupPath.vertexCollateralizedNegativeExposurePV();

  293.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  294.             {
  295.                 vertexCollateralizedNegativeExposurePV[vertexIndex] +=
  296.                     fundingGroupVertexCollateralizedNegativeExposurePV[vertexIndex];
  297.             }
  298.         }

  299.         return vertexCollateralizedNegativeExposurePV;
  300.     }

  301.     @Override public double[] vertexUncollateralizedExposure()
  302.     {
  303.         int vertexCount = vertexDates().length;

  304.         double[] vertexUncollateralizedExposure = new double[vertexCount];

  305.         for (int j = 0; j < vertexCount; ++j)
  306.         {
  307.             vertexUncollateralizedExposure[j] = 0.;
  308.         }

  309.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  310.         {
  311.             double[] fundingGroupVertexUncollateralizedExposure =
  312.                 fundingGroupPath.vertexUncollateralizedExposure();

  313.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  314.             {
  315.                 vertexUncollateralizedExposure[vertexIndex] +=
  316.                     fundingGroupVertexUncollateralizedExposure[vertexIndex];
  317.             }
  318.         }

  319.         return vertexUncollateralizedExposure;
  320.     }

  321.     @Override public double[] vertexUncollateralizedExposurePV()
  322.     {
  323.         int vertexCount = vertexDates().length;

  324.         double[] vertexUncollateralizedExposurePV = new double[vertexCount];

  325.         for (int j = 0; j < vertexCount; ++j)
  326.         {
  327.             vertexUncollateralizedExposurePV[j] = 0.;
  328.         }

  329.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  330.         {
  331.             double[] fundingGroupVertexUncollateralizedExposurePV =
  332.                 fundingGroupPath.vertexUncollateralizedExposurePV();

  333.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  334.             {
  335.                 vertexUncollateralizedExposurePV[vertexIndex] +=
  336.                     fundingGroupVertexUncollateralizedExposurePV[vertexIndex];
  337.             }
  338.         }

  339.         return vertexUncollateralizedExposurePV;
  340.     }

  341.     @Override public double[] vertexUncollateralizedPositiveExposure()
  342.     {
  343.         int vertexCount = vertexDates().length;

  344.         double[] vertexUncollateralizedPositiveExposure = new double[vertexCount];

  345.         for (int j = 0; j < vertexCount; ++j)
  346.         {
  347.             vertexUncollateralizedPositiveExposure[j] = 0.;
  348.         }

  349.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  350.         {
  351.             double[] fundingGroupVertexUncollateralizedPositiveExposure =
  352.                 fundingGroupPath.vertexUncollateralizedPositiveExposure();

  353.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  354.             {
  355.                 vertexUncollateralizedPositiveExposure[vertexIndex] +=
  356.                     fundingGroupVertexUncollateralizedPositiveExposure[vertexIndex];
  357.             }
  358.         }

  359.         return vertexUncollateralizedPositiveExposure;
  360.     }

  361.     @Override public double[] vertexUncollateralizedPositiveExposurePV()
  362.     {
  363.         int vertexCount = vertexDates().length;

  364.         double[] vertexUncollateralizedPositiveExposurePV = new double[vertexCount];

  365.         for (int j = 0; j < vertexCount; ++j)
  366.         {
  367.             vertexUncollateralizedPositiveExposurePV[j] = 0.;
  368.         }

  369.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  370.         {
  371.             double[] fundingGroupVertexUncollateralizedPositiveExposurePV =
  372.                 fundingGroupPath.vertexUncollateralizedPositiveExposurePV();

  373.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  374.             {
  375.                 vertexUncollateralizedPositiveExposurePV[vertexIndex] +=
  376.                     fundingGroupVertexUncollateralizedPositiveExposurePV[vertexIndex];
  377.             }
  378.         }

  379.         return vertexUncollateralizedPositiveExposurePV;
  380.     }

  381.     @Override public double[] vertexUncollateralizedNegativeExposure()
  382.     {
  383.         int vertexCount = vertexDates().length;

  384.         double[] vertexUncollateralizedNegativeExposure = new double[vertexCount];

  385.         for (int j = 0; j < vertexCount; ++j)
  386.         {
  387.             vertexUncollateralizedNegativeExposure[j] = 0.;
  388.         }

  389.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  390.         {
  391.             double[] fundingGroupVertexUncollateralizedNegativeExposure =
  392.                 fundingGroupPath.vertexUncollateralizedNegativeExposure();

  393.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  394.             {
  395.                 vertexUncollateralizedNegativeExposure[vertexIndex] +=
  396.                     fundingGroupVertexUncollateralizedNegativeExposure[vertexIndex];
  397.             }
  398.         }

  399.         return vertexUncollateralizedNegativeExposure;
  400.     }

  401.     @Override public double[] vertexUncollateralizedNegativeExposurePV()
  402.     {
  403.         int vertexCount = vertexDates().length;

  404.         double[] vertexUncollateralizedNegativeExposurePV = new double[vertexCount];

  405.         for (int j = 0; j < vertexCount; ++j)
  406.         {
  407.             vertexUncollateralizedNegativeExposurePV[j] = 0.;
  408.         }

  409.         for (org.drip.xva.netting.FundingGroupPath fundingGroupPath : _fundingGroupPathArray)
  410.         {
  411.             double[] fundingGroupVertexUncollateralizedNegativeExposurePV =
  412.                 fundingGroupPath.vertexUncollateralizedNegativeExposurePV();

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

  419.         return vertexUncollateralizedNegativeExposurePV;
  420.     }

  421.     @Override public double[] vertexFundingExposure()
  422.     {
  423.         int vertexCount = vertexDates().length;

  424.         int fundingGroupCount = _fundingGroupPathArray.length;
  425.         double[] vertexFundingExposure = new double[vertexCount];

  426.         for (int j = 0; j < vertexCount; ++j)
  427.         {
  428.             vertexFundingExposure[j] = 0.;
  429.         }

  430.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  431.         {
  432.             double[] fundingGroupVertexExposure =
  433.                 _fundingGroupPathArray[fundingGroupIndex].vertexFundingExposure();

  434.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  435.             {
  436.                 vertexFundingExposure[vertexIndex] += fundingGroupVertexExposure[vertexIndex];
  437.             }
  438.         }

  439.         return vertexFundingExposure;
  440.     }

  441.     @Override public double[] vertexFundingExposurePV()
  442.     {
  443.         int vertexCount = vertexDates().length;

  444.         int fundingGroupCount = _fundingGroupPathArray.length;
  445.         double[] vertexFundingExposurePV = new double[vertexCount];

  446.         for (int j = 0; j < vertexCount; ++j)
  447.         {
  448.             vertexFundingExposurePV[j] = 0.;
  449.         }

  450.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  451.         {
  452.             double[] fundingGroupVertexExposurePV =
  453.                 _fundingGroupPathArray[fundingGroupIndex].vertexFundingExposurePV();

  454.             for (int vertexIndex = 0; vertexIndex < vertexCount; ++vertexIndex)
  455.             {
  456.                 vertexFundingExposurePV[vertexIndex] += fundingGroupVertexExposurePV[vertexIndex];
  457.             }
  458.         }

  459.         return vertexFundingExposurePV;
  460.     }

  461.     @Override public double unilateralCreditAdjustment()
  462.     {
  463.         double unilateralCreditAdjustment = 0.;
  464.         int fundingGroupCount = _fundingGroupPathArray.length;

  465.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  466.         {
  467.             unilateralCreditAdjustment +=
  468.                 _fundingGroupPathArray[fundingGroupIndex].unilateralCreditAdjustment();
  469.         }

  470.         return unilateralCreditAdjustment;
  471.     }

  472.     @Override public double bilateralCreditAdjustment()
  473.     {
  474.         double bilateralCreditAdjustment = 0.;
  475.         int fundingGroupCount = _fundingGroupPathArray.length;

  476.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  477.         {
  478.             bilateralCreditAdjustment +=
  479.                 _fundingGroupPathArray[fundingGroupIndex].bilateralCreditAdjustment();
  480.         }

  481.         return bilateralCreditAdjustment;
  482.     }

  483.     @Override public double creditAdjustment()
  484.     {
  485.         return unilateralCreditAdjustment();
  486.     }

  487.     @Override public double contraLiabilityCreditAdjustment()
  488.     {
  489.         double contraLiabilityCreditAdjustment = 0.;
  490.         int fundingGroupCount = _fundingGroupPathArray.length;

  491.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  492.         {
  493.             contraLiabilityCreditAdjustment +=
  494.                 _fundingGroupPathArray[fundingGroupIndex].contraLiabilityCreditAdjustment();
  495.         }

  496.         return contraLiabilityCreditAdjustment;
  497.     }

  498.     @Override public double unilateralDebtAdjustment()
  499.     {
  500.         double unilateralDebtAdjustment = 0.;
  501.         int fundingGroupCount = _fundingGroupPathArray.length;

  502.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  503.         {
  504.             unilateralDebtAdjustment += _fundingGroupPathArray[fundingGroupIndex].unilateralDebtAdjustment();
  505.         }

  506.         return unilateralDebtAdjustment;
  507.     }

  508.     @Override public double bilateralDebtAdjustment()
  509.     {
  510.         double bilateralDebtAdjustment = 0.;
  511.         int fundingGroupCount = _fundingGroupPathArray.length;

  512.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  513.         {
  514.             bilateralDebtAdjustment += _fundingGroupPathArray[fundingGroupIndex].bilateralDebtAdjustment();
  515.         }

  516.         return bilateralDebtAdjustment;
  517.     }

  518.     @Override public double debtAdjustment()
  519.     {
  520.         return unilateralDebtAdjustment();
  521.     }

  522.     @Override public double contraAssetDebtAdjustment()
  523.     {
  524.         double contraAssetDebtAdjustment = 0.;
  525.         int fundingGroupCount = _fundingGroupPathArray.length;

  526.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  527.         {
  528.             contraAssetDebtAdjustment +=
  529.                 _fundingGroupPathArray[fundingGroupIndex].contraAssetDebtAdjustment();
  530.         }

  531.         return contraAssetDebtAdjustment;
  532.     }

  533.     @Override public double unilateralCollateralAdjustment()
  534.     {
  535.         double unilateralCollateralAdjustment = 0.;
  536.         int fundingGroupCount = _fundingGroupPathArray.length;

  537.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  538.         {
  539.             unilateralCollateralAdjustment +=
  540.                 _fundingGroupPathArray[fundingGroupIndex].unilateralCollateralAdjustment();
  541.         }

  542.         return unilateralCollateralAdjustment;
  543.     }

  544.     @Override public double bilateralCollateralAdjustment()
  545.     {
  546.         double bilateralCollateralAdjustment = 0.;
  547.         int fundingGroupCount = _fundingGroupPathArray.length;

  548.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  549.         {
  550.             bilateralCollateralAdjustment +=
  551.                 _fundingGroupPathArray[fundingGroupIndex].bilateralCollateralAdjustment();
  552.         }

  553.         return bilateralCollateralAdjustment;
  554.     }

  555.     @Override public double collateralAdjustment()
  556.     {
  557.         return bilateralCollateralAdjustment();
  558.     }

  559.     @Override public double unilateralFundingValueAdjustment()
  560.     {
  561.         double unilateralFundingValueAdjustment = 0.;
  562.         int fundingGroupCount = _fundingGroupPathArray.length;

  563.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  564.         {
  565.             unilateralFundingValueAdjustment +=
  566.                 _fundingGroupPathArray[fundingGroupIndex].unilateralFundingValueAdjustment();
  567.         }

  568.         return unilateralFundingValueAdjustment;
  569.     }

  570.     @Override public double bilateralFundingValueAdjustment()
  571.     {
  572.         double bilateralFundingValueAdjustment = 0.;
  573.         int fundingGroupCount = _fundingGroupPathArray.length;

  574.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  575.         {
  576.             bilateralFundingValueAdjustment +=
  577.                 _fundingGroupPathArray[fundingGroupIndex].bilateralFundingValueAdjustment();
  578.         }

  579.         return bilateralFundingValueAdjustment;
  580.     }

  581.     @Override public double fundingValueAdjustment()
  582.     {
  583.         double fundingValueAdjustment = 0.;
  584.         int fundingGroupCount = _fundingGroupPathArray.length;

  585.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  586.         {
  587.             fundingValueAdjustment += _fundingGroupPathArray[fundingGroupIndex].fundingValueAdjustment();
  588.         }

  589.         return fundingValueAdjustment;
  590.     }

  591.     @Override public double fundingDebtAdjustment()
  592.     {
  593.         double fundingDebtAdjustment = 0.;
  594.         int fundingGroupCount = _fundingGroupPathArray.length;

  595.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  596.         {
  597.             fundingDebtAdjustment += _fundingGroupPathArray[fundingGroupIndex].fundingDebtAdjustment();
  598.         }

  599.         return fundingDebtAdjustment;
  600.     }

  601.     @Override public double fundingCostAdjustment()
  602.     {
  603.         double fundingCostAdjustment = 0.;
  604.         int fundingGroupCount = _fundingGroupPathArray.length;

  605.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  606.         {
  607.             fundingCostAdjustment += _fundingGroupPathArray[fundingGroupIndex].fundingCostAdjustment();
  608.         }

  609.         return fundingCostAdjustment;
  610.     }

  611.     @Override public double fundingBenefitAdjustment()
  612.     {
  613.         double fundingBenefitAdjustment = 0.;
  614.         int fundingGroupCount = _fundingGroupPathArray.length;

  615.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  616.         {
  617.             fundingBenefitAdjustment += _fundingGroupPathArray[fundingGroupIndex].fundingBenefitAdjustment();
  618.         }

  619.         return fundingBenefitAdjustment;
  620.     }

  621.     @Override public double symmetricFundingValueAdjustment()
  622.     {
  623.         double symmetricFundingValueAdjustment = 0.;
  624.         int fundingGroupCount = _fundingGroupPathArray.length;

  625.         for (int fundingGroupIndex = 0; fundingGroupIndex < fundingGroupCount; ++fundingGroupIndex)
  626.         {
  627.             symmetricFundingValueAdjustment +=
  628.                 _fundingGroupPathArray[fundingGroupIndex].symmetricFundingValueAdjustment();
  629.         }

  630.         return symmetricFundingValueAdjustment;
  631.     }

  632.     @Override public double totalAdjustment()
  633.     {
  634.         return collateralAdjustment() + creditAdjustment() + debtAdjustment() + fundingValueAdjustment();
  635.     }
  636. }