FundingGroupPerfectReplication.java

  1. package org.drip.sample.xvastrategy;

  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.definition.*;
  13. import org.drip.xva.derivative.ReplicationPortfolioVertexDealer;
  14. import org.drip.xva.gross.*;
  15. import org.drip.xva.netting.CollateralGroupPath;
  16. import org.drip.xva.strategy.*;
  17. import org.drip.xva.vertex.*;

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

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

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

  82. public class FundingGroupPerfectReplication {

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

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

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

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

  111.         return ablAssetValue;
  112.     }

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

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

  130.         double dblTimeWidth = dblTime / iNumStep;
  131.         MarketVertex[] aMV = new MarketVertex[iNumStep + 1];
  132.         JulianDate[] adtVertex = new JulianDate[iNumStep + 1];
  133.         BurgardKjaer[] aBKV1 = new BurgardKjaer[iNumStep + 1];
  134.         BurgardKjaer[] aBKV2 = new BurgardKjaer[iNumStep + 1];
  135.         double dblBankSeniorFundingSpread = dblBankHazardRate / (1. - dblBankSeniorRecoveryRate);
  136.         double dblBankSubordinateFundingSpread = dblBankHazardRate / (1. - dblBankSubordinateRecoveryRate);
  137.         double dblCounterPartyFundingSpread = dblCounterPartyHazardRate / (1. - dblCounterPartyRecoveryRate);

  138.         JulianDate dtSpot = DateUtil.Today();

  139.         CloseOut cog = new CloseOutBilateral (
  140.             dblBankSeniorRecoveryRate,
  141.             dblCounterPartyRecoveryRate
  142.         );

  143.         DiffusionEvolver deAssetValue = new DiffusionEvolver (
  144.             DiffusionEvaluatorLogarithmic.Standard (
  145.                 dblAssetDrift,
  146.                 dblAssetVolatility
  147.             )
  148.         );

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

  156.         double[] adblAssetValuePath2 = AssetValueRealization (
  157.             deAssetValue,
  158.             dblAssetValueInitial,
  159.             dblTime,
  160.             dblTimeWidth,
  161.             iNumStep
  162.         );

  163.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  181.         for (int i = 0; i <= iNumStep; ++i)
  182.         {
  183.             LatentStateVertexContainer latentStateVertexContainer = new LatentStateVertexContainer();

  184.             latentStateVertexContainer.add (
  185.                 OTCFixFloatLabel.Standard ("USD-3M-10Y"),
  186.                 Double.NaN
  187.             );

  188.             aMV[i] = MarketVertex.Nodal (
  189.                 adtVertex[i] = dtSpot.addMonths (6 * i),
  190.                 dblOISRate,
  191.                 Math.exp (-0.5 * dblOISRate * (iNumStep - i)),
  192.                 dblCSADrift,
  193.                 Math.exp (-0.5 * dblCSADrift * (iNumStep - i)),
  194.                 new MarketVertexEntity (
  195.                     Math.exp (-0.5 * dblBankHazardRate * i),
  196.                     dblBankHazardRate,
  197.                     dblBankSeniorRecoveryRate,
  198.                     dblBankSeniorFundingSpread,
  199.                     Math.exp (-0.5 * dblBankHazardRate * (1. - dblBankSeniorRecoveryRate) * (iNumStep - i)),
  200.                     dblBankSubordinateRecoveryRate,
  201.                     dblBankSubordinateFundingSpread,
  202.                     Math.exp (-0.5 * dblBankHazardRate * (1. - dblBankSubordinateRecoveryRate) * (iNumStep - i))
  203.                 ),
  204.                 new MarketVertexEntity (
  205.                     Math.exp (-0.5 * dblCounterPartyHazardRate * i),
  206.                     dblCounterPartyHazardRate,
  207.                     dblCounterPartyRecoveryRate,
  208.                     dblCounterPartyFundingSpread,
  209.                     Math.exp (-0.5 * dblCounterPartyHazardRate * (1. - dblCounterPartyRecoveryRate) * (iNumStep - i)),
  210.                     Double.NaN,
  211.                     Double.NaN,
  212.                     Double.NaN
  213.                 ),
  214.                 latentStateVertexContainer
  215.             );

  216.             if (0 != i) {
  217.                 aBKV1[i] = BurgardKjaerBuilder.HedgeErrorDualBond (
  218.                     adtVertex[i],
  219.                     adblAssetValuePath1[i],
  220.                     0.,
  221.                     0.,
  222.                     0.,
  223.                     new MarketEdge (
  224.                         aMV[i - 1],
  225.                         aMV[i]
  226.                     ),
  227.                     cog
  228.                 );

  229.                 aBKV2[i] = BurgardKjaerBuilder.HedgeErrorDualBond (
  230.                     adtVertex[i],
  231.                     adblAssetValuePath2[i],
  232.                     0.,
  233.                     0.,
  234.                     0.,
  235.                     new MarketEdge (
  236.                         aMV[i - 1],
  237.                         aMV[i]
  238.                     ),
  239.                     cog
  240.                 );
  241.             } else {
  242.                 aBKV1[i] = BurgardKjaerBuilder.Initial (
  243.                     adtVertex[i],
  244.                     adblAssetValuePath1[i],
  245.                     aMV[i],
  246.                     cog
  247.                 );

  248.                 aBKV2[i] = BurgardKjaerBuilder.Initial (
  249.                     adtVertex[i],
  250.                     adblAssetValuePath2[i],
  251.                     aMV[i],
  252.                     cog
  253.                 );
  254.             }

  255.             System.out.println (
  256.                 "\t| " + adtVertex[i] + " => " +
  257.                 FormatUtil.FormatDouble (aBKV1[i].collateralized(), 1, 6, 1.) + " | " +
  258.                 FormatUtil.FormatDouble (aBKV1[i].uncollateralized(), 1, 6, 1.) + " | " +
  259.                 FormatUtil.FormatDouble (aBKV1[i].variationMarginPosting(), 1, 6, 1.) + " | " +
  260.                 FormatUtil.FormatDouble (aBKV2[i].collateralized(), 1, 6, 1.) + " | " +
  261.                 FormatUtil.FormatDouble (aBKV2[i].uncollateralized(), 1, 6, 1.) + " | " +
  262.                 FormatUtil.FormatDouble (aBKV2[i].variationMarginPosting(), 1, 6, 1.) + " | " +
  263.                 FormatUtil.FormatDouble (aMV[i].overnightRate(), 1, 6, 1.) + " | " +
  264.                 FormatUtil.FormatDouble (aMV[i].dealer().survivalProbability(), 1, 6, 1.) + " | " +
  265.                 FormatUtil.FormatDouble (aMV[i].dealer().seniorRecoveryRate(), 1, 6, 1.) + " | " +
  266.                 FormatUtil.FormatDouble (aMV[i].dealer().seniorFundingSpread(), 1, 6, 1.) + " | " +
  267.                 FormatUtil.FormatDouble (aMV[i].client().survivalProbability(), 1, 6, 1.) + " | " +
  268.                 FormatUtil.FormatDouble (aMV[i].client().seniorRecoveryRate(), 1, 6, 1.) + " ||"
  269.             );
  270.         }

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

  272.         CollateralGroupPath[] aCGP1 = new CollateralGroupPath[] {
  273.             new CollateralGroupPath (
  274.                 aBKV1,
  275.                 mp
  276.             )
  277.         };

  278.         CollateralGroupPath[] aCGP2 = new CollateralGroupPath[] {
  279.             new CollateralGroupPath (
  280.                 aBKV2,
  281.                 mp
  282.             )
  283.         };

  284.         AlbaneseAndersenNettingGroupPath ngpaa2014_1 = new AlbaneseAndersenNettingGroupPath (
  285.             aCGP1,
  286.             mp
  287.         );

  288.         AlbaneseAndersenFundingGroupPath fgpaa2014_1 = new AlbaneseAndersenFundingGroupPath (
  289.             new AlbaneseAndersenNettingGroupPath[] {ngpaa2014_1},
  290.             mp
  291.         );

  292.         AlbaneseAndersenNettingGroupPath ngpaa2014_2 = new AlbaneseAndersenNettingGroupPath (
  293.             aCGP2,
  294.             mp
  295.         );

  296.         AlbaneseAndersenFundingGroupPath fgpaa2014_2 = new AlbaneseAndersenFundingGroupPath (
  297.             new AlbaneseAndersenNettingGroupPath[] {ngpaa2014_2},
  298.             mp
  299.         );

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

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

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

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

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

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

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

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

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

  309.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

  323.         for (int i = 1; i <= iNumStep; ++i) {
  324.             System.out.println ("\t| [" +
  325.                 adtVertex[i - 1] + " -> " + adtVertex[i] + "] => " +
  326.                 FormatUtil.FormatDouble (adblPeriodUnilateralCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  327.                 FormatUtil.FormatDouble (adblPeriodBilateralCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  328.                 FormatUtil.FormatDouble (adblPeriodCreditAdjustment1[i - 1], 1, 6, 1.) + " | " +
  329.                 FormatUtil.FormatDouble (adblPeriodContraLiabilityCreditAdjustment1[i - 1], 1, 6, 1.) + " ||| " +
  330.                 FormatUtil.FormatDouble (adblPeriodUnilateralCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  331.                 FormatUtil.FormatDouble (adblPeriodBilateralCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  332.                 FormatUtil.FormatDouble (adblPeriodCreditAdjustment2[i - 1], 1, 6, 1.) + " | " +
  333.                 FormatUtil.FormatDouble (adblPeriodContraLiabilityCreditAdjustment2[i - 1], 1, 6, 1.) + " ||"
  334.             );
  335.         }

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

  337.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  367.         for (int i = 1; i <= iNumStep; ++i) {
  368.             System.out.println ("\t| [" +
  369.                 adtVertex[i - 1] + " -> " + adtVertex[i] + "] => " +
  370.                 FormatUtil.FormatDouble (adblPeriodDebtAdjustment1[i - 1], 1, 6, 1.) + " | " +
  371.                 FormatUtil.FormatDouble (adblPeriodFundingValueAdjustment1[i - 1], 1, 6, 1.) + " | " +
  372.                 FormatUtil.FormatDouble (adblPeriodFundingDebtAdjustment1[i - 1], 1, 6, 1.) + " | " +
  373.                 FormatUtil.FormatDouble (adblPeriodFundingCostAdjustment1[i - 1], 1, 6, 1.) + " | " +
  374.                 FormatUtil.FormatDouble (adblPeriodFundingBenefitAdjustment1[i - 1], 1, 6, 1.) + " | " +
  375.                 FormatUtil.FormatDouble (adblPeriodSymmetricFundingValueAdjustment1[i - 1], 1, 6, 1.) + " || " +
  376.                 FormatUtil.FormatDouble (adblPeriodDebtAdjustment2[i - 1], 1, 6, 1.) + " | " +
  377.                 FormatUtil.FormatDouble (adblPeriodFundingValueAdjustment2[i - 1], 1, 6, 1.) + " | " +
  378.                 FormatUtil.FormatDouble (adblPeriodFundingDebtAdjustment2[i - 1], 1, 6, 1.) + " | " +
  379.                 FormatUtil.FormatDouble (adblPeriodFundingCostAdjustment2[i - 1], 1, 6, 1.) + " | " +
  380.                 FormatUtil.FormatDouble (adblPeriodFundingBenefitAdjustment2[i - 1], 1, 6, 1.) + " | " +
  381.                 FormatUtil.FormatDouble (adblPeriodSymmetricFundingValueAdjustment2[i - 1], 1, 6, 1.) + " || "
  382.             );
  383.         }

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

  385.         System.out.println();

  386.         ExposureAdjustmentAggregator eaa = new ExposureAdjustmentAggregator (
  387.             new MonoPathExposureAdjustment[] {
  388.                 new MonoPathExposureAdjustment (
  389.                     new AlbaneseAndersenFundingGroupPath[] {fgpaa2014_1}
  390.                 ),
  391.                 new MonoPathExposureAdjustment (
  392.                     new AlbaneseAndersenFundingGroupPath[] {fgpaa2014_2}
  393.                 )
  394.             }
  395.         );

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

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

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

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

  401.         System.out.println (strDump);

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

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

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

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

  407.         System.out.println (strDump);

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

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

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

  412.         System.out.println (strDump);

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

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

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

  417.         System.out.println (strDump);

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

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

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

  422.         System.out.println (strDump);

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

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

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

  427.         System.out.println (strDump);

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

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

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

  432.         System.out.println (strDump);

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

  434.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

  447.         System.out.println();

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

  449.         System.out.println ("\t|| BURGARD KJAER REPLICATION PORTFOLIO #1 ||");

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

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

  452.         System.out.println ("\t||           - Bank Bond Units            ||");

  453.         System.out.println ("\t||           - Bank Subordinate Units     ||");

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

  455.         for (int i = 0; i <= iNumStep; ++i) {
  456.             ReplicationPortfolioVertexDealer rpvb = aBKV1[i].dealerReplicationPortfolio();

  457.             System.out.println ("\t|| [" + adtVertex[i] + "] =>   " +
  458.                 FormatUtil.FormatDouble (rpvb.seniorNumeraireHoldings(), 1, 3, 1.) + "  |  " +
  459.                 FormatUtil.FormatDouble (rpvb.subordinateNumeraireHoldings(), 1, 3, 1.) + "   || "
  460.             );
  461.         }

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

  463.         System.out.println();

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

  465.         System.out.println ("\t|| BURGARD KJAER REPLICATION PORTFOLIO #2 ||");

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

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

  468.         System.out.println ("\t||           - Bank Bond Units            ||");

  469.         System.out.println ("\t||           - Bank Subordinate Units     ||");

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

  471.         for (int i = 0; i <= iNumStep; ++i) {
  472.             ReplicationPortfolioVertexDealer rpvb = aBKV2[i].dealerReplicationPortfolio();

  473.             System.out.println ("\t|| [" + adtVertex[i] + "] =>   " +
  474.                 FormatUtil.FormatDouble (rpvb.seniorNumeraireHoldings(), 1, 3, 1.) + "  |  " +
  475.                 FormatUtil.FormatDouble (rpvb.subordinateNumeraireHoldings(), 1, 3, 1.) + "   || "
  476.             );
  477.         }

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

  479.         System.out.println();

  480.         EnvManager.TerminateEnv();
  481.     }
  482. }