FundingGroupSemiReplication.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.  * FundingGroupSemiReplication demonstrates the Simulation Run of the Funding Group Exposure using the "Semi
  64.  *  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 FundingGroupSemiReplication {

  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.SemiReplicationDualBond (
  218.                     adtVertex[i],
  219.                     adblAssetValuePath1[i],
  220.                     0.,
  221.                     0.,
  222.                     new MarketEdge (
  223.                         aMV[i - 1],
  224.                         aMV[i]
  225.                     ),
  226.                     cog
  227.                 );

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

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

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

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

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

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

  282.         AlbaneseAndersenNettingGroupPath ngpaa2014_1 = new AlbaneseAndersenNettingGroupPath (
  283.             aCGP1,
  284.             mp
  285.         );

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

  290.         AlbaneseAndersenNettingGroupPath ngpaa2014_2 = new AlbaneseAndersenNettingGroupPath (
  291.             aCGP2,
  292.             mp
  293.         );

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

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

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

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

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

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

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

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

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

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

  307.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  335.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  383.         System.out.println();

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

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

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

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

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

  399.         System.out.println (strDump);

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

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

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

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

  405.         System.out.println (strDump);

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

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

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

  410.         System.out.println (strDump);

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

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

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

  415.         System.out.println (strDump);

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

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

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

  420.         System.out.println (strDump);

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

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

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

  425.         System.out.println (strDump);

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

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

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

  430.         System.out.println (strDump);

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

  432.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

  445.         System.out.println();

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

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

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

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

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

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

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

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

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

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

  461.         System.out.println();

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

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

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

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

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

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

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

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

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

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

  477.         System.out.println();

  478.         EnvManager.TerminateEnv();
  479.     }
  480. }