SystemicScenarioDesignContextManager.java

  1. package org.drip.capital.env;

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

  74. /**
  75.  * <i>SystemicScenarioDesignContextManager</i> sets up the Credit Spread Event Container. The References are:
  76.  *
  77.  * <br><br>
  78.  *  <ul>
  79.  *      <li>
  80.  *          Bank for International Supervision(2005): Stress Testing at Major Financial Institutions: Survey
  81.  *              Results and Practice https://www.bis.org/publ/cgfs24.htm
  82.  *      </li>
  83.  *      <li>
  84.  *          Glasserman, P. (2004): <i>Monte Carlo Methods in Financial Engineering</i> <b>Springer</b>
  85.  *      </li>
  86.  *      <li>
  87.  *          Kupiec, P. H. (2000): Stress Tests and Risk Capital <i>Risk</i> <b>2 (4)</b> 27-39
  88.  *      </li>
  89.  *  </ul>
  90.  *
  91.  *  <br><br>
  92.  *  <ul>
  93.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  94.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/CapitalAnalyticsLibrary.md">Capital Analytics</a></li>
  95.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/capital/README.md">Basel Market Risk and Operational Capital</a></li>
  96.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/capital/env/README.md">Economic Risk Capital Parameter Factories</a></li>
  97.  *  </ul>
  98.  *
  99.  * @author Lakshmi Krishnamurthy
  100.  */

  101. public class SystemicScenarioDesignContextManager
  102. {
  103.     private static org.drip.capital.shell.CreditSpreadEventContainer s_CreditSpreadEventContainer = null;

  104.     /**
  105.      * Initialize the GSST Design Context Manager
  106.      *
  107.      * @return TRUE - The GSST Design Context Manager successfully initialized
  108.      */

  109.     public static final boolean Init()
  110.     {
  111.         s_CreditSpreadEventContainer = new org.drip.capital.shell.CreditSpreadEventContainer();

  112.         if (!s_CreditSpreadEventContainer.add (
  113.             org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  114.                 "NOV-2008",
  115.                  371.,
  116.                  -39.5,
  117.                 -197.,
  118.                  129.,
  119.                    7.8,
  120.                  -55.0,
  121.                  -28.5,
  122.                 org.drip.capital.systemicscenario.SystemicStressShockIndicator.Deflationary()
  123.             )
  124.         ))
  125.         {
  126.             return false;
  127.         }

  128.         try
  129.         {
  130.             if (!s_CreditSpreadEventContainer.add (
  131.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  132.                     "APR-1932",
  133.                     332.,
  134.                     -61.4,
  135.                      42.,
  136.                      96.,
  137.                     java.lang.Double.NaN,
  138.                      33.8,
  139.                     java.lang.Double.NaN,
  140.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  141.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  142.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  143.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED,
  144.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  145.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED
  146.                     )
  147.                 )
  148.             ))
  149.             {
  150.                 return false;
  151.             }

  152.             if (!s_CreditSpreadEventContainer.add (
  153.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  154.                     "JAN-1975",
  155.                      221.,
  156.                      -29.7,
  157.                      183.,
  158.                      -53.,
  159.                       -8.5,
  160.                      159.0,
  161.                       49.2,
  162.                     org.drip.capital.systemicscenario.SystemicStressShockIndicator.Inflationary()
  163.                 )
  164.             ))
  165.             {
  166.                 return false;
  167.             }

  168.             if (!s_CreditSpreadEventContainer.add (
  169.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  170.                     "APR-1938",
  171.                     180.,
  172.                     -40.5,
  173.                     -17.,
  174.                      30.,
  175.                     java.lang.Double.NaN,
  176.                      -4.2,
  177.                     java.lang.Double.NaN,
  178.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  179.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  180.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  181.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  182.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  183.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED
  184.                     )
  185.                 )
  186.             ))
  187.             {
  188.                 return false;
  189.             }

  190.             if (!s_CreditSpreadEventContainer.add (
  191.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  192.                     "AUG-1982",
  193.                      161.,
  194.                       -2.7,
  195.                     -256.,
  196.                      520.,
  197.                       -0.8,
  198.                       -6.0,
  199.                       -7.8,
  200.                     org.drip.capital.systemicscenario.SystemicStressShockIndicator.Deflationary()
  201.                 )
  202.             ))
  203.             {
  204.                 return false;
  205.             }

  206.             if (!s_CreditSpreadEventContainer.add (
  207.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  208.                     "APR-1980",
  209.                      147.,
  210.                        4.5,
  211.                      259.,
  212.                     -135.,
  213.                       -1.0,
  214.                      149.0,
  215.                        4.1,
  216.                     org.drip.capital.systemicscenario.SystemicStressShockIndicator.Inflationary()
  217.                 )
  218.             ))
  219.             {
  220.                 return false;
  221.             }

  222.             if (!s_CreditSpreadEventContainer.add (
  223.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  224.                     "NOV-1970",
  225.                      140.,
  226.                       -7.0,
  227.                     -106.,
  228.                      169.,
  229.                     java.lang.Double.NaN,
  230.                       -1.0,
  231.                        3.9,
  232.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  233.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  234.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  235.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  236.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  237.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP
  238.                     )
  239.                 )
  240.             ))
  241.             {
  242.                 return false;
  243.             }

  244.             if (!s_CreditSpreadEventContainer.add (
  245.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  246.                     "JAN-2001",
  247.                      125.,
  248.                       -2.0,
  249.                     -172.,
  250.                     -148.,
  251.                        8.1,
  252.                        9.0,
  253.                        3.2,
  254.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  255.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  256.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  257.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED,
  258.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  259.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP
  260.                     )
  261.                 )
  262.             ))
  263.             {
  264.                 return false;
  265.             }

  266.             if (!s_CreditSpreadEventContainer.add (
  267.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  268.                     "APR-1931",
  269.                      113.,
  270.                      -39.4,
  271.                      -11.,
  272.                     java.lang.Double.NaN,
  273.                     java.lang.Double.NaN,
  274.                      -45.4,
  275.                     java.lang.Double.NaN,
  276.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  277.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  278.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  279.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED,
  280.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  281.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED
  282.                     )
  283.                 )
  284.             ))
  285.             {
  286.                 return false;
  287.             }

  288.             if (!s_CreditSpreadEventContainer.add (
  289.                 org.drip.capital.systemicscenario.CreditSpreadEvent.Standard (
  290.                     "DEC-1966",
  291.                       94.,
  292.                      -13.1,
  293.                       28.,
  294.                      -36.,
  295.                     java.lang.Double.NaN,
  296.                        2.0,
  297.                     java.lang.Double.NaN,
  298.                     new org.drip.capital.systemicscenario.SystemicStressShockIndicator (
  299.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  300.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.DOWN,
  301.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  302.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UP,
  303.                         org.drip.capital.systemicscenario.SystemicStressShockIndicator.UNSPECIFIED
  304.                     )
  305.                 )
  306.             ))
  307.             {
  308.                 return false;
  309.             }
  310.         }
  311.         catch (java.lang.Exception e)
  312.         {
  313.             e.printStackTrace();

  314.             return false;
  315.         }

  316.         return true;
  317.     }

  318.     /**
  319.      * Retrieve the Built-in Credit Spread Event Container
  320.      *
  321.      * @return The Built-in Credit Spread Event Container
  322.      */

  323.     public static final org.drip.capital.shell.CreditSpreadEventContainer CreditSpreadEventContainer()
  324.     {
  325.         return s_CreditSpreadEventContainer;
  326.     }
  327. }