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

  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 dblFixedHedgeError = 0.01;
  121.         double dblAssetDrift = 0.06;
  122.         double dblAssetVolatility = 0.15;
  123.         double dblAssetValueInitial = 1.;
  124.         double dblOISRate = 0.004;
  125.         double dblCSADrift = 0.01;
  126.         double dblBankHazardRate = 0.015;
  127.         double dblBankSeniorRecoveryRate = 0.40;
  128.         double dblBankSubordinateRecoveryRate = 0.15;
  129.         double dblCounterPartyHazardRate = 0.030;
  130.         double dblCounterPartyRecoveryRate = 0.30;

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

  139.         JulianDate dtSpot = DateUtil.Today();

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

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

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

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

  164.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  289.         AlbaneseAndersenFundingGroupPath fgpaa2014_1 = AlbaneseAndersenFundingGroupPath.Mono (
  290.             ngpaa2014_1,
  291.             mp
  292.         );

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

  297.         AlbaneseAndersenFundingGroupPath fgpaa2014_2 = AlbaneseAndersenFundingGroupPath.Mono (
  298.             ngpaa2014_1,
  299.             mp
  300.         );

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

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

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

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

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

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

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

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

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

  310.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  338.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  386.         System.out.println();

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

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

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

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

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

  402.         System.out.println (strDump);

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

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

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

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

  408.         System.out.println (strDump);

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

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

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

  413.         System.out.println (strDump);

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

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

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

  418.         System.out.println (strDump);

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

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

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

  423.         System.out.println (strDump);

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

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

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

  428.         System.out.println (strDump);

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

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

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

  433.         System.out.println (strDump);

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

  435.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

  448.         System.out.println();

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

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

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

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

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

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

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

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

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

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

  464.         System.out.println();

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

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

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

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

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

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

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

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

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

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

  480.         System.out.println();

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