PortfolioGroupRun.java

  1. package org.drip.sample.netting;

  2. import org.drip.analytics.date.*;
  3. import org.drip.exposure.evolver.LatentStateVertexContainer;
  4. import org.drip.exposure.universe.*;
  5. import org.drip.measure.discrete.SequenceGenerator;
  6. import org.drip.measure.dynamics.DiffusionEvaluatorLogarithmic;
  7. import org.drip.measure.process.DiffusionEvolver;
  8. import org.drip.measure.realization.*;
  9. import org.drip.numerical.common.FormatUtil;
  10. import org.drip.service.env.EnvManager;
  11. import org.drip.state.identifier.OTCFixFloatLabel;
  12. import org.drip.xva.gross.*;
  13. import org.drip.xva.hypothecation.*;
  14. import org.drip.xva.netting.CollateralGroupPath;
  15. import org.drip.xva.strategy.*;
  16. import org.drip.xva.vertex.AlbaneseAndersen;

  17. /*
  18.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  19.  */

  20. /*!
  21.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  22.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  23.  *
  24.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  25.  *      libraries targeting analysts and developers
  26.  *      https://lakshmidrip.github.io/DRIP/
  27.  *  
  28.  *  DRIP is composed of four main libraries:
  29.  *  
  30.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  31.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  32.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  33.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  34.  *
  35.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  36.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  37.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  38.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  39.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  40.  *
  41.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  42.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  43.  *
  44.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  45.  *
  46.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  47.  *
  48.  *  Licensed under the Apache License, Version 2.0 (the "License");
  49.  *      you may not use this file except in compliance with the License.
  50.  *  
  51.  *  You may obtain a copy of the License at
  52.  *      http://www.apache.org/licenses/LICENSE-2.0
  53.  *  
  54.  *  Unless required by applicable law or agreed to in writing, software
  55.  *      distributed under the License is distributed on an "AS IS" BASIS,
  56.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  57.  *  
  58.  *  See the License for the specific language governing permissions and
  59.  *      limitations under the License.
  60.  */

  61. /**
  62.  * PortfolioGroupRun demonstrates the Simulation Run of the Netting Group Exposure. The References are:
  63.  *  
  64.  *  - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk
  65.  *      and Funding Costs, Journal of Credit Risk, 7 (3) 1-19.
  66.  *  
  67.  *  - Burgard, C., and M. Kjaer (2014): In the Balance, Risk, 24 (11) 72-75.
  68.  *  
  69.  *  - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90.
  70.  *  
  71.  *  - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the
  72.  *      Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing,
  73.  *      Singapore.
  74.  *
  75.  *  - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk
  76.  *      21 (2) 97-102.
  77.  *
  78.  * @author Lakshmi Krishnamurthy
  79.  */

  80. public class PortfolioGroupRun {

  81.     private static final double[] AssetValueRealization (
  82.         final DiffusionEvolver deAssetValue,
  83.         final double dblAssetValueInitial,
  84.         final double dblTime,
  85.         final double dblTimeWidth,
  86.         final int iNumStep)
  87.         throws Exception
  88.     {
  89.         double[] ablAssetValue = new double[iNumStep + 1];
  90.         double[] adblTimeWidth = new double[iNumStep];
  91.         ablAssetValue[0] = dblAssetValueInitial;

  92.         for (int i = 0; i < iNumStep; ++i)
  93.             adblTimeWidth[i] = dblTimeWidth;

  94.         JumpDiffusionEdge[] aJDE = deAssetValue.incrementSequence (
  95.             new JumpDiffusionVertex (
  96.                 dblTime,
  97.                 dblAssetValueInitial,
  98.                 0.,
  99.                 false
  100.             ),
  101.             JumpDiffusionEdgeUnit.Diffusion (
  102.                 adblTimeWidth,
  103.                 SequenceGenerator.Gaussian (iNumStep)
  104.             ),
  105.             dblTimeWidth
  106.         );

  107.         for (int j = 1; j <= iNumStep; ++j)
  108.             ablAssetValue[j] = aJDE[j - 1].finish();

  109.         return ablAssetValue;
  110.     }

  111.     public static final void main (
  112.         final String[] astrArgs)
  113.         throws Exception
  114.     {
  115.         EnvManager.InitEnv ("");

  116.         int iNumStep = 10;
  117.         double dblTime = 5.;
  118.         double dblAssetDrift = 0.06;
  119.         double dblAssetVolatility = 0.15;
  120.         double dblAssetValueInitial = 1.;
  121.         double dblOISRate = 0.004;
  122.         double dblCSADrift = 0.01;
  123.         double dblBankHazardRate = 0.015;
  124.         double dblBankRecoveryRate = 0.40;
  125.         double dblCounterPartyHazardRate = 0.030;
  126.         double dblCounterPartyRecoveryRate = 0.30;

  127.         double dblTimeWidth = dblTime / iNumStep;
  128.         MarketVertex[] aMV = new MarketVertex[iNumStep + 1];
  129.         JulianDate[] adtVertex = new JulianDate[iNumStep + 1];
  130.         double dblBankFundingSpread = dblBankHazardRate / (1. - dblBankRecoveryRate);
  131.         double dblCounterPartyFundingSpread = dblCounterPartyHazardRate / (1. - dblCounterPartyRecoveryRate);
  132.         CollateralGroupVertex[] aCGV1 = new CollateralGroupVertex[iNumStep + 1];
  133.         CollateralGroupVertex[] aCGV2 = new CollateralGroupVertex[iNumStep + 1];

  134.         JulianDate dtSpot = DateUtil.Today();

  135.         DiffusionEvolver deAssetValue = new DiffusionEvolver (
  136.             DiffusionEvaluatorLogarithmic.Standard (
  137.                 dblAssetDrift,
  138.                 dblAssetVolatility
  139.             )
  140.         );

  141.         double[] adblAssetValuePath1 = AssetValueRealization (
  142.             deAssetValue,
  143.             dblAssetValueInitial,
  144.             dblTime,
  145.             dblTimeWidth,
  146.             iNumStep
  147.         );

  148.         double[] adblAssetValuePath2 = AssetValueRealization (
  149.             deAssetValue,
  150.             dblAssetValueInitial,
  151.             dblTime,
  152.             dblTimeWidth,
  153.             iNumStep
  154.         );

  155.         System.out.println();

  156.         System.out.println ("\t|--------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  157.         System.out.println ("\t|                                                       PATH VERTEX EXPOSURES AND NUMERAIRE REALIZATIONS                                                       ||");

  158.         System.out.println ("\t|--------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  159.         System.out.println ("\t|    L -> R:                                                                                                                                                   ||");

  160.         System.out.println ("\t|            - Path #1 Gross Exposure                                                                                                                          ||");

  161.         System.out.println ("\t|            - Path #1 Positive Exposure                                                                                                                       ||");

  162.         System.out.println ("\t|            - Path #1 Negative Exposure                                                                                                                       ||");

  163.         System.out.println ("\t|            - Path #2 Gross Exposure                                                                                                                          ||");

  164.         System.out.println ("\t|            - Path #2 Positive Exposure                                                                                                                       ||");

  165.         System.out.println ("\t|            - Path #2 Negative Exposure                                                                                                                       ||");

  166.         System.out.println ("\t|            - Collateral Numeraire                                                                                                                            ||");

  167.         System.out.println ("\t|            - Bank Survival Probability                                                                                                                       ||");

  168.         System.out.println ("\t|            - Bank Recovery Rate                                                                                                                              ||");

  169.         System.out.println ("\t|            - Bank Funding Spread                                                                                                                             ||");

  170.         System.out.println ("\t|            - Counter Party Survival Probability                                                                                                              ||");

  171.         System.out.println ("\t|            - Counter Party Recovery Rate                                                                                                                     ||");

  172.         System.out.println ("\t|--------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  173.         for (int i = 0; i <= iNumStep; ++i)
  174.         {
  175.             LatentStateVertexContainer latentStateVertexContainer = new LatentStateVertexContainer();

  176.             latentStateVertexContainer.add (
  177.                 OTCFixFloatLabel.Standard ("USD-3M-10Y"),
  178.                 Double.NaN
  179.             );

  180.             aMV[i] = MarketVertex.Nodal (
  181.                 adtVertex[i] = dtSpot.addMonths (6 * i),
  182.                 0.,
  183.                 Math.exp (-0.5 * dblOISRate * (iNumStep - i)),
  184.                 dblCSADrift,
  185.                 Math.exp (-0.5 * dblCSADrift * (iNumStep - i)),
  186.                 new MarketVertexEntity (
  187.                     Math.exp (-0.5 * dblBankHazardRate * i),
  188.                     dblBankHazardRate,
  189.                     dblBankRecoveryRate,
  190.                     dblBankFundingSpread,
  191.                     Math.exp (-0.5 * dblBankHazardRate * (1. - dblBankRecoveryRate) * (iNumStep - i)),
  192.                     Double.NaN,
  193.                     Double.NaN,
  194.                     Double.NaN
  195.                 ),
  196.                 new MarketVertexEntity (
  197.                     Math.exp (-0.5 * dblCounterPartyHazardRate * i),
  198.                     dblCounterPartyHazardRate,
  199.                     dblCounterPartyRecoveryRate,
  200.                     dblCounterPartyFundingSpread,
  201.                     Math.exp (-0.5 * dblCounterPartyHazardRate * (1. - dblCounterPartyRecoveryRate) * (iNumStep - i)),
  202.                     Double.NaN,
  203.                     Double.NaN,
  204.                     Double.NaN
  205.                 ),
  206.                 latentStateVertexContainer
  207.             );

  208.             aCGV1[i] = new AlbaneseAndersen (
  209.                 adtVertex[i],
  210.                 adblAssetValuePath1[i],
  211.                 0.,
  212.                 0.
  213.             );

  214.             aCGV2[i] = new AlbaneseAndersen (
  215.                 adtVertex[i],
  216.                 adblAssetValuePath2[i],
  217.                 0.,
  218.                 0.
  219.             );

  220.             System.out.println (
  221.                 "\t| " + adtVertex[i] + " => " +
  222.                 FormatUtil.FormatDouble (aCGV1[i].collateralized(), 1, 6, 1.) + " | " +
  223.                 FormatUtil.FormatDouble (aCGV1[i].uncollateralized(), 1, 6, 1.) + " | " +
  224.                 FormatUtil.FormatDouble (aCGV1[i].variationMarginPosting(), 1, 6, 1.) + " | " +
  225.                 FormatUtil.FormatDouble (aCGV2[i].collateralized(), 1, 6, 1.) + " | " +
  226.                 FormatUtil.FormatDouble (aCGV2[i].uncollateralized(), 1, 6, 1.) + " | " +
  227.                 FormatUtil.FormatDouble (aCGV2[i].variationMarginPosting(), 1, 6, 1.) + " | " +
  228.                 FormatUtil.FormatDouble (aMV[i].overnightRate(), 1, 6, 1.) + " | " +
  229.                 FormatUtil.FormatDouble (aMV[i].dealer().survivalProbability(), 1, 6, 1.) + " | " +
  230.                 FormatUtil.FormatDouble (aMV[i].dealer().seniorRecoveryRate(), 1, 6, 1.) + " | " +
  231.                 FormatUtil.FormatDouble (aMV[i].dealer().seniorFundingSpread(), 1, 6, 1.) + " | " +
  232.                 FormatUtil.FormatDouble (aMV[i].client().survivalProbability(), 1, 6, 1.) + " | " +
  233.                 FormatUtil.FormatDouble (aMV[i].client().seniorRecoveryRate(), 1, 6, 1.) + " ||"
  234.             );

  235.             System.out.println (i + " | " + aMV[i].overnightReplicator());
  236.         }

  237.         MarketPath mp = MarketPath.FromMarketVertexArray (aMV);

  238.         CollateralGroupPath[] aCGP1 = new CollateralGroupPath[] {
  239.             new CollateralGroupPath (
  240.                 aCGV1,
  241.                 mp
  242.             )
  243.         };

  244.         CollateralGroupPath[] aCGP2 = new CollateralGroupPath[] {
  245.             new CollateralGroupPath (
  246.                 aCGV2,
  247.                 mp
  248.             )
  249.         };

  250.         AlbaneseAndersenNettingGroupPath ngpaa2014_1 = new AlbaneseAndersenNettingGroupPath (
  251.             aCGP1,
  252.             mp
  253.         );

  254.         AlbaneseAndersenFundingGroupPath fgpaa2014_1 = AlbaneseAndersenFundingGroupPath.Mono (
  255.             ngpaa2014_1,
  256.             mp
  257.         );

  258.         AlbaneseAndersenNettingGroupPath ngpaa2014_2 = new AlbaneseAndersenNettingGroupPath (
  259.             aCGP2,
  260.             mp
  261.         );

  262.         AlbaneseAndersenFundingGroupPath fgpaa2014_2 = AlbaneseAndersenFundingGroupPath.Mono (
  263.             ngpaa2014_2,
  264.             mp
  265.         );

  266.         double[] adblPeriodUnilateralCreditAdjustment1 = ngpaa2014_1.periodUnilateralCreditAdjustment();

  267.         double[] adblPeriodBilateralCreditAdjustment1 = ngpaa2014_1.periodBilateralCreditAdjustment();

  268.         double[] adblPeriodCreditAdjustment1 = ngpaa2014_1.periodCreditAdjustment();

  269.         double[] adblPeriodContraLiabilityCreditAdjustment1 = ngpaa2014_1.periodContraLiabilityCreditAdjustment();

  270.         double[] adblPeriodUnilateralCreditAdjustment2 = ngpaa2014_2.periodUnilateralCreditAdjustment();

  271.         double[] adblPeriodBilateralCreditAdjustment2 = ngpaa2014_2.periodBilateralCreditAdjustment();

  272.         double[] adblPeriodCreditAdjustment2 = ngpaa2014_2.periodCreditAdjustment();

  273.         double[] adblPeriodContraLiabilityCreditAdjustment2 = ngpaa2014_2.periodContraLiabilityCreditAdjustment();

  274.         System.out.println ("\t|--------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  275.         System.out.println();

  276.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------||");

  277.         System.out.println ("\t|               PERIOD UNILATERAL CREDIT, BILATERAL CREDIT, CREDIT, & CONTRA LIABILITY CREDIT VALUATION ADJUSTMENTS               ||");

  278.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------||");

  279.         System.out.println ("\t|    - Forward Period                                                                                                             ||");

  280.         System.out.println ("\t|    - Path #1 Period Unilateral Credit Adjustments                                                                               ||");

  281.         System.out.println ("\t|    - Path #1 Period Bilateral Credit Adjustments                                                                                ||");

  282.         System.out.println ("\t|    - Path #1 Period Credit Adjustments                                                                                          ||");

  283.         System.out.println ("\t|    - Path #1 Period Contra-Liability Credit Adjustments                                                                         ||");

  284.         System.out.println ("\t|    - Path #2 Period Unilateral Credit Adjustments                                                                               ||");

  285.         System.out.println ("\t|    - Path #2 Period Bilateral Credit Adjustments                                                                                ||");

  286.         System.out.println ("\t|    - Path #2 Period Credit Adjustments                                                                                          ||");

  287.         System.out.println ("\t|    - Path #2 Period Contra-Liability Credit Adjustments                                                                         ||");

  288.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------||");

  289.         for (int i = 1; i <= iNumStep; ++i) {
  290.             System.out.println ("\t| [" +
  291.                 adtVertex[i - 1] + " -> " + adtVertex[i] + "] => " +
  292.                 FormatUtil.FormatDouble (adblPeriodUnilateralCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  293.                 FormatUtil.FormatDouble (adblPeriodBilateralCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  294.                 FormatUtil.FormatDouble (adblPeriodCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  295.                 FormatUtil.FormatDouble (adblPeriodContraLiabilityCreditAdjustment1[i - 1], 1, 6, 1.) + " ||| " +
  296.                 FormatUtil.FormatDouble (adblPeriodUnilateralCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  297.                 FormatUtil.FormatDouble (adblPeriodBilateralCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  298.                 FormatUtil.FormatDouble (adblPeriodCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  299.                 FormatUtil.FormatDouble (adblPeriodContraLiabilityCreditAdjustment2[i - 1], 1, 6, 1.) + " ||"
  300.             );
  301.         }

  302.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------||");

  303.         System.out.println();

  304.         double[] adblPeriodDebtAdjustment1 = ngpaa2014_1.periodDebtAdjustment();

  305.         double[] adblPeriodFundingValueAdjustment1 = fgpaa2014_1.periodFundingValueAdjustment();

  306.         double[] adblPeriodFundingDebtAdjustment1 = fgpaa2014_1.periodFundingDebtAdjustment();

  307.         double[] adblPeriodFundingCostAdjustment1 = fgpaa2014_1.periodFundingCostAdjustment();

  308.         double[] adblPeriodFundingBenefitAdjustment1 = fgpaa2014_1.periodFundingBenefitAdjustment();

  309.         double[] adblPeriodSymmetricFundingValueAdjustment1 = fgpaa2014_1.periodSymmetricFundingValueAdjustment();

  310.         double[] adblPeriodDebtAdjustment2 = ngpaa2014_2.periodDebtAdjustment();

  311.         double[] adblPeriodFundingValueAdjustment2 = fgpaa2014_2.periodFundingValueAdjustment();

  312.         double[] adblPeriodFundingDebtAdjustment2 = fgpaa2014_2.periodFundingDebtAdjustment();

  313.         double[] adblPeriodFundingCostAdjustment2 = fgpaa2014_2.periodFundingCostAdjustment();

  314.         double[] adblPeriodFundingBenefitAdjustment2 = fgpaa2014_2.periodFundingBenefitAdjustment();

  315.         double[] adblPeriodSymmetricFundingValueAdjustment2 = fgpaa2014_2.periodSymmetricFundingValueAdjustment();

  316.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  317.         System.out.println ("\t|                             DEBT VALUATION, FUNDING VALUATION, FUNDING DEBT, FUNDING COST, FUNDING BENEFIT, & SYMMETRIC FUNDING VALUATION ADJUSTMENTS                              ||");

  318.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  319.         System.out.println ("\t|  L -> R:                                                                                                                                                                           ||");

  320.         System.out.println ("\t|          - Path #1 Debt Valuation Adjustment                                                                                                                                       ||");

  321.         System.out.println ("\t|          - Path #1 Funding Valuation Adjustment                                                                                                                                    ||");

  322.         System.out.println ("\t|          - Path #1 Funding Debt Adjustment                                                                                                                                         ||");

  323.         System.out.println ("\t|          - Path #1 Funding Cost Adjustment                                                                                                                                         ||");

  324.         System.out.println ("\t|          - Path #1 Funding Benefit Adjustment                                                                                                                                      ||");

  325.         System.out.println ("\t|          - Path #1 Symmatric Funding Valuation Adjustment                                                                                                                          ||");

  326.         System.out.println ("\t|          - Path #2 Debt Valuation Adjustment                                                                                                                                       ||");

  327.         System.out.println ("\t|          - Path #2 Funding Valuation Adjustment                                                                                                                                    ||");

  328.         System.out.println ("\t|          - Path #2 Funding Debt Adjustment                                                                                                                                         ||");

  329.         System.out.println ("\t|          - Path #2 Funding Cost Adjustment                                                                                                                                         ||");

  330.         System.out.println ("\t|          - Path #2 Funding Benefit Adjustment                                                                                                                                      ||");

  331.         System.out.println ("\t|          - Path #2 Symmatric Funding Valuation Adjustment                                                                                                                          ||");

  332.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  333.         for (int i = 1; i <= iNumStep; ++i) {
  334.             System.out.println ("\t| [" +
  335.                 adtVertex[i - 1] + " -> " + adtVertex[i] + "] => " +
  336.                 FormatUtil.FormatDouble (adblPeriodDebtAdjustment1[i - 1], 1, 6, 1.) + " | " +
  337.                 FormatUtil.FormatDouble (adblPeriodFundingValueAdjustment1[i - 1], 1, 6, 1.) + " | " +
  338.                 FormatUtil.FormatDouble (adblPeriodFundingDebtAdjustment1[i - 1], 1, 6, 1.) + " | " +
  339.                 FormatUtil.FormatDouble (adblPeriodFundingCostAdjustment1[i - 1], 1, 6, 1.) + " | " +
  340.                 FormatUtil.FormatDouble (adblPeriodFundingBenefitAdjustment1[i - 1], 1, 6, 1.) + " | " +
  341.                 FormatUtil.FormatDouble (adblPeriodSymmetricFundingValueAdjustment1[i - 1], 1, 6, 1.) + " || " +
  342.                 FormatUtil.FormatDouble (adblPeriodDebtAdjustment2[i - 1], 1, 6, 1.) + " | " +
  343.                 FormatUtil.FormatDouble (adblPeriodFundingValueAdjustment2[i - 1], 1, 6, 1.) + " | " +
  344.                 FormatUtil.FormatDouble (adblPeriodFundingDebtAdjustment2[i - 1], 1, 6, 1.) + " | " +
  345.                 FormatUtil.FormatDouble (adblPeriodFundingCostAdjustment2[i - 1], 1, 6, 1.) + " | " +
  346.                 FormatUtil.FormatDouble (adblPeriodFundingBenefitAdjustment2[i - 1], 1, 6, 1.) + " | " +
  347.                 FormatUtil.FormatDouble (adblPeriodSymmetricFundingValueAdjustment2[i - 1], 1, 6, 1.) + " || "
  348.             );
  349.         }

  350.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  351.         System.out.println();

  352.         ExposureAdjustmentAggregator eaa = new ExposureAdjustmentAggregator (
  353.             new MonoPathExposureAdjustment[] {
  354.                 new MonoPathExposureAdjustment (
  355.                     new AlbaneseAndersenFundingGroupPath[] {fgpaa2014_1}
  356.                 ),
  357.                 new MonoPathExposureAdjustment (
  358.                     new AlbaneseAndersenFundingGroupPath[] {fgpaa2014_2}
  359.                 )
  360.             }
  361.         );

  362.         JulianDate[] adtVertexNode = eaa.vertexDates();

  363.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|");

  364.         String strDump = "\t|         DATE         =>" ;

  365.         for (int i = 0; i < adtVertexNode.length; ++i)
  366.             strDump = strDump + " " + adtVertexNode[i] + " |";

  367.         System.out.println (strDump);

  368.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|");

  369.         double[] adblExposure = eaa.collateralizedExposure();

  370.         strDump = "\t|       EXPOSURE       =>";

  371.         for (int j = 0; j < adblExposure.length; ++j)
  372.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblExposure[j], 1, 4, 1.) + "   |";

  373.         System.out.println (strDump);

  374.         double[] adblPositiveExposure = eaa.collateralizedPositiveExposure();

  375.         strDump = "\t|  POSITIVE EXPOSURE   =>";

  376.         for (int j = 0; j < adblPositiveExposure.length; ++j)
  377.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblPositiveExposure[j], 1, 4, 1.) + "   |";

  378.         System.out.println (strDump);

  379.         double[] adblNegativeExposure = eaa.collateralizedNegativeExposure();

  380.         strDump = "\t|  NEGATIVE EXPOSURE   =>";

  381.         for (int j = 0; j < adblNegativeExposure.length; ++j)
  382.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblNegativeExposure[j], 1, 4, 1.) + "   |";

  383.         System.out.println (strDump);

  384.         double[] adblExposurePV = eaa.collateralizedExposurePV();

  385.         strDump = "\t|      EXPOSURE PV     =>";

  386.         for (int j = 0; j < adblExposurePV.length; ++j)
  387.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblExposurePV[j], 1, 4, 1.) + "   |";

  388.         System.out.println (strDump);

  389.         double[] adblPositiveExposurePV = eaa.collateralizedPositiveExposurePV();

  390.         strDump = "\t| POSITIVE EXPOSURE PV =>";

  391.         for (int j = 0; j < adblPositiveExposurePV.length; ++j)
  392.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblPositiveExposurePV[j], 1, 4, 1.) + "   |";

  393.         System.out.println (strDump);

  394.         double[] adblNegativeExposurePV = eaa.collateralizedNegativeExposurePV();

  395.         strDump = "\t| NEGATIVE EXPOSURE PV =>";

  396.         for (int j = 0; j < adblNegativeExposurePV.length; ++j)
  397.             strDump = strDump + "   " + FormatUtil.FormatDouble (adblNegativeExposurePV[j], 1, 4, 1.) + "   |";

  398.         System.out.println (strDump);

  399.         System.out.println ("\t|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|");

  400.         System.out.println();

  401.         System.out.println ("\t||-------------------||");

  402.         System.out.println ("\t||  UCVA  => " + FormatUtil.FormatDouble (eaa.ucva().amount(), 2, 2, 100.) + "% ||");

  403.         System.out.println ("\t|| FTDCVA => " + FormatUtil.FormatDouble (eaa.ftdcva().amount(), 2, 2, 100.) + "% ||");

  404.         System.out.println ("\t||  CVA   => " + FormatUtil.FormatDouble (eaa.cva().amount(), 2, 2, 100.) + "% ||");

  405.         System.out.println ("\t||  CVACL => " + FormatUtil.FormatDouble (eaa.cvacl().amount(), 2, 2, 100.) + "% ||");

  406.         System.out.println ("\t||  DVA   => " + FormatUtil.FormatDouble (eaa.dva().amount(), 2, 2, 100.) + "% ||");

  407.         System.out.println ("\t||  FVA   => " + FormatUtil.FormatDouble (eaa.fva().amount(), 2, 2, 100.) + "% ||");

  408.         System.out.println ("\t||  FDA   => " + FormatUtil.FormatDouble (eaa.fda().amount(), 2, 2, 100.) + "% ||");

  409.         System.out.println ("\t||  FCA   => " + FormatUtil.FormatDouble (eaa.fca().amount(), 2, 2, 100.) + "% ||");

  410.         System.out.println ("\t||  FBA   => " + FormatUtil.FormatDouble (eaa.fba().amount(), 2, 2, 100.) + "% ||");

  411.         System.out.println ("\t||  SFVA  => " + FormatUtil.FormatDouble (eaa.sfva().amount(), 2, 2, 100.) + "% ||");

  412.         System.out.println ("\t||-------------------||");

  413.         EnvManager.TerminateEnv();
  414.     }
  415. }