Criterion.java

  1. package org.drip.capital.systemicscenario;

  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>Criterion</i> contains the Specification Details of a Credit Spread Event Criterion. The References
  76.  *  are:
  77.  *
  78.  * <br><br>
  79.  *  <ul>
  80.  *      <li>
  81.  *          Bank for International Supervision(2005): Stress Testing at Major Financial Institutions: Survey
  82.  *              Results and Practice https://www.bis.org/publ/cgfs24.htm
  83.  *      </li>
  84.  *      <li>
  85.  *          Glasserman, P. (2004): <i>Monte Carlo Methods in Financial Engineering</i> <b>Springer</b>
  86.  *      </li>
  87.  *      <li>
  88.  *          Kupiec, P. H. (2000): Stress Tests and Risk Capital <i>Risk</i> <b>2 (4)</b> 27-39
  89.  *      </li>
  90.  *  </ul>
  91.  *
  92.  *  <br><br>
  93.  *  <ul>
  94.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  95.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/CapitalAnalyticsLibrary.md">Capital Analytics</a></li>
  96.  *      <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>
  97.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/capital/systemicscenario/README.md">Systemic Stress Scenario Design/Construction</a></li>
  98.  *  </ul>
  99.  *
  100.  * @author Lakshmi Krishnamurthy
  101.  */

  102. public class Criterion
  103. {
  104.     private java.lang.String _name = "";
  105.     private java.lang.String _description = "";
  106.     private double _value = java.lang.Double.NaN;
  107.     private int _unit = java.lang.Integer.MIN_VALUE;

  108.     /**
  109.      * Construct the Baa Spread Change Criterion
  110.      *
  111.      * @param baaSpreadChange Baa Spread Change in Basis Points
  112.      *
  113.      * @return Baa Spread Change Criterion
  114.      */

  115.     public static final Criterion BaaSpreadChange (
  116.         final double baaSpreadChange)
  117.     {
  118.         try
  119.         {
  120.             return new Criterion (
  121.                 "Baa Spread Change",
  122.                 "Baa Spread Change",
  123.                 org.drip.capital.systemicscenario.CriterionUnit.BASIS_POINT,
  124.                 baaSpreadChange
  125.             );
  126.         }
  127.         catch (java.lang.Exception e)
  128.         {
  129.             e.printStackTrace();
  130.         }

  131.         return null;
  132.     }

  133.     /**
  134.      * Construct the SnP 500 Annual Return Criterion
  135.      *
  136.      * @param snp500AnnualReturn SnP 500 Annual Return in Percentage
  137.      *
  138.      * @return SnP 500 Annual Return Criterion
  139.      */

  140.     public static final Criterion SnP500AnnualReturn (
  141.         final double snp500AnnualReturn)
  142.     {
  143.         try
  144.         {
  145.             return new Criterion (
  146.                 "SnP 500 Annual Return",
  147.                 "SnP 500 Annual Return",
  148.                 org.drip.capital.systemicscenario.CriterionUnit.PERCENT,
  149.                 snp500AnnualReturn
  150.             );
  151.         }
  152.         catch (java.lang.Exception e)
  153.         {
  154.             e.printStackTrace();
  155.         }

  156.         return null;
  157.     }

  158.     /**
  159.      * Construct the UST 5Y Absolute Change Criterion
  160.      *
  161.      * @param ust5YAbsoluteChange UST 5Y Absolute Change in Basis Points
  162.      *
  163.      * @return UST 5Y Absolute Change Criterion
  164.      */

  165.     public static final Criterion UST5YAbsoluteChange (
  166.         final double ust5YAbsoluteChange)
  167.     {
  168.         try
  169.         {
  170.             return new Criterion (
  171.                 "UST 5Y Absolute Change",
  172.                 "UST 5Y Absolute Change",
  173.                 org.drip.capital.systemicscenario.CriterionUnit.BASIS_POINT,
  174.                 ust5YAbsoluteChange
  175.             );
  176.         }
  177.         catch (java.lang.Exception e)
  178.         {
  179.             e.printStackTrace();
  180.         }

  181.         return null;
  182.     }

  183.     /**
  184.      * Construct the UST 10Y - 3M Absolute Change Criterion
  185.      *
  186.      * @param ust10YMinus3MAbsoluteChange UST 10Y - 3M Absolute Change in Basis Points
  187.      *
  188.      * @return UST 10Y - 3M Absolute Change Criterion
  189.      */

  190.     public static final Criterion UST10YMinus3MAbsoluteChange (
  191.         final double ust10YMinus3MAbsoluteChange)
  192.     {
  193.         try
  194.         {
  195.             return new Criterion (
  196.                 "UST 10Y - 3M Absolute Change",
  197.                 "UST 10Y - 3M Absolute Change",
  198.                 org.drip.capital.systemicscenario.CriterionUnit.BASIS_POINT,
  199.                 ust10YMinus3MAbsoluteChange
  200.             );
  201.         }
  202.         catch (java.lang.Exception e)
  203.         {
  204.             e.printStackTrace();
  205.         }

  206.         return null;
  207.     }

  208.     /**
  209.      * Construct the FX Rate Change Criterion
  210.      *
  211.      * @param fxRateChange FX Rate Change in Percentage
  212.      *
  213.      * @return FX Rate Change Criterion
  214.      */

  215.     public static final Criterion FXRateChange (
  216.         final double fxRateChange)
  217.     {
  218.         try
  219.         {
  220.             return new Criterion (
  221.                 "FX Rate Change",
  222.                 "FX Rate Change in USD/EUR. Prior to 1999 in German DEM/USD",
  223.                 org.drip.capital.systemicscenario.CriterionUnit.PERCENT,
  224.                 fxRateChange
  225.             );
  226.         }
  227.         catch (java.lang.Exception e)
  228.         {
  229.             e.printStackTrace();
  230.         }

  231.         return null;
  232.     }

  233.     /**
  234.      * Construct the WTI Spot Return Criterion
  235.      *
  236.      * @param wtiSpotReturn WTI Spot Return in Percentage
  237.      *
  238.      * @return WTI Spot Return Criterion
  239.      */

  240.     public static final Criterion WTISpotReturn (
  241.         final double wtiSpotReturn)
  242.     {
  243.         try
  244.         {
  245.             return new Criterion (
  246.                 "WTI Spot Return",
  247.                 "WTI Spot Return from 1946",
  248.                 org.drip.capital.systemicscenario.CriterionUnit.PERCENT,
  249.                 wtiSpotReturn
  250.             );
  251.         }
  252.         catch (java.lang.Exception e)
  253.         {
  254.             e.printStackTrace();
  255.         }

  256.         return null;
  257.     }

  258.     /**
  259.      * Construct the SnP GSCI Non-energy Commodity Index Criterion
  260.      *
  261.      * @param snpGSCINonEnergyCommodityIndex SnP GSCI Non-energy Commodity Index in Percentage
  262.      *
  263.      * @return SnP GSCI Non-energy Commodity Index Criterion
  264.      */

  265.     public static final Criterion SnPGSCINonEnergyCommodityIndex (
  266.         final double snpGSCINonEnergyCommodityIndex)
  267.     {
  268.         try
  269.         {
  270.             return new Criterion (
  271.                 "SnP GSCI Non-energy Commodity Index",
  272.                 "SnP GSCI Non-energy Commodity Index",
  273.                 org.drip.capital.systemicscenario.CriterionUnit.PERCENT,
  274.                 snpGSCINonEnergyCommodityIndex
  275.             );
  276.         }
  277.         catch (java.lang.Exception e)
  278.         {
  279.             e.printStackTrace();
  280.         }

  281.         return null;
  282.     }

  283.     /**
  284.      * Criterion Constructor
  285.      *
  286.      * @param name Criterion Name
  287.      * @param description Criterion Description
  288.      * @param unit Criterion Unit
  289.      * @param value Criterion Value
  290.      *
  291.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  292.      */

  293.     public Criterion (
  294.         final java.lang.String name,
  295.         final java.lang.String description,
  296.         final int unit,
  297.         final double value)
  298.         throws java.lang.Exception
  299.     {
  300.         if (null == (_name = name) || _name.isEmpty() ||
  301.             null == (_description = description) || _description.isEmpty() ||
  302.             -1 >= (_unit = unit))
  303.         {
  304.             throw new java.lang.Exception ("Criterion Constructor => Invalid Inputs");
  305.         }

  306.         _value = value;
  307.     }

  308.     /**
  309.      * Retrieve the Criterion Name
  310.      *
  311.      * @return The Criterion Name
  312.      */

  313.     public java.lang.String name()
  314.     {
  315.         return _name;
  316.     }

  317.     /**
  318.      * Retrieve the Criterion Description
  319.      *
  320.      * @return The Criterion Description
  321.      */

  322.     public java.lang.String description()
  323.     {
  324.         return _description;
  325.     }

  326.     /**
  327.      * Retrieve the Criterion Unit
  328.      *
  329.      * @return The Criterion Unit
  330.      */

  331.     public int unit()
  332.     {
  333.         return _unit;
  334.     }

  335.     /**
  336.      * Retrieve the Criterion Value
  337.      *
  338.      * @return The Criterion Value
  339.      */

  340.     public double value()
  341.     {
  342.         return _value;
  343.     }
  344. }