IRSettingsContainer20.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>IRSettingsContainer20</i> holds the ISDA SIMM 2.0 Tenor Vertex Risk Weights/Correlations for Single IR
  77.  * Curves, Cross Currencies, and Inflation. 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 IRSettingsContainer20
  117. {
  118.     private static org.drip.simm.rates.IRWeight ZERO_RISK_WEIGHT = null;
  119.     private static org.drip.measure.stochastic.LabelCorrelation s_SingleCurveTenorCorrelation = null;

  120.     private static final java.util.Map<java.lang.String, org.drip.simm.rates.IRWeight> s_RiskWeightMap =
  121.         new java.util.HashMap<java.lang.String, org.drip.simm.rates.IRWeight>();

  122.     private static final boolean TenorCorrelation()
  123.     {
  124.         java.util.List<java.lang.String> tenorList = new java.util.ArrayList<java.lang.String>();

  125.         tenorList.add ("2W");

  126.         tenorList.add ("1M");

  127.         tenorList.add ("3M");

  128.         tenorList.add ("6M");

  129.         tenorList.add ("1Y");

  130.         tenorList.add ("2Y");

  131.         tenorList.add ("3Y");

  132.         tenorList.add ("5Y");

  133.         tenorList.add ("10Y");

  134.         tenorList.add ("15Y");

  135.         tenorList.add ("20Y");

  136.         tenorList.add ("30Y");

  137.         try
  138.         {
  139.             s_SingleCurveTenorCorrelation = new org.drip.measure.stochastic.LabelCorrelation (
  140.                 tenorList,
  141.                 new double[][]
  142.                 {
  143.                     {1.00, 0.99, 0.79, 0.67, 0.53, 0.42, 0.37, 0.30, 0.22, 0.18, 0.16, 0.12},
  144.                     {0.99, 1.00, 0.79, 0.67, 0.53, 0.42, 0.37, 0.30, 0.22, 0.18, 0.16, 0.12},
  145.                     {0.79, 0.79, 1.00, 0.85, 0.69, 0.57, 0.50, 0.42, 0.32, 0.25, 0.23, 0.20},
  146.                     {0.67, 0.67, 0.85, 1.00, 0.86, 0.76, 0.69, 0.59, 0.47, 0.40, 0.37, 0.32},
  147.                     {0.53, 0.53, 0.69, 0.86, 1.00, 0.93, 0.87, 0.77, 0.63, 0.57, 0.54, 0.50},
  148.                     {0.42, 0.42, 0.57, 0.76, 0.93, 1.00, 0.98, 0.90, 0.77, 0.70, 0.67, 0.63},
  149.                     {0.37, 0.37, 0.50, 0.69, 0.87, 0.98, 1.00, 0.96, 0.84, 0.78, 0.75, 0.71},
  150.                     {0.30, 0.30, 0.42, 0.59, 0.77, 0.90, 0.96, 1.00, 0.93, 0.89, 0.86, 0.82},
  151.                     {0.22, 0.22, 0.32, 0.47, 0.63, 0.77, 0.84, 0.93, 1.00, 0.98, 0.96, 0.94},
  152.                     {0.18, 0.18, 0.25, 0.40, 0.57, 0.70, 0.78, 0.89, 0.98, 1.00, 0.99, 0.98},
  153.                     {0.16, 0.16, 0.23, 0.37, 0.54, 0.67, 0.75, 0.86, 0.96, 0.99, 1.00, 0.99},
  154.                     {0.12, 0.12, 0.20, 0.32, 0.50, 0.63, 0.71, 0.82, 0.94, 0.98, 0.99, 1.00}
  155.                 }
  156.             );

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

  163.         return false;
  164.     }

  165.     /**
  166.      * Initialize the Interest Rate Weight Specification Container
  167.      *
  168.      * @return TRUE - The Interest Rate Weight Specification Container successfully initialized
  169.      */

  170.     public static final boolean Init()
  171.     {
  172.         org.drip.simm.rates.IRWeight lowVolatilityRiskWeight = null;
  173.         org.drip.simm.rates.IRWeight highVolatilityRiskWeight = null;
  174.         org.drip.simm.rates.IRWeight regularVolatilityRiskWeight = null;

  175.         java.util.Map<java.lang.String, java.lang.Double> zeroIRWeight = new
  176.             java.util.HashMap<java.lang.String, java.lang.Double>();

  177.         java.util.Map<java.lang.String, java.lang.Double> tenorDeltaWeightLowVolatility = new
  178.             java.util.HashMap<java.lang.String, java.lang.Double>();

  179.         java.util.Map<java.lang.String, java.lang.Double> tenorDeltaWeightHighVolatility = new
  180.             java.util.HashMap<java.lang.String, java.lang.Double>();

  181.         java.util.Map<java.lang.String, java.lang.Double> tenorDeltaWeightRegularVolatility = new
  182.             java.util.HashMap<java.lang.String, java.lang.Double>();

  183.         java.util.Map<java.lang.String, java.lang.Double> tenorVegaRiskWeight = new
  184.             java.util.HashMap<java.lang.String, java.lang.Double>();

  185.         tenorVegaRiskWeight.put (
  186.             "2W",
  187.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  188.         );

  189.         tenorVegaRiskWeight.put (
  190.             "1M",
  191.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  192.         );

  193.         tenorVegaRiskWeight.put (
  194.             "3M",
  195.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  196.         );

  197.         tenorVegaRiskWeight.put (
  198.             "6M",
  199.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  200.         );

  201.         tenorVegaRiskWeight.put (
  202.             "1Y",
  203.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  204.         );

  205.         tenorVegaRiskWeight.put (
  206.             "2Y",
  207.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  208.         );

  209.         tenorVegaRiskWeight.put (
  210.             "3Y",
  211.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  212.         );

  213.         tenorVegaRiskWeight.put (
  214.             "5Y",
  215.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  216.         );

  217.         tenorVegaRiskWeight.put (
  218.             "10Y",
  219.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  220.         );

  221.         tenorVegaRiskWeight.put (
  222.             "15Y",
  223.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  224.         );

  225.         tenorVegaRiskWeight.put (
  226.             "20Y",
  227.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  228.         );

  229.         tenorVegaRiskWeight.put (
  230.             "30Y",
  231.             org.drip.simm.rates.IRSystemics20.VEGA_RISK_WEIGHT
  232.         );

  233.         tenorDeltaWeightRegularVolatility.put (
  234.             "2W",
  235.             113.
  236.         );

  237.         tenorDeltaWeightRegularVolatility.put (
  238.             "1M",
  239.             113.
  240.         );

  241.         tenorDeltaWeightRegularVolatility.put (
  242.             "3M",
  243.             98.
  244.         );

  245.         tenorDeltaWeightRegularVolatility.put (
  246.             "6M",
  247.             69.
  248.         );

  249.         tenorDeltaWeightRegularVolatility.put (
  250.             "1Y",
  251.             56.
  252.         );

  253.         tenorDeltaWeightRegularVolatility.put (
  254.             "2Y",
  255.             52.
  256.         );

  257.         tenorDeltaWeightRegularVolatility.put (
  258.             "3Y",
  259.             51.
  260.         );

  261.         tenorDeltaWeightRegularVolatility.put (
  262.             "5Y",
  263.             51.
  264.         );

  265.         tenorDeltaWeightRegularVolatility.put (
  266.             "10Y",
  267.             51.
  268.         );

  269.         tenorDeltaWeightRegularVolatility.put (
  270.             "15Y",
  271.             53.
  272.         );

  273.         tenorDeltaWeightRegularVolatility.put (
  274.             "20Y",
  275.             56.
  276.         );

  277.         tenorDeltaWeightRegularVolatility.put (
  278.             "30Y",
  279.             64.
  280.         );

  281.         tenorDeltaWeightLowVolatility.put (
  282.             "2W",
  283.             21.
  284.         );

  285.         tenorDeltaWeightLowVolatility.put (
  286.             "1M",
  287.             21.
  288.         );

  289.         tenorDeltaWeightLowVolatility.put (
  290.             "3M",
  291.             10.
  292.         );

  293.         tenorDeltaWeightLowVolatility.put (
  294.             "6M",
  295.             11.
  296.         );

  297.         tenorDeltaWeightLowVolatility.put (
  298.             "1Y",
  299.             15.
  300.         );

  301.         tenorDeltaWeightLowVolatility.put (
  302.             "2Y",
  303.             20.
  304.         );

  305.         tenorDeltaWeightLowVolatility.put (
  306.             "3Y",
  307.             22.
  308.         );

  309.         tenorDeltaWeightLowVolatility.put (
  310.             "5Y",
  311.             21.
  312.         );

  313.         tenorDeltaWeightLowVolatility.put (
  314.             "10Y",
  315.             19.
  316.         );

  317.         tenorDeltaWeightLowVolatility.put (
  318.             "15Y",
  319.             20.
  320.         );

  321.         tenorDeltaWeightLowVolatility.put (
  322.             "20Y",
  323.             23.
  324.         );

  325.         tenorDeltaWeightLowVolatility.put (
  326.             "30Y",
  327.             27.
  328.         );

  329.         tenorDeltaWeightHighVolatility.put (
  330.             "2W",
  331.             93.
  332.         );

  333.         tenorDeltaWeightHighVolatility.put (
  334.             "1M",
  335.             93.
  336.         );

  337.         tenorDeltaWeightHighVolatility.put (
  338.             "3M",
  339.             90.
  340.         );

  341.         tenorDeltaWeightHighVolatility.put (
  342.             "6M",
  343.             94.
  344.         );

  345.         tenorDeltaWeightHighVolatility.put (
  346.             "1Y",
  347.             97.
  348.         );

  349.         tenorDeltaWeightHighVolatility.put (
  350.             "2Y",
  351.             103.
  352.         );

  353.         tenorDeltaWeightHighVolatility.put (
  354.             "3Y",
  355.             101.
  356.         );

  357.         tenorDeltaWeightHighVolatility.put (
  358.             "5Y",
  359.             103.
  360.         );

  361.         tenorDeltaWeightHighVolatility.put (
  362.             "10Y",
  363.             102.
  364.         );

  365.         tenorDeltaWeightHighVolatility.put (
  366.             "15Y",
  367.             101.
  368.         );

  369.         tenorDeltaWeightHighVolatility.put (
  370.             "20Y",
  371.             102.
  372.         );

  373.         tenorDeltaWeightHighVolatility.put (
  374.             "30Y",
  375.             101.
  376.         );

  377.         zeroIRWeight.put (
  378.             "2W",
  379.             0.
  380.         );

  381.         zeroIRWeight.put (
  382.             "1M",
  383.             0.
  384.         );

  385.         zeroIRWeight.put (
  386.             "3M",
  387.             0.
  388.         );

  389.         zeroIRWeight.put (
  390.             "6M",
  391.             0.
  392.         );

  393.         zeroIRWeight.put (
  394.             "1Y",
  395.             0.
  396.         );

  397.         zeroIRWeight.put (
  398.             "2Y",
  399.             0.
  400.         );

  401.         zeroIRWeight.put (
  402.             "3Y",
  403.             0.
  404.         );

  405.         zeroIRWeight.put (
  406.             "5Y",
  407.             0.
  408.         );

  409.         zeroIRWeight.put (
  410.             "10Y",
  411.             0.
  412.         );

  413.         zeroIRWeight.put (
  414.             "15Y",
  415.             0.
  416.         );

  417.         zeroIRWeight.put (
  418.             "20Y",
  419.             0.
  420.         );

  421.         zeroIRWeight.put (
  422.             "30Y",
  423.             0.
  424.         );

  425.         try
  426.         {
  427.             regularVolatilityRiskWeight = new org.drip.simm.rates.IRWeight (
  428.                 org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_REGULAR,
  429.                 tenorDeltaWeightRegularVolatility,
  430.                 tenorVegaRiskWeight
  431.             );

  432.             lowVolatilityRiskWeight = new org.drip.simm.rates.IRWeight (
  433.                 org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_LOW,
  434.                 tenorDeltaWeightLowVolatility,
  435.                 tenorVegaRiskWeight
  436.             );

  437.             highVolatilityRiskWeight = new org.drip.simm.rates.IRWeight (
  438.                 org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_HIGH,
  439.                 tenorDeltaWeightHighVolatility,
  440.                 tenorVegaRiskWeight
  441.             );

  442.             ZERO_RISK_WEIGHT = new org.drip.simm.rates.IRWeight (
  443.                 org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_NULL,
  444.                 zeroIRWeight,
  445.                 tenorVegaRiskWeight
  446.             );
  447.         }
  448.         catch (java.lang.Exception e)
  449.         {
  450.             e.printStackTrace();

  451.             return false;
  452.         }

  453.         s_RiskWeightMap.put (
  454.             "AUD",
  455.             regularVolatilityRiskWeight
  456.         );

  457.         s_RiskWeightMap.put (
  458.             "CAD",
  459.             regularVolatilityRiskWeight
  460.         );

  461.         s_RiskWeightMap.put (
  462.             "CHF",
  463.             regularVolatilityRiskWeight
  464.         );

  465.         s_RiskWeightMap.put (
  466.             "DKK",
  467.             regularVolatilityRiskWeight
  468.         );

  469.         s_RiskWeightMap.put (
  470.             "EUR",
  471.             regularVolatilityRiskWeight
  472.         );

  473.         s_RiskWeightMap.put (
  474.             "GBP",
  475.             regularVolatilityRiskWeight
  476.         );

  477.         s_RiskWeightMap.put (
  478.             "HKD",
  479.             regularVolatilityRiskWeight
  480.         );

  481.         s_RiskWeightMap.put (
  482.             "JPY",
  483.             lowVolatilityRiskWeight
  484.         );

  485.         s_RiskWeightMap.put (
  486.             "KRW",
  487.             regularVolatilityRiskWeight
  488.         );

  489.         s_RiskWeightMap.put (
  490.             "NOK",
  491.             regularVolatilityRiskWeight
  492.         );

  493.         s_RiskWeightMap.put (
  494.             "OTHER",
  495.             highVolatilityRiskWeight
  496.         );

  497.         s_RiskWeightMap.put (
  498.             "USD",
  499.             regularVolatilityRiskWeight
  500.         );

  501.         s_RiskWeightMap.put (
  502.             "SEK",
  503.             regularVolatilityRiskWeight
  504.         );

  505.         s_RiskWeightMap.put (
  506.             "SGD",
  507.             regularVolatilityRiskWeight
  508.         );

  509.         s_RiskWeightMap.put (
  510.             "TWD",
  511.             regularVolatilityRiskWeight
  512.         );

  513.         s_RiskWeightMap.put (
  514.             "USD",
  515.             regularVolatilityRiskWeight
  516.         );

  517.         return TenorCorrelation();
  518.     }

  519.     /**
  520.      * Retrieve the Standard ISDA Rates Tenor Set
  521.      *
  522.      * @return The Standard ISDA Rates Tenor Set
  523.      */

  524.     public static final java.util.Set<java.lang.String> TenorSet()
  525.     {
  526.         return s_RiskWeightMap.get ("USD").tenors();
  527.     }

  528.     /**
  529.      * Indicate if the Sub-Curve is supported for the specified Currency
  530.      *
  531.      * @param currency The Currency
  532.      * @param subCurve The sub-Curve Type
  533.      *
  534.      * @return TRUE - The Sub-Curve is supported for the specified Currency
  535.      */

  536.     public static final boolean SubCurveSupported (
  537.         final java.lang.String currency,
  538.         final java.lang.String subCurve)
  539.     {
  540.         if (null == currency || currency.isEmpty() || null == subCurve)
  541.         {
  542.             return false;
  543.         }

  544.         if (org.drip.simm.rates.IRSystemics.SUB_CURVE_OIS.equalsIgnoreCase (subCurve) ||
  545.             org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_1M.equalsIgnoreCase (subCurve) ||
  546.             org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_3M.equalsIgnoreCase (subCurve) ||
  547.             org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_6M.equalsIgnoreCase (subCurve) ||
  548.             org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_12M.equalsIgnoreCase (subCurve))
  549.         {
  550.             return true;
  551.         }

  552.         if (org.drip.simm.rates.IRSystemics.SUB_CURVE_PRIME.equalsIgnoreCase (subCurve) ||
  553.             org.drip.simm.rates.IRSystemics.SUB_CURVE_MUNICIPAL.equalsIgnoreCase (subCurve))
  554.         {
  555.             return "USD".equalsIgnoreCase (currency);
  556.         }

  557.         return false;
  558.     }

  559.     /**
  560.      * Retrieve the Set of all Available Currencies
  561.      *
  562.      * @return The Set of all Available Currencies
  563.      */

  564.     public static final java.util.Set<java.lang.String> CurrencySet()
  565.     {
  566.         return s_RiskWeightMap.keySet();
  567.     }

  568.     /**
  569.      * Retrieve the Set of Currencies for the specified Volatility Type
  570.      *
  571.      * @param volatilityType The Volatility Type
  572.      *
  573.      * @return The Set of Currencies for the specified Volatility Type
  574.      */

  575.     public static final java.util.Set<java.lang.String> VolatilityTypeCurrencySet (
  576.         final java.lang.String volatilityType)
  577.     {
  578.         if (null == volatilityType || volatilityType.isEmpty())
  579.         {
  580.             return null;
  581.         }

  582.         java.util.Set<java.lang.String> currencySet = new java.util.HashSet<java.lang.String>();

  583.         for (java.util.Map.Entry<java.lang.String, org.drip.simm.rates.IRWeight> irRiskWeightMapEntry :
  584.             s_RiskWeightMap.entrySet())
  585.         {
  586.             if (irRiskWeightMapEntry.getValue().volatilityType().equalsIgnoreCase (volatilityType))
  587.             {
  588.                 currencySet.add (irRiskWeightMapEntry.getKey());
  589.             }
  590.         }

  591.         return currencySet;
  592.     }

  593.     /**
  594.      * Retrieve the Regular Volatility Currency Set
  595.      *
  596.      * @return The Regular Volatility Currency Set
  597.      */

  598.     public static final java.util.Set<java.lang.String> RegularVolatilityCurrencySet()
  599.     {
  600.         return VolatilityTypeCurrencySet (org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_REGULAR);
  601.     }

  602.     /**
  603.      * Retrieve the Low Volatility Currency Set
  604.      *
  605.      * @return The Low Volatility Currency Set
  606.      */

  607.     public static final java.util.Set<java.lang.String> LowVolatilityCurrencySet()
  608.     {
  609.         return VolatilityTypeCurrencySet (org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_LOW);
  610.     }

  611.     /**
  612.      * Retrieve the High Volatility Currency Set
  613.      *
  614.      * @return The High Volatility Currency Set
  615.      */

  616.     public static final java.util.Set<java.lang.String> HighVolatilityCurrencySet()
  617.     {
  618.         return VolatilityTypeCurrencySet (org.drip.simm.rates.IRSystemics.VOLATILITY_TYPE_HIGH);
  619.     }

  620.     /**
  621.      * Indicate if the IR Risk Weight is available for the specified Currency
  622.      *
  623.      * @param currency The Currency
  624.      *
  625.      * @return TRUE - The IR Risk Weight is available for the specified Currency
  626.      */

  627.     public static final boolean ContainsRiskWeight (
  628.         final java.lang.String currency)
  629.     {
  630.         return null != currency && !currency.isEmpty() && s_RiskWeightMap.containsKey (currency);
  631.     }

  632.     /**
  633.      * Indicate if the IR Risk Weight is available for the specified Currency
  634.      *
  635.      * @param currency The Currency
  636.      * @param subCurve The sub-Curve Type
  637.      *
  638.      * @return TRUE - The IR Risk Weight is available for the specified Currency
  639.      */

  640.     public static final boolean ContainsRiskWeight (
  641.         final java.lang.String currency,
  642.         final java.lang.String subCurve)
  643.     {
  644.         return SubCurveSupported (
  645.             currency,
  646.             subCurve
  647.         ) && s_RiskWeightMap.containsKey (currency);
  648.     }

  649.     /**
  650.      * Retrieve the IR Risk Weight for the specified Currency
  651.      *
  652.      * @param currency The Currency
  653.      *
  654.      * @return The IR Risk Weight for the specified Currency
  655.      */

  656.     public static final org.drip.simm.rates.IRWeight RiskWeight (
  657.         final java.lang.String currency)
  658.     {
  659.         return ContainsRiskWeight (currency) ? s_RiskWeightMap.get (currency) : s_RiskWeightMap.get
  660.             ("OTHER");
  661.     }

  662.     /**
  663.      * Retrieve the IR Risk Weight for the specified Currency
  664.      *
  665.      * @param currency The Currency
  666.      * @param subCurve The sub-Curve Type
  667.      *
  668.      * @return The IR Risk Weight for the specified Currency
  669.      */

  670.     public static final org.drip.simm.rates.IRWeight RiskWeight (
  671.         final java.lang.String currency,
  672.         final java.lang.String subCurve)
  673.     {
  674.         if (!SubCurveSupported (
  675.             currency,
  676.             subCurve
  677.         ))
  678.         {
  679.             return ZERO_RISK_WEIGHT;
  680.         }

  681.         return ContainsRiskWeight (currency) ? s_RiskWeightMap.get (currency) : s_RiskWeightMap.get
  682.             ("OTHER");
  683.     }

  684.     /**
  685.      * Retrieve the Interest Rate Single Curve Tenor Correlation Instance
  686.      *
  687.      * @return The Interest Rate Single Curve Tenor Correlation Instance
  688.      */

  689.     public static final org.drip.measure.stochastic.LabelCorrelation SingleCurveTenorCorrelation()
  690.     {
  691.         return s_SingleCurveTenorCorrelation;
  692.     }

  693.     /**
  694.      * Retrieve the Interest Rate Risk Weight Term Structure based on the Volatility Type
  695.      *
  696.      * @return The Interest Rate Risk Weight Term Structure based on the Volatility Type
  697.      */

  698.     public static final java.util.Map<java.lang.String, org.drip.simm.rates.IRWeight> RiskWeight()
  699.     {
  700.         return s_RiskWeightMap;
  701.     }

  702.     /**
  703.      * Retrieve the Currency Pair Principal Co-variance Matrix
  704.      *
  705.      * @param currency1 Currency #1
  706.      * @param currency2 Currency #2
  707.      *
  708.      * @return The Currency Pair Principal Co-variance Matrix
  709.      */

  710.     public static final org.drip.simm.foundation.RiskGroupPrincipalCovariance CurrencyPairPrincipalCovariance (
  711.         final java.lang.String currency1,
  712.         final java.lang.String currency2)
  713.     {
  714.         if (null == currency1 || currency1.isEmpty() ||
  715.             null == currency2 || currency2.isEmpty())
  716.         {
  717.             return null;
  718.         }

  719.         org.drip.simm.rates.IRThreshold irThreshold1 = org.drip.simm.rates.IRThresholdContainer20.Threshold
  720.             (currency1);

  721.         org.drip.simm.rates.IRThreshold irThreshold2 = org.drip.simm.rates.IRThresholdContainer20.Threshold
  722.             (currency2);

  723.         if (null == irThreshold1 || null == irThreshold2)
  724.         {
  725.             return null;
  726.         }

  727.         return org.drip.simm.foundation.RiskGroupPrincipalCovariance.Standard (
  728.             s_SingleCurveTenorCorrelation.matrix(),
  729.             irThreshold1.currencyRiskGroup().volatilityType().equalsIgnoreCase (
  730.                 irThreshold2.currencyRiskGroup().volatilityType()
  731.             ) ? 1. : org.drip.simm.rates.IRSystemics20.SINGLE_CURRENCY_CROSS_CURVE_CORRELATION
  732.         );
  733.     }
  734. }