CRQSettingsContainer20.java

  1. package org.drip.simm.credit;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

  5. /*!
  6.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  7.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  8.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  9.  *
  10.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  11.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  12.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  13.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  14.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  15.  *      and computational support.
  16.  *  
  17.  *      https://lakshmidrip.github.io/DROP/
  18.  *  
  19.  *  DROP is composed of three modules:
  20.  *  
  21.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  22.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  23.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  24.  *
  25.  *  DROP Product Core implements libraries for the following:
  26.  *  - Fixed Income Analytics
  27.  *  - Loan Analytics
  28.  *  - Transaction Cost Analytics
  29.  *
  30.  *  DROP Portfolio Core implements libraries for the following:
  31.  *  - Asset Allocation Analytics
  32.  *  - Asset Liability Management Analytics
  33.  *  - Capital Estimation Analytics
  34.  *  - Exposure Analytics
  35.  *  - Margin Analytics
  36.  *  - XVA Analytics
  37.  *
  38.  *  DROP Computational Core implements libraries for the following:
  39.  *  - Algorithm Support
  40.  *  - Computation Support
  41.  *  - Function Analysis
  42.  *  - Model Validation
  43.  *  - Numerical Analysis
  44.  *  - Numerical Optimizer
  45.  *  - Spline Builder
  46.  *  - Statistical Learning
  47.  *
  48.  *  Documentation for DROP is Spread Over:
  49.  *
  50.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  51.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  52.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  53.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  54.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  55.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  56.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  57.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  58.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  59.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  60.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  61.  *
  62.  *  Licensed under the Apache License, Version 2.0 (the "License");
  63.  *      you may not use this file except in compliance with the License.
  64.  *  
  65.  *  You may obtain a copy of the License at
  66.  *      http://www.apache.org/licenses/LICENSE-2.0
  67.  *  
  68.  *  Unless required by applicable law or agreed to in writing, software
  69.  *      distributed under the License is distributed on an "AS IS" BASIS,
  70.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  71.  *  
  72.  *  See the License for the specific language governing permissions and
  73.  *      limitations under the License.
  74.  */

  75. /**
  76.  * <i>CRQSettingsContainer20</i> holds the ISDA SIMM 2.0 Credit Qualifying Buckets. The References are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Credit Exposure in the Presence of Initial
  82.  *              Margin https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2806156 <b>eSSRN</b>
  83.  *      </li>
  84.  *      <li>
  85.  *          Albanese, C., S. Caenazzo, and O. Frankel (2017): Regression Sensitivities for Initial Margin
  86.  *              Calculations https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2763488 <b>eSSRN</b>
  87.  *      </li>
  88.  *      <li>
  89.  *          Anfuso, F., D. Aziz, P. Giltinan, and K. Loukopoulus (2017): A Sound Modeling and Back-testing
  90.  *              Framework for Forecasting Initial Margin Requirements
  91.  *                  https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2716279 <b>eSSRN</b>
  92.  *      </li>
  93.  *      <li>
  94.  *          Caspers, P., P. Giltinan, R. Lichters, and N. Nowaczyk (2017): Forecasting Initial Margin
  95.  *              Requirements - A Model Evaluation https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2911167
  96.  *                  <b>eSSRN</b>
  97.  *      </li>
  98.  *      <li>
  99.  *          International Swaps and Derivatives Association (2017): SIMM v2.0 Methodology
  100.  *              https://www.isda.org/a/oFiDE/isda-simm-v2.pdf
  101.  *      </li>
  102.  *  </ul>
  103.  *
  104.  * <br><br>
  105.  *  <ul>
  106.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  107.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/MarginAnalyticsLibrary.md">Initial and Variation Margin Analytics</a></li>
  108.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/simm/README.md">Initial Margin Analytics based on ISDA SIMM and its Variants</a></li>
  109.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/simm/credit/README.md">Credit Qualifying/Non-Qualifying Risk Factor Settings</a></li>
  110.  *  </ul>
  111.  * <br><br>
  112.  *
  113.  * @author Lakshmi Krishnamurthy
  114.  */

  115. public class CRQSettingsContainer20
  116. {
  117.     private static org.drip.measure.stochastic.LabelCorrelation s_CrossBucketCorrelation = null;

  118.     private static final java.util.Map<java.lang.Integer, org.drip.simm.credit.CRBucket> s_BucketMap = new
  119.         java.util.TreeMap<java.lang.Integer, org.drip.simm.credit.CRBucket>();

  120.     private static final boolean SetUpCrossBucketCorrelation()
  121.     {
  122.         java.util.List<java.lang.String> bucketList = new java.util.ArrayList<java.lang.String>();

  123.         bucketList.add ("1");

  124.         bucketList.add ("2");

  125.         bucketList.add ("3");

  126.         bucketList.add ("4");

  127.         bucketList.add ("5");

  128.         bucketList.add ("6");

  129.         bucketList.add ("7");

  130.         bucketList.add ("8");

  131.         bucketList.add ("9");

  132.         bucketList.add ("10");

  133.         bucketList.add ("11");

  134.         bucketList.add ("12");

  135.         try
  136.         {
  137.             s_CrossBucketCorrelation = new org.drip.measure.stochastic.LabelCorrelation (
  138.                 bucketList,
  139.                 new double[][]
  140.                 {
  141.                     {1.00, 0.42, 0.39, 0.39, 0.40, 0.38, 0.39, 0.34, 0.37, 0.39, 0.37, 0.31},
  142.                     {0.42, 1.00, 0.44, 0.45, 0.47, 0.45, 0.33, 0.40, 0.41, 0.44, 0.43, 0.47},
  143.                     {0.39, 0.44, 1.00, 0.43, 0.45, 0.43, 0.32, 0.35, 0.41, 0.42, 0.40, 0.36},
  144.                     {0.39, 0.45, 0.43, 1.00, 0.47, 0.44, 0.30, 0.34, 0.39, 0.43, 0.39, 0.36},
  145.                     {0.40, 0.47, 0.45, 0.47, 1.00, 0.47, 0.31, 0.35, 0.40, 0.44, 0.42, 0.37},
  146.                     {0.38, 0.45, 0.43, 0.44, 0.47, 1.00, 0.30, 0.34, 0.38, 0.40, 0.39, 0.38},
  147.                     {0.39, 0.33, 0.32, 0.30, 0.31, 0.30, 1.00, 0.28, 0.31, 0.31, 0.30, 0.26},
  148.                     {0.34, 0.40, 0.35, 0.34, 0.35, 0.34, 0.28, 1.00, 0.34, 0.35, 0.33, 0.30},
  149.                     {0.37, 0.41, 0.41, 0.39, 0.40, 0.38, 0.31, 0.34, 1.00, 0.40, 0.37, 0.32},
  150.                     {0.39, 0.44, 0.42, 0.43, 0.44, 0.40, 0.31, 0.35, 0.40, 1.00, 0.40, 0.35},
  151.                     {0.37, 0.43, 0.40, 0.39, 0.42, 0.39, 0.30, 0.33, 0.37, 0.40, 1.00, 0.34},
  152.                     {0.31, 0.37, 0.36, 0.36, 0.37, 0.38, 0.26, 0.30, 0.32, 0.35, 0.34, 1.00}
  153.                 }
  154.             );

  155.             return true;
  156.         }
  157.         catch (java.lang.Exception e)
  158.         {
  159.             e.printStackTrace();
  160.         }

  161.         return false;
  162.     }

  163.     /**
  164.      * Initial the Credit Qualifying Settings
  165.      *
  166.      * @return TRUE - The Credit Qualifying Settings successfully initialized
  167.      */

  168.     public static final boolean Init()
  169.     {
  170.         try
  171.         {
  172.             s_BucketMap.put (
  173.                 -1,
  174.                 new org.drip.simm.credit.CRBucket (
  175.                     -1,
  176.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_UNSPECIFIED,
  177.                     org.drip.simm.credit.SectorSystemics.RESIDUAL,
  178.                     238.
  179.                 )
  180.             );

  181.             s_BucketMap.put (
  182.                 1,
  183.                 new org.drip.simm.credit.CRBucket (
  184.                     1,
  185.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  186.                     org.drip.simm.credit.SectorSystemics.SOVEREIGNS,
  187.                     85.
  188.                 )
  189.             );

  190.             s_BucketMap.put (
  191.                 2,
  192.                 new org.drip.simm.credit.CRBucket (
  193.                     2,
  194.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  195.                     org.drip.simm.credit.SectorSystemics.FINANCIALS,
  196.                     85.
  197.                 )
  198.             );

  199.             s_BucketMap.put (
  200.                 3,
  201.                 new org.drip.simm.credit.CRBucket (
  202.                     3,
  203.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  204.                     org.drip.simm.credit.SectorSystemics.BASIC_MATERIALS,
  205.                     73.
  206.                 )
  207.             );

  208.             s_BucketMap.put (
  209.                 4,
  210.                 new org.drip.simm.credit.CRBucket (
  211.                     4,
  212.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  213.                     org.drip.simm.credit.SectorSystemics.CONSUMER,
  214.                     49.
  215.                 )
  216.             );

  217.             s_BucketMap.put (
  218.                 5,
  219.                 new org.drip.simm.credit.CRBucket (
  220.                     5,
  221.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  222.                     org.drip.simm.credit.SectorSystemics.TMT,
  223.                     48.
  224.                 )
  225.             );

  226.             s_BucketMap.put (
  227.                 6,
  228.                 new org.drip.simm.credit.CRBucket (
  229.                     6,
  230.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_INVESTMENT_GRADE,
  231.                     org.drip.simm.credit.SectorSystemics.LOCAL_SERVICES,
  232.                     43.
  233.                 )
  234.             );

  235.             s_BucketMap.put (
  236.                 7,
  237.                 new org.drip.simm.credit.CRBucket (
  238.                     7,
  239.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  240.                     org.drip.simm.credit.SectorSystemics.BASIC_MATERIALS,
  241.                     161.
  242.                 )
  243.             );

  244.             s_BucketMap.put (
  245.                 8,
  246.                 new org.drip.simm.credit.CRBucket (
  247.                     8,
  248.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  249.                     org.drip.simm.credit.SectorSystemics.FINANCIALS,
  250.                     238.
  251.                 )
  252.             );

  253.             s_BucketMap.put (
  254.                 9,
  255.                 new org.drip.simm.credit.CRBucket (
  256.                     9,
  257.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  258.                     org.drip.simm.credit.SectorSystemics.BASIC_MATERIALS,
  259.                     151.
  260.                 )
  261.             );

  262.             s_BucketMap.put (
  263.                 10,
  264.                 new org.drip.simm.credit.CRBucket (
  265.                     10,
  266.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  267.                     org.drip.simm.credit.SectorSystemics.CONSUMER,
  268.                     210.
  269.                 )
  270.             );

  271.             s_BucketMap.put (
  272.                 11,
  273.                 new org.drip.simm.credit.CRBucket (
  274.                     11,
  275.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  276.                     org.drip.simm.credit.SectorSystemics.TMT,
  277.                     141.
  278.                 )
  279.             );

  280.             s_BucketMap.put (
  281.                 12,
  282.                 new org.drip.simm.credit.CRBucket (
  283.                     12,
  284.                     org.drip.simm.credit.CRSystemics.CREDIT_QUALITY_HIGH_YIELD,
  285.                     org.drip.simm.credit.SectorSystemics.LOCAL_SERVICES,
  286.                     102.
  287.                 )
  288.             );
  289.         }
  290.         catch (java.lang.Exception e)
  291.         {
  292.             e.printStackTrace();

  293.             return false;
  294.         }

  295.         return SetUpCrossBucketCorrelation();
  296.     }

  297.     /**
  298.      * Retrieve the Standard ISDA Credit Tenor Set
  299.      *
  300.      * @return The Standard ISDA Credit Tenor Set
  301.      */

  302.     public static final java.util.Set<java.lang.String> TenorSet()
  303.     {
  304.         java.util.Set<java.lang.String> tenorSet = new java.util.HashSet<java.lang.String>();

  305.         tenorSet.add ("1Y");

  306.         tenorSet.add ("2Y");

  307.         tenorSet.add ("3Y");

  308.         tenorSet.add ("5Y");

  309.         tenorSet.add ("10Y");

  310.         return tenorSet;
  311.     }

  312.     /**
  313.      * Retrieve the Set of Bucket Indexes available
  314.      *
  315.      * @return The Set of Bucket Indexes available
  316.      */

  317.     public static final java.util.Set<java.lang.Integer> BucketSet()
  318.     {
  319.         return s_BucketMap.keySet();
  320.     }

  321.     /**
  322.      * Indicate if the Bucket denoted by the Number is available
  323.      *
  324.      * @param bucketNumber The Bucket Number
  325.      *
  326.      * @return TRUE - The Bucket denoted by the Number is available
  327.      */

  328.     public static final boolean ContainsBucket (
  329.         final int bucketNumber)
  330.     {
  331.         return s_BucketMap.containsKey (bucketNumber);
  332.     }

  333.     /**
  334.      * Retrieve the Bucket denoted by the Number
  335.      *
  336.      * @param bucketNumber The Bucket Number
  337.      *
  338.      * @return The Bucket denoted by the Number
  339.      */

  340.     public static final org.drip.simm.credit.CRBucket Bucket (
  341.         final int bucketNumber)
  342.     {
  343.         return ContainsBucket (bucketNumber) ? s_BucketMap.get (bucketNumber) : null;
  344.     }

  345.     /**
  346.      * Retrieve the Cross Bucket Correlation
  347.      *
  348.      * @return The Cross Bucket Correlation
  349.      */

  350.     public static final org.drip.measure.stochastic.LabelCorrelation CrossBucketCorrelation()
  351.     {
  352.         return s_CrossBucketCorrelation;
  353.     }

  354.     /**
  355.      * Retrieve the Bucket Map
  356.      *
  357.      * @return The Bucket Map
  358.      */

  359.     public static final java.util.Map<java.lang.Integer, org.drip.simm.credit.CRBucket> BucketMap()
  360.     {
  361.         return s_BucketMap;
  362.     }
  363. }