IRThresholdContainer21.java

  1. package org.drip.simm.rates;

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

  116. public class IRThresholdContainer21
  117. {
  118.     private static final java.util.Map<java.lang.String, java.lang.Integer> s_CurrencyThresholdMap = new
  119.         java.util.HashMap<java.lang.String, java.lang.Integer>();

  120.     private static final java.util.Map<java.lang.Integer, org.drip.simm.rates.IRThreshold> s_ThresholdMap =
  121.         new java.util.TreeMap<java.lang.Integer, org.drip.simm.rates.IRThreshold>();

  122.     private static final boolean SetupCurrencyMap()
  123.     {
  124.         s_CurrencyThresholdMap.put (
  125.             "USD",
  126.             2
  127.         );

  128.         s_CurrencyThresholdMap.put (
  129.             "EUR",
  130.             2
  131.         );

  132.         s_CurrencyThresholdMap.put (
  133.             "GBP",
  134.             2
  135.         );

  136.         s_CurrencyThresholdMap.put (
  137.             "AUD",
  138.             3
  139.         );

  140.         s_CurrencyThresholdMap.put (
  141.             "CAD",
  142.             3
  143.         );

  144.         s_CurrencyThresholdMap.put (
  145.             "CHF",
  146.             3
  147.         );

  148.         s_CurrencyThresholdMap.put (
  149.             "DKK",
  150.             3
  151.         );

  152.         s_CurrencyThresholdMap.put (
  153.             "HKD",
  154.             3
  155.         );

  156.         s_CurrencyThresholdMap.put (
  157.             "KRW",
  158.             3
  159.         );

  160.         s_CurrencyThresholdMap.put (
  161.             "NOK",
  162.             3
  163.         );

  164.         s_CurrencyThresholdMap.put (
  165.             "NZD",
  166.             3
  167.         );

  168.         s_CurrencyThresholdMap.put (
  169.             "SEK",
  170.             3
  171.         );

  172.         s_CurrencyThresholdMap.put (
  173.             "SGD",
  174.             3
  175.         );

  176.         s_CurrencyThresholdMap.put (
  177.             "TWD",
  178.             3
  179.         );

  180.         s_CurrencyThresholdMap.put (
  181.             "JPY",
  182.             4
  183.         );

  184.         return true;
  185.     }

  186.     /**
  187.      * Initialize the Container
  188.      *
  189.      * @return TRUE - The Container successfully Initialized
  190.      */

  191.     public static final boolean Init()
  192.     {
  193.         try
  194.         {
  195.             s_ThresholdMap.put (
  196.                 1,
  197.                 new org.drip.simm.rates.IRThreshold (
  198.                     new org.drip.simm.rates.CurrencyRiskGroup (
  199.                         org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_HIGH,
  200.                         org.drip.simm.rates.IRSystemics.TRADE_FREQUENCY_LESS_WELL_TRADED,
  201.                         new java.lang.String[]
  202.                         {
  203.                             "Other"
  204.                         }
  205.                     ),
  206.                     new org.drip.simm.common.DeltaVegaThreshold (
  207.                         12.,
  208.                         120.
  209.                     )
  210.                 )
  211.             );

  212.             s_ThresholdMap.put (
  213.                 2,
  214.                 new org.drip.simm.rates.IRThreshold (
  215.                     new org.drip.simm.rates.CurrencyRiskGroup (
  216.                         org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_REGULAR,
  217.                         org.drip.simm.rates.IRSystemics.TRADE_FREQUENCY_WELL_TRADED,
  218.                         new java.lang.String[]
  219.                         {
  220.                             "USD",
  221.                             "EUR",
  222.                             "GBP"
  223.                         }
  224.                     ),
  225.                     new org.drip.simm.common.DeltaVegaThreshold (
  226.                         210.,
  227.                         2200.
  228.                     )
  229.                 )
  230.             );

  231.             s_ThresholdMap.put (
  232.                 3,
  233.                 new org.drip.simm.rates.IRThreshold (
  234.                     new org.drip.simm.rates.CurrencyRiskGroup (
  235.                         org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_REGULAR,
  236.                         org.drip.simm.rates.IRSystemics.TRADE_FREQUENCY_LESS_WELL_TRADED,
  237.                         new java.lang.String[]
  238.                         {
  239.                             "AUD",
  240.                             "CAD",
  241.                             "CHF",
  242.                             "DKK",
  243.                             "HKD",
  244.                             "KRW",
  245.                             "NOK",
  246.                             "NZD",
  247.                             "SEK",
  248.                             "SGD",
  249.                             "TWD"
  250.                         }
  251.                     ),
  252.                     new org.drip.simm.common.DeltaVegaThreshold (
  253.                         27.,
  254.                         190.
  255.                     )
  256.                 )
  257.             );

  258.             s_ThresholdMap.put (
  259.                 4,
  260.                 new org.drip.simm.rates.IRThreshold (
  261.                     new org.drip.simm.rates.CurrencyRiskGroup (
  262.                         org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_LOW,
  263.                         org.drip.simm.rates.IRSystemics.TRADE_FREQUENCY_WELL_TRADED,
  264.                         new java.lang.String[]
  265.                         {
  266.                             "JPY"
  267.                         }
  268.                     ),
  269.                     new org.drip.simm.common.DeltaVegaThreshold (
  270.                         170.,
  271.                         770.
  272.                     )
  273.                 )
  274.             );
  275.         }
  276.         catch (java.lang.Exception e)
  277.         {
  278.             e.printStackTrace();

  279.             return false;
  280.         }

  281.         return SetupCurrencyMap();
  282.     }

  283.     /**
  284.      * Retrieve the Interest Rate Threshold Container Bucket Index Set
  285.      *
  286.      * @return The Interest Rate Threshold Container Bucket Index Set
  287.      */

  288.     public static final java.util.Set<java.lang.Integer> IndexSet()
  289.     {
  290.         return s_ThresholdMap.keySet();
  291.     }

  292.     /**
  293.      * Retrieve the Interest Rate Threshold Container Currency Set
  294.      *
  295.      * @return The Interest Rate Threshold Container Currency Set
  296.      */

  297.     public static final java.util.Set<java.lang.String> CurrencySet()
  298.     {
  299.         return s_CurrencyThresholdMap.keySet();
  300.     }

  301.     /**
  302.      * Indicate if the Entry denoted by the Number is available as an Interest Rate Threshold
  303.      *
  304.      * @param groupNumber The Group Number
  305.      *
  306.      * @return TRUE - The Entry denoted by the Number is available as an Interest Rate Threshold
  307.      */

  308.     public static final boolean ContainsThreshold (
  309.         final int groupNumber)
  310.     {
  311.         return s_ThresholdMap.containsKey (groupNumber);
  312.     }

  313.     /**
  314.      * Indicate if the Currency is available as an Interest Rate Threshold
  315.      *
  316.      * @param currency The Currency
  317.      *
  318.      * @return TRUE - The Currency is available as an Interest Rate Threshold
  319.      */

  320.     public static final boolean ContainsThreshold (
  321.         final java.lang.String currency)
  322.     {
  323.         return s_CurrencyThresholdMap.containsKey (currency);
  324.     }

  325.     /**
  326.      * Retrieve the Interest Rate Threshold denoted by the Currency
  327.      *
  328.      * @param currency The Currency
  329.      *
  330.      * @return The Interest Rate Threshold
  331.      */

  332.     public static final org.drip.simm.rates.IRThreshold Threshold (
  333.         final java.lang.String currency)
  334.     {
  335.         return ContainsThreshold (currency) ? s_ThresholdMap.get (s_CurrencyThresholdMap.get (currency)) :
  336.             s_ThresholdMap.get (1);
  337.     }

  338.     /**
  339.      * Retrieve the Interest Rate Threshold denoted by the Group Number
  340.      *
  341.      * @param groupNumber The Group Number
  342.      *
  343.      * @return The Interest Rate Threshold
  344.      */

  345.     public static final org.drip.simm.rates.IRThreshold Threshold (
  346.         final int groupNumber)
  347.     {
  348.         return ContainsThreshold (groupNumber) ? s_ThresholdMap.get (groupNumber) : null;
  349.     }

  350.     /**
  351.      * Retrieve the Currency Threshold Map
  352.      *
  353.      * @return The Currency Threshold Map
  354.      */

  355.     public static final java.util.Map<java.lang.String, java.lang.Integer> CurrencyThresholdMap()
  356.     {
  357.         return s_CurrencyThresholdMap;
  358.     }

  359.     /**
  360.      * Retrieve the Interest Rate Threshold Map
  361.      *
  362.      * @return The Interest Rate Threshold Map
  363.      */

  364.     public static final java.util.Map<java.lang.Integer, org.drip.simm.rates.IRThreshold> ThresholdMap()
  365.     {
  366.         return s_ThresholdMap;
  367.     }
  368. }