CollateralizedCollateralGroupCorrelated.java

  1. package org.drip.sample.xva;

  2. import org.drip.analytics.date.*;
  3. import org.drip.exposure.evolver.LatentStateVertexContainer;
  4. import org.drip.exposure.mpor.CollateralAmountEstimator;
  5. import org.drip.exposure.universe.*;
  6. import org.drip.measure.bridge.BrokenDateInterpolatorLinearT;
  7. import org.drip.measure.discrete.SequenceGenerator;
  8. import org.drip.measure.dynamics.*;
  9. import org.drip.measure.process.DiffusionEvolver;
  10. import org.drip.measure.realization.*;
  11. import org.drip.numerical.common.FormatUtil;
  12. import org.drip.numerical.linearalgebra.Matrix;
  13. import org.drip.service.env.EnvManager;
  14. import org.drip.state.identifier.OTCFixFloatLabel;
  15. import org.drip.xva.gross.*;
  16. import org.drip.xva.netting.CollateralGroupPath;
  17. import org.drip.xva.proto.*;
  18. import org.drip.xva.settings.*;
  19. import org.drip.xva.strategy.*;
  20. import org.drip.xva.vertex.AlbaneseAndersen;

  21. /*
  22.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  23.  */

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

  65. /**
  66.  * CollateralizedCollateralGroupCorrelated illustrates the Sample Run of a Single Partially Collateralized
  67.  *  Collateral Group under Non-Zero Bank/Counter Party Threshold with several Fix-Float Swaps, and with built
  68.  *  in Factor Correlations across the Numeraires. The References are:
  69.  *  
  70.  *  - Burgard, C., and M. Kjaer (2014): PDE Representations of Derivatives with Bilateral Counter-party Risk
  71.  *      and Funding Costs, Journal of Credit Risk, 7 (3) 1-19.
  72.  *  
  73.  *  - Burgard, C., and M. Kjaer (2014): In the Balance, Risk, 24 (11) 72-75.
  74.  *  
  75.  *  - Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk, Risk 20 (2) 86-90.
  76.  *  
  77.  *  - Li, B., and Y. Tang (2007): Quantitative Analysis, Derivatives Modeling, and Trading Strategies in the
  78.  *      Presence of Counter-party Credit Risk for the Fixed Income Market, World Scientific Publishing,
  79.  *      Singapore.
  80.  *
  81.  *  - Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives Pricing, Risk
  82.  *      21 (2) 97-102.
  83.  *
  84.  * @author Lakshmi Krishnamurthy
  85.  */

  86. public class CollateralizedCollateralGroupCorrelated {

  87.     private static final double[] NumeraireValueRealization (
  88.         final DiffusionEvolver deNumeraireValue,
  89.         final double dblNumeraireValueInitial,
  90.         final double dblTime,
  91.         final double dblTimeWidth,
  92.         final double[] adblRandom,
  93.         final int iNumStep)
  94.         throws Exception
  95.     {
  96.         double[] adblNumeraireValue = new double[iNumStep + 1];
  97.         adblNumeraireValue[0] = dblNumeraireValueInitial;
  98.         double[] adblTimeWidth = new double[iNumStep];

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

  101.         JumpDiffusionEdge[] aJDE = deNumeraireValue.incrementSequence (
  102.             new JumpDiffusionVertex (
  103.                 dblTime,
  104.                 dblNumeraireValueInitial,
  105.                 0.,
  106.                 false
  107.             ),
  108.             JumpDiffusionEdgeUnit.Diffusion (
  109.                 adblTimeWidth,
  110.                 adblRandom
  111.             ),
  112.             dblTimeWidth
  113.         );

  114.         for (int j = 1; j <= iNumStep; ++j)
  115.             adblNumeraireValue[j] = aJDE[j - 1].finish();

  116.         return adblNumeraireValue;
  117.     }

  118.     private static final double[] VertexNumeraireRealization (
  119.         final DiffusionEvolver deNumeraireValue,
  120.         final double dblNumeraireValueInitial,
  121.         final double dblTime,
  122.         final double dblTimeWidth,
  123.         final double[] adblRandom,
  124.         final int iNumStep)
  125.         throws Exception
  126.     {
  127.         double[] adblNumeraireValue = new double[iNumStep + 1];
  128.         double[] adblTimeWidth = new double[iNumStep];

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

  131.         JumpDiffusionVertex[] aJDV = deNumeraireValue.vertexSequenceReverse (
  132.             new JumpDiffusionVertex (
  133.                 dblTime,
  134.                 dblNumeraireValueInitial,
  135.                 0.,
  136.                 false
  137.             ),
  138.             JumpDiffusionEdgeUnit.Diffusion (
  139.                 adblTimeWidth,
  140.                 adblRandom
  141.             ),
  142.             adblTimeWidth
  143.         );

  144.         for (int j = 0; j <= iNumStep; ++j)
  145.             adblNumeraireValue[j] = aJDV[j].value();

  146.         return adblNumeraireValue;
  147.     }

  148.     private static final double[] ATMSwapRateOffsetRealization (
  149.         final DiffusionEvolver deATMSwapRateOffset,
  150.         final double dblATMSwapRateOffsetInitial,
  151.         final double[] adblRandom,
  152.         final double dblTime,
  153.         final double dblTimeWidth,
  154.         final int iNumStep)
  155.         throws Exception
  156.     {
  157.         double[] adblATMSwapRateOffset = new double[iNumStep + 1];
  158.         adblATMSwapRateOffset[0] = dblATMSwapRateOffsetInitial;
  159.         double[] adblTimeWidth = new double[iNumStep];

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

  162.         JumpDiffusionEdge[] aJDE = deATMSwapRateOffset.incrementSequence (
  163.             new JumpDiffusionVertex (
  164.                 dblTime,
  165.                 dblATMSwapRateOffsetInitial,
  166.                 0.,
  167.                 false
  168.             ),
  169.             JumpDiffusionEdgeUnit.Diffusion (
  170.                 adblTimeWidth,
  171.                 adblRandom
  172.             ),
  173.             dblTimeWidth
  174.         );

  175.         for (int j = 1; j <= iNumStep; ++j)
  176.             adblATMSwapRateOffset[j] = aJDE[j - 1].finish();

  177.         return adblATMSwapRateOffset;
  178.     }

  179.     private static final double[] SwapPortfolioValueRealization (
  180.         final DiffusionEvolver deATMSwapRate,
  181.         final double dblATMSwapRateStart,
  182.         final double[] adblRandom,
  183.         final int iNumStep,
  184.         final double dblTime,
  185.         final double dblTimeWidth,
  186.         final int iNumSwap)
  187.         throws Exception
  188.     {
  189.         double[] adblSwapPortfolioValueRealization = new double[iNumStep + 1];

  190.         for (int i = 0; i < iNumStep; ++i)
  191.             adblSwapPortfolioValueRealization[i] = 0.;

  192.         for (int i = 0; i < iNumSwap; ++i) {
  193.             double[] adblATMSwapRateOffsetRealization = ATMSwapRateOffsetRealization (
  194.                 deATMSwapRate,
  195.                 dblATMSwapRateStart,
  196.                 adblRandom,
  197.                 dblTime,
  198.                 dblTimeWidth,
  199.                 iNumStep
  200.             );

  201.             for (int j = 0; j <= iNumStep; ++j)
  202.                 adblSwapPortfolioValueRealization[j] += dblTimeWidth * (iNumStep - j) * adblATMSwapRateOffsetRealization[j];
  203.         }

  204.         return adblSwapPortfolioValueRealization;
  205.     }

  206.     public static final void main (
  207.         final String[] astrArgs)
  208.         throws Exception
  209.     {
  210.         EnvManager.InitEnv ("");

  211.         int iNumStep = 10;
  212.         int iNumSwap = 10;
  213.         double dblTime = 5.;
  214.         int iNumPath = 10000;
  215.         double dblATMSwapRateOffsetDrift = 0.0;
  216.         double dblATMSwapRateOffsetVolatility = 0.25;
  217.         double dblATMSwapRateOffsetStart = 0.;
  218.         double dblOvernightNumeraireDrift = 0.004;
  219.         double dblOvernightNumeraireVolatility = 0.02;
  220.         double dblOvernightNumeraireInitial = 1.;
  221.         double dblCSADrift = 0.006;
  222.         double dblCSAVolatility = 0.05;
  223.         double dblCSAInitial = 1.;
  224.         double dblBankHazardRateDrift = 0.002;
  225.         double dblBankHazardRateVolatility = 0.20;
  226.         double dblBankHazardRateInitial = 0.015;
  227.         double dblBankRecoveryRateDrift = 0.002;
  228.         double dblBankRecoveryRateVolatility = 0.02;
  229.         double dblBankRecoveryRateInitial = 0.40;
  230.         double dblCounterPartyHazardRateDrift = 0.002;
  231.         double dblCounterPartyHazardRateVolatility = 0.30;
  232.         double dblCounterPartyHazardRateInitial = 0.030;
  233.         double dblCounterPartyRecoveryRateDrift = 0.002;
  234.         double dblCounterPartyRecoveryRateVolatility = 0.02;
  235.         double dblCounterPartyRecoveryRateInitial = 0.30;
  236.         double dblBankFundingSpreadDrift = 0.00002;
  237.         double dblBankFundingSpreadVolatility = 0.002;
  238.         double dblCounterPartyFundingSpreadDrift = 0.000022;
  239.         double dblCounterPartyFundingSpreadVolatility = 0.0022;
  240.         double dblBankThreshold = -0.1;
  241.         double dblCounterPartyThreshold = 0.1;

  242.         double[][] aadblCorrelation = new double[][] {
  243.             {1.00,  0.00,  0.03,  0.07,  0.04,  0.05,  0.08,  0.00,  0.00},  // PORTFOLIO
  244.             {0.00,  1.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  1.00},  // OVERNIGHT
  245.             {0.03,  0.00,  1.00,  0.26,  0.33,  0.21,  0.35,  0.13,  0.00},  // CSA
  246.             {0.07,  0.00,  0.26,  1.00,  0.45, -0.17,  0.07,  0.77,  0.00},  // BANK HAZARD
  247.             {0.04,  0.00,  0.33,  0.45,  1.00, -0.22, -0.54,  0.58,  0.00},  // COUNTER PARTY HAZARD
  248.             {0.05,  0.00,  0.21, -0.17, -0.22,  1.00,  0.47, -0.23,  0.00},  // BANK RECOVERY
  249.             {0.08,  0.00,  0.35,  0.07, -0.54,  0.47,  1.00,  0.01,  0.00},  // COUNTER PARTY RECOVERY
  250.             {0.00,  0.00,  0.13,  0.77,  0.58, -0.23,  0.01,  1.00,  0.00},  // BANK FUNDING SPREAD
  251.             {0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  0.00,  1.00}   // COUNTER PARTY FUNDING SPREAD
  252.         };

  253.         JulianDate dtSpot = DateUtil.Today();

  254.         PositionGroupSpecification positionGroupSpecification = PositionGroupSpecification.FixedThreshold (
  255.             "FIXEDTHRESHOLD",
  256.             dblCounterPartyThreshold,
  257.             dblBankThreshold,
  258.             PositionReplicationScheme.ALBANESE_ANDERSEN_VERTEX,
  259.             BrokenDateScheme.SQUARE_ROOT_OF_TIME,
  260.             0.,
  261.             CloseOutScheme.ISDA_92
  262.         );

  263.         double dblTimeWidth = dblTime / iNumStep;
  264.         JulianDate[] adtVertex = new JulianDate[iNumStep + 1];
  265.         double[][] aadblPortfolioValue = new double[iNumPath][iNumStep + 1];
  266.         MonoPathExposureAdjustment[] aMPEA = new MonoPathExposureAdjustment[iNumPath];
  267.         double dblBankFundingSpreadInitial = dblBankHazardRateInitial / (1. - dblBankRecoveryRateInitial);
  268.         double dblCounterPartyFundingSpreadInitial = dblCounterPartyHazardRateInitial / (1. - dblCounterPartyRecoveryRateInitial);

  269.         for (int j = 0; j < iNumStep; ++j)
  270.             adtVertex[j] = dtSpot.addMonths (6 * j + 6);

  271.         DiffusionEvolver deATMSwapRateOffset = new DiffusionEvolver (
  272.             DiffusionEvaluatorLinear.Standard (
  273.                 dblATMSwapRateOffsetDrift,
  274.                 dblATMSwapRateOffsetVolatility
  275.             )
  276.         );

  277.         DiffusionEvolver deOvernightNumeraire = new DiffusionEvolver (
  278.             DiffusionEvaluatorLogarithmic.Standard (
  279.                 dblOvernightNumeraireDrift,
  280.                 dblOvernightNumeraireVolatility
  281.             )
  282.         );

  283.         DiffusionEvolver deCSA = new DiffusionEvolver (
  284.             DiffusionEvaluatorLogarithmic.Standard (
  285.                 dblCSADrift,
  286.                 dblCSAVolatility
  287.             )
  288.         );

  289.         DiffusionEvolver deBankHazardRate = new DiffusionEvolver (
  290.             DiffusionEvaluatorLogarithmic.Standard (
  291.                 dblBankHazardRateDrift,
  292.                 dblBankHazardRateVolatility
  293.             )
  294.         );

  295.         DiffusionEvolver deCounterPartyHazardRate = new DiffusionEvolver (
  296.             DiffusionEvaluatorLogarithmic.Standard (
  297.                 dblCounterPartyHazardRateDrift,
  298.                 dblCounterPartyHazardRateVolatility
  299.             )
  300.         );

  301.         DiffusionEvolver deBankRecoveryRate = new DiffusionEvolver (
  302.             DiffusionEvaluatorLogarithmic.Standard (
  303.                 dblBankRecoveryRateDrift,
  304.                 dblBankRecoveryRateVolatility
  305.             )
  306.         );

  307.         DiffusionEvolver deCounterPartyRecoveryRate = new DiffusionEvolver (
  308.             DiffusionEvaluatorLogarithmic.Standard (
  309.                 dblCounterPartyRecoveryRateDrift,
  310.                 dblCounterPartyRecoveryRateVolatility
  311.             )
  312.         );

  313.         DiffusionEvolver deBankFundingSpread = new DiffusionEvolver (
  314.             DiffusionEvaluatorLinear.Standard (
  315.                 dblBankFundingSpreadDrift,
  316.                 dblBankFundingSpreadVolatility
  317.             )
  318.         );

  319.         DiffusionEvolver deCounterPartyFundingSpread = new DiffusionEvolver (
  320.             DiffusionEvaluatorLinear.Standard (
  321.                 dblCounterPartyFundingSpreadDrift,
  322.                 dblCounterPartyFundingSpreadVolatility
  323.             )
  324.         );

  325.         for (int i = 0; i < iNumPath; ++i) {
  326.             double[][] aadblNumeraire = Matrix.Transpose (
  327.                 SequenceGenerator.GaussianJoint (
  328.                     iNumStep,
  329.                     aadblCorrelation
  330.                 )
  331.             );

  332.             aadblPortfolioValue[i] = SwapPortfolioValueRealization (
  333.                 deATMSwapRateOffset,
  334.                 dblATMSwapRateOffsetStart,
  335.                 aadblNumeraire[0],
  336.                 iNumStep,
  337.                 dblTime,
  338.                 dblTimeWidth,
  339.                 iNumSwap
  340.             );

  341.             double[] adblOvernightNumeraire = VertexNumeraireRealization (
  342.                 deOvernightNumeraire,
  343.                 dblOvernightNumeraireInitial,
  344.                 dblTime,
  345.                 dblTimeWidth,
  346.                 aadblNumeraire[1],
  347.                 iNumStep
  348.             );

  349.             double[] adblCSA = VertexNumeraireRealization (
  350.                 deCSA,
  351.                 dblCSAInitial,
  352.                 dblTime,
  353.                 dblTimeWidth,
  354.                 aadblNumeraire[2],
  355.                 iNumStep
  356.             );

  357.             double[] adblBankHazardRate = NumeraireValueRealization (
  358.                 deBankHazardRate,
  359.                 dblBankHazardRateInitial,
  360.                 dblTime,
  361.                 dblTimeWidth,
  362.                 aadblNumeraire[3],
  363.                 iNumStep
  364.             );

  365.             double[] adblCounterPartyHazardRate = NumeraireValueRealization (
  366.                 deCounterPartyHazardRate,
  367.                 dblCounterPartyHazardRateInitial,
  368.                 dblTime,
  369.                 dblTimeWidth,
  370.                 aadblNumeraire[4],
  371.                 iNumStep
  372.             );

  373.             double[] adblBankRecoveryRate = NumeraireValueRealization (
  374.                 deBankRecoveryRate,
  375.                 dblBankRecoveryRateInitial,
  376.                 dblTime,
  377.                 dblTimeWidth,
  378.                 aadblNumeraire[5],
  379.                 iNumStep
  380.             );

  381.             double[] adblCounterPartyRecoveryRate = NumeraireValueRealization (
  382.                 deCounterPartyRecoveryRate,
  383.                 dblCounterPartyRecoveryRateInitial,
  384.                 dblTime,
  385.                 dblTimeWidth,
  386.                 aadblNumeraire[6],
  387.                 iNumStep
  388.             );

  389.             double[] adblBankFundingSpread = NumeraireValueRealization (
  390.                 deBankFundingSpread,
  391.                 dblBankFundingSpreadInitial,
  392.                 dblTime,
  393.                 dblTimeWidth,
  394.                 aadblNumeraire[7],
  395.                 iNumStep
  396.             );

  397.             double[] adblCounterPartyFundingSpread = NumeraireValueRealization (
  398.                 deCounterPartyFundingSpread,
  399.                 dblCounterPartyFundingSpreadInitial,
  400.                 dblTime,
  401.                 dblTimeWidth,
  402.                 aadblNumeraire[8],
  403.                 iNumStep
  404.             );

  405.             JulianDate dtStart = dtSpot;
  406.             MarketVertex[] aMV = new MarketVertex [iNumStep + 1];
  407.             double dblValueStart = dblTime * dblATMSwapRateOffsetStart;
  408.             AlbaneseAndersen[] aHGVR = new AlbaneseAndersen[iNumStep + 1];

  409.             for (int j = 0; j <= iNumStep; ++j)
  410.             {
  411.                 LatentStateVertexContainer latentStateVertexContainer = new LatentStateVertexContainer();

  412.                 latentStateVertexContainer.add (
  413.                     OTCFixFloatLabel.Standard ("USD-3M-10Y"),
  414.                     Double.NaN
  415.                 );

  416.                 aMV[j] = MarketVertex.Nodal (
  417.                     adtVertex[j] = dtSpot.addMonths (6 * j),
  418.                     dblOvernightNumeraireDrift,
  419.                     adblOvernightNumeraire[j],
  420.                     dblCSADrift,
  421.                     adblCSA[j],
  422.                     new MarketVertexEntity (
  423.                         Math.exp (-0.5 * adblBankHazardRate[j] * j),
  424.                         adblBankHazardRate[j],
  425.                         adblBankRecoveryRate[j],
  426.                         adblBankFundingSpread[j],
  427.                         Math.exp (-0.5 * adblBankHazardRate[j] * (1. - adblBankRecoveryRate[j]) * (iNumStep - j)),
  428.                         Double.NaN,
  429.                         Double.NaN,
  430.                         Double.NaN
  431.                     ),
  432.                     new MarketVertexEntity (
  433.                         Math.exp (-0.5 * adblCounterPartyHazardRate[j] * j),
  434.                         adblCounterPartyHazardRate[j],
  435.                         adblCounterPartyRecoveryRate[j],
  436.                         adblCounterPartyFundingSpread[j],
  437.                         Math.exp (-0.5 * adblCounterPartyHazardRate[j] * (1. - adblCounterPartyRecoveryRate[j]) * (iNumStep - j)),
  438.                         Double.NaN,
  439.                         Double.NaN,
  440.                         Double.NaN
  441.                     ),
  442.                     latentStateVertexContainer
  443.                 );

  444.                 JulianDate dtEnd = adtVertex[j];
  445.                 double dblCollateralBalance = 0.;
  446.                 double dblValueEnd = aadblPortfolioValue[i][j];

  447.                 if (0 != j) {
  448.                     CollateralAmountEstimator cae = new CollateralAmountEstimator (
  449.                         positionGroupSpecification,
  450.                         new BrokenDateInterpolatorLinearT (
  451.                             dtStart.julian(),
  452.                             dtEnd.julian(),
  453.                             dblValueStart,
  454.                             dblValueEnd
  455.                         ),
  456.                         Double.NaN
  457.                     );

  458.                     dblCollateralBalance = cae.postingRequirement (dtEnd);
  459.                 }

  460.                 aHGVR[j] = new AlbaneseAndersen (
  461.                     adtVertex[j],
  462.                     aadblPortfolioValue[i][j],
  463.                     0.,
  464.                     dblCollateralBalance
  465.                 );

  466.                 dtStart = dtEnd;
  467.                 dblValueStart = dblValueEnd;
  468.             }

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

  470.             CollateralGroupPath[] aHGP = new CollateralGroupPath[] {
  471.                 new CollateralGroupPath (
  472.                     aHGVR,
  473.                     mp
  474.                 )
  475.             };

  476.             aMPEA[i] = new MonoPathExposureAdjustment (
  477.                 new AlbaneseAndersenFundingGroupPath[] {
  478.                     new AlbaneseAndersenFundingGroupPath (
  479.                         new AlbaneseAndersenNettingGroupPath[] {
  480.                             new AlbaneseAndersenNettingGroupPath (
  481.                                 aHGP,
  482.                                 mp
  483.                             )
  484.                         },
  485.                         mp
  486.                     )
  487.                 }
  488.             );
  489.         }

  490.         ExposureAdjustmentAggregator eaa = new ExposureAdjustmentAggregator (aMPEA);

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

  492.         System.out.println();

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

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

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

  497.         System.out.println (strDump);

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

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

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

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

  503.         System.out.println (strDump);

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

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

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

  508.         System.out.println (strDump);

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

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

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

  513.         System.out.println (strDump);

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

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

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

  518.         System.out.println (strDump);

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

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

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

  523.         System.out.println (strDump);

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

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

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

  528.         System.out.println (strDump);

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

  530.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

  543.         EnvManager.TerminateEnv();
  544.     }
  545. }