CreditNonQualifyingParameters20.java

  1. package org.drip.sample.simmsettings;

  2. import java.util.Set;

  3. import org.drip.numerical.common.FormatUtil;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.simm.credit.CRBucket;
  6. import org.drip.simm.credit.CRNQBucketCorrelation20;
  7. import org.drip.simm.credit.CRNQSettingsContainer20;
  8. import org.drip.simm.credit.CRNQSystemics20;

  9. /*
  10.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  11.  */

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

  52. /**
  53.  * CreditNonQualifyingParameters20 demonstrates the Extraction and Display of ISDA SIMM 2.0 Single/Cross
  54.  *  Currency Credit Non-Qualifying Bucket Risk Weights, Systemics, and Correlations. The References are:
  55.  *  
  56.  *  - Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Credit Exposure in the Presence of Initial Margin,
  57.  *      https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2806156, eSSRN.
  58.  *  
  59.  *  - Albanese, C., S. Caenazzo, and O. Frankel (2017): Regression Sensitivities for Initial Margin
  60.  *      Calculations, https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2763488, eSSRN.
  61.  *  
  62.  *  - Anfuso, F., D. Aziz, P. Giltinan, and K. Loukopoulus (2017): A Sound Modeling and Back-testing
  63.  *      Framework for Forecasting Initial Margin Requirements,
  64.  *      https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2716279, eSSRN.
  65.  *  
  66.  *  - Caspers, P., P. Giltinan, R. Lichters, and N. Nowaczyk (2017): Forecasting Initial Margin Requirements
  67.  *      - A Model Evaluation https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2911167, eSSRN.
  68.  *  
  69.  *  - International Swaps and Derivatives Association (2017): SIMM v2.0 Methodology,
  70.  *      https://www.isda.org/a/oFiDE/isda-simm-v2.pdf.
  71.  *
  72.  * @author Lakshmi Krishnamurthy
  73.  */

  74. public class CreditNonQualifyingParameters20
  75. {

  76.     private static final void DisplayRiskWeights()
  77.     {
  78.         Set<Integer> bucketIndexSet = CRNQSettingsContainer20.BucketSet();

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

  81.         System.out.println
  82.             ("\t||                               2.0 CREDIT NON QUALIFYING BUCKETS RISK WEIGHT                                 ||");

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

  85.         System.out.println
  86.             ("\t||                                                                                                             ||");

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

  89.         System.out.println
  90.             ("\t||                - Bucket Number                                                                              ||");

  91.         System.out.println
  92.             ("\t||                - Bucket Quality                                                                             ||");

  93.         System.out.println
  94.             ("\t||                - Bucket Risk Weight                                                                         ||");

  95.         System.out.println
  96.             ("\t||                - Bucket Sector                                                                              ||");

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

  99.         for (int bucketIndex : bucketIndexSet)
  100.         {
  101.             CRBucket creditQualifyingBucket = CRNQSettingsContainer20.Bucket (bucketIndex);

  102.             String sectorArrayDump = "";

  103.             String[] sectorArray = creditQualifyingBucket.sectorArray();

  104.             for (String sector : sectorArray)
  105.             {
  106.                 sectorArrayDump = sectorArrayDump + sector + " ,";
  107.             }

  108.             System.out.println (
  109.                 "\t|| " + FormatUtil.FormatDouble (creditQualifyingBucket.number(), 2, 0, 1.) + " | " +
  110.                 FormatUtil.FormatDouble (creditQualifyingBucket.riskWeight(), 4, 0, 1.) + " | " +
  111.                 creditQualifyingBucket.quality() + " | {" +
  112.                 sectorArrayDump + "}"
  113.             );
  114.         }

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

  117.         System.out.println();
  118.     }

  119.     private static final void CreditNonQualifyingSystemics()
  120.     {
  121.         System.out.println ("\t||----------------------------------------------------------------||");

  122.         System.out.println ("\t||                CREDIT NON QUALIFYING SYSTEMICS                 ||");

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

  124.         System.out.println (
  125.             "\t|| Vega Risk Wight                                     => " +
  126.             FormatUtil.FormatDouble (
  127.                 CRNQSystemics20.VEGA_RISK_WEIGHT, 3, 2, 1.
  128.             ) + " ||"
  129.         );

  130.         System.out.println (
  131.             "\t|| Non-Residual Correlation >80% Names Overlap         => " +
  132.             FormatUtil.FormatDouble (
  133.                 CRNQBucketCorrelation20.GT_80PC_OVERLAP_NON_RESIDUAL, 3, 2, 1.
  134.             ) + " ||"
  135.         );

  136.         System.out.println (
  137.             "\t|| Non-Residual Correlation <80% Names Overlap         => " +
  138.             FormatUtil.FormatDouble (
  139.                 CRNQBucketCorrelation20.LT_80PC_OVERLAP_NON_RESIDUAL, 3, 2, 1.
  140.             ) + " ||"
  141.         );

  142.         System.out.println (
  143.             "\t|| Residual Correlation >80% Names Overlap             => " +
  144.             FormatUtil.FormatDouble (
  145.                 CRNQBucketCorrelation20.GT_80PC_OVERLAP_RESIDUAL, 3, 2, 1.
  146.             ) + " ||"
  147.         );

  148.         System.out.println (
  149.             "\t|| Residual Correlation <80% Names Overlap             => " +
  150.             FormatUtil.FormatDouble (
  151.                 CRNQBucketCorrelation20.LT_80PC_OVERLAP_RESIDUAL, 3, 2, 1.
  152.             ) + " ||"
  153.         );

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

  155.         System.out.println();
  156.     }

  157.     public static final void main (
  158.         final String[] args)
  159.         throws Exception
  160.     {
  161.         EnvManager.InitEnv ("");

  162.         DisplayRiskWeights();

  163.         CreditNonQualifyingSystemics();

  164.         EnvManager.TerminateEnv();
  165.     }
  166. }