RiskMeasureSensitivitySettingsIR.java

  1. package org.drip.simm.parameters;

  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>RiskMeasureSensitivitySettingsIR</i> holds the Settings that govern the Generation of the ISDA SIMM
  77.  * Bucket Sensitivities across Individual IR Class Risk Measure Buckets. 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/parameters/README.md">ISDA SIMM Risk Factor Parameters</a></li>
  111.  *  </ul>
  112.  * <br><br>
  113.  *
  114.  * @author Lakshmi Krishnamurthy
  115.  */

  116. public class RiskMeasureSensitivitySettingsIR
  117. {
  118.     private org.drip.measure.stochastic.LabelCorrelation _crossBucketCorrelation = null;
  119.     private java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  120.         _bucketSensitivitySettingsMap = null;

  121.     /**
  122.      * Generate the Standard ISDA 2.0 DELTA Instance of RiskMeasureSensitivitySettingsIR
  123.      *
  124.      * @param currencyList The Currency List
  125.      *
  126.      * @return The Standard ISDA 2.0 DELTA Instance of RiskMeasureSensitivitySettingsIR
  127.      */

  128.     public static final RiskMeasureSensitivitySettingsIR ISDA_DELTA_20 (
  129.         final java.util.List<java.lang.String> currencyList)
  130.     {
  131.         if (null == currencyList)
  132.         {
  133.             return null;
  134.         }

  135.         int currencyListSize = currencyList.size();

  136.         if (0 == currencyListSize)
  137.         {
  138.             return null;
  139.         }

  140.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  141.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  142.             bucketDeltaSettingsMap = new java.util.HashMap<java.lang.String,
  143.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  144.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  145.         {
  146.             java.lang.String currency = currencyList.get (currencyListIndex);

  147.             bucketDeltaSettingsMap.put (
  148.                 currency,
  149.                 org.drip.simm.parameters.BucketSensitivitySettingsIR.ISDA_DELTA_20 (currency)
  150.             );

  151.             for (int currencyListInnerIndex = 0;
  152.                 currencyListInnerIndex < currencyListSize;
  153.                 ++currencyListInnerIndex)
  154.             {
  155.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  156.                     currencyListIndex == currencyListInnerIndex ? 1. :
  157.                         org.drip.simm.rates.IRSystemics20.CROSS_CURRENCY_CORRELATION;
  158.             }
  159.         }

  160.         try
  161.         {
  162.             return new RiskMeasureSensitivitySettingsIR (
  163.                 bucketDeltaSettingsMap,
  164.                 new org.drip.measure.stochastic.LabelCorrelation (
  165.                     currencyList,
  166.                     crossCurrencyCorrelation
  167.                 )
  168.             );
  169.         }
  170.         catch (java.lang.Exception e)
  171.         {
  172.             e.printStackTrace();
  173.         }

  174.         return null;
  175.     }

  176.     /**
  177.      * Generate the Standard ISDA 2.1 DELTA Instance of RiskMeasureSensitivitySettingsIR
  178.      *
  179.      * @param currencyList The Currency List
  180.      *
  181.      * @return The Standard ISDA 2.1 DELTA Instance of RiskMeasureSensitivitySettingsIR
  182.      */

  183.     public static final RiskMeasureSensitivitySettingsIR ISDA_DELTA_21 (
  184.         final java.util.List<java.lang.String> currencyList)
  185.     {
  186.         if (null == currencyList)
  187.         {
  188.             return null;
  189.         }

  190.         int currencyListSize = currencyList.size();

  191.         if (0 == currencyListSize)
  192.         {
  193.             return null;
  194.         }

  195.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  196.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  197.             bucketDeltaSettingsMap = new java.util.HashMap<java.lang.String,
  198.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  199.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  200.         {
  201.             java.lang.String currency = currencyList.get (currencyListIndex);

  202.             bucketDeltaSettingsMap.put (
  203.                 currency,
  204.                 org.drip.simm.parameters.BucketSensitivitySettingsIR.ISDA_DELTA_21 (currency)
  205.             );

  206.             for (int currencyListInnerIndex = 0;
  207.                 currencyListInnerIndex < currencyListSize;
  208.                 ++currencyListInnerIndex)
  209.             {
  210.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  211.                     currencyListIndex == currencyListInnerIndex ? 1. :
  212.                         org.drip.simm.rates.IRSystemics21.CROSS_CURRENCY_CORRELATION;
  213.             }
  214.         }

  215.         try
  216.         {
  217.             return new RiskMeasureSensitivitySettingsIR (
  218.                 bucketDeltaSettingsMap,
  219.                 new org.drip.measure.stochastic.LabelCorrelation (
  220.                     currencyList,
  221.                     crossCurrencyCorrelation
  222.                 )
  223.             );
  224.         }
  225.         catch (java.lang.Exception e)
  226.         {
  227.             e.printStackTrace();
  228.         }

  229.         return null;
  230.     }

  231.     /**
  232.      * Generate the Standard ISDA 2.0 VEGA Instance of RiskMeasureSensitivitySettingsIR
  233.      *
  234.      * @param currencyList The Currency List
  235.      *
  236.      * @return The Standard ISDA 2.0 VEGA Instance of RiskMeasureSensitivitySettingsIR
  237.      */

  238.     public static final RiskMeasureSensitivitySettingsIR ISDA_VEGA_20 (
  239.         final java.util.List<java.lang.String> currencyList)
  240.     {
  241.         if (null == currencyList)
  242.         {
  243.             return null;
  244.         }

  245.         int currencyListSize = currencyList.size();

  246.         if (0 == currencyListSize)
  247.         {
  248.             return null;
  249.         }

  250.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  251.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  252.             bucketVegaSettingsMap = new java.util.HashMap<java.lang.String,
  253.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  254.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  255.         {
  256.             java.lang.String currency = currencyList.get (currencyListIndex);

  257.             bucketVegaSettingsMap.put (
  258.                 currency,
  259.                 org.drip.simm.parameters.BucketVegaSettingsIR.ISDA_20 (currency)
  260.             );

  261.             for (int currencyListInnerIndex = 0;
  262.                 currencyListInnerIndex < currencyListSize;
  263.                 ++currencyListInnerIndex)
  264.             {
  265.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  266.                     currencyListIndex == currencyListInnerIndex ? 1. :
  267.                         org.drip.simm.rates.IRSystemics20.CROSS_CURRENCY_CORRELATION;
  268.             }
  269.         }

  270.         try
  271.         {
  272.             return new RiskMeasureSensitivitySettingsIR (
  273.                 bucketVegaSettingsMap,
  274.                 new org.drip.measure.stochastic.LabelCorrelation (
  275.                     currencyList,
  276.                     crossCurrencyCorrelation
  277.                 )
  278.             );
  279.         }
  280.         catch (java.lang.Exception e)
  281.         {
  282.             e.printStackTrace();
  283.         }

  284.         return null;
  285.     }

  286.     /**
  287.      * Generate the Standard ISDA 2.1 VEGA Instance of RiskMeasureSensitivitySettingsIR
  288.      *
  289.      * @param currencyList The Currency List
  290.      *
  291.      * @return The Standard ISDA 2.1 VEGA Instance of RiskMeasureSensitivitySettingsIR
  292.      */

  293.     public static final RiskMeasureSensitivitySettingsIR ISDA_VEGA_21 (
  294.         final java.util.List<java.lang.String> currencyList)
  295.     {
  296.         if (null == currencyList)
  297.         {
  298.             return null;
  299.         }

  300.         int currencyListSize = currencyList.size();

  301.         if (0 == currencyListSize)
  302.         {
  303.             return null;
  304.         }

  305.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  306.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  307.             bucketVegaSettingsMap = new java.util.HashMap<java.lang.String,
  308.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  309.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  310.         {
  311.             java.lang.String currency = currencyList.get (currencyListIndex);

  312.             bucketVegaSettingsMap.put (
  313.                 currency,
  314.                 org.drip.simm.parameters.BucketVegaSettingsIR.ISDA_21 (currency)
  315.             );

  316.             for (int currencyListInnerIndex = 0;
  317.                 currencyListInnerIndex < currencyListSize;
  318.                 ++currencyListInnerIndex)
  319.             {
  320.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  321.                     currencyListIndex == currencyListInnerIndex ? 1. :
  322.                         org.drip.simm.rates.IRSystemics21.CROSS_CURRENCY_CORRELATION;
  323.             }
  324.         }

  325.         try
  326.         {
  327.             return new RiskMeasureSensitivitySettingsIR (
  328.                 bucketVegaSettingsMap,
  329.                 new org.drip.measure.stochastic.LabelCorrelation (
  330.                     currencyList,
  331.                     crossCurrencyCorrelation
  332.                 )
  333.             );
  334.         }
  335.         catch (java.lang.Exception e)
  336.         {
  337.             e.printStackTrace();
  338.         }

  339.         return null;
  340.     }

  341.     /**
  342.      * Generate the Standard ISDA 2.0 CURVATURE Instance of RiskMeasureSensitivitySettingsIR
  343.      *
  344.      * @param currencyList The Currency List
  345.      *
  346.      * @return The Standard ISDA 2.0 CURVATURE Instance of RiskMeasureSensitivitySettingsIR
  347.      */

  348.     public static final RiskMeasureSensitivitySettingsIR ISDA_CURVATURE_20 (
  349.         final java.util.List<java.lang.String> currencyList)
  350.     {
  351.         if (null == currencyList)
  352.         {
  353.             return null;
  354.         }

  355.         int currencyListSize = currencyList.size();

  356.         if (0 == currencyListSize)
  357.         {
  358.             return null;
  359.         }

  360.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  361.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  362.             bucketCurvatureSettingsMap = new java.util.HashMap<java.lang.String,
  363.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  364.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  365.         {
  366.             java.lang.String currency = currencyList.get (currencyListIndex);

  367.             bucketCurvatureSettingsMap.put (
  368.                 currency,
  369.                 org.drip.simm.parameters.BucketCurvatureSettingsIR.ISDA_20 (currency)
  370.             );

  371.             for (int currencyListInnerIndex = 0;
  372.                 currencyListInnerIndex < currencyListSize;
  373.                 ++currencyListInnerIndex)
  374.             {
  375.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  376.                     currencyListIndex == currencyListInnerIndex ? 1. :
  377.                         org.drip.simm.rates.IRSystemics20.CROSS_CURRENCY_CORRELATION;
  378.             }
  379.         }

  380.         try
  381.         {
  382.             return new RiskMeasureSensitivitySettingsIR (
  383.                 bucketCurvatureSettingsMap,
  384.                 new org.drip.measure.stochastic.LabelCorrelation (
  385.                     currencyList,
  386.                     crossCurrencyCorrelation
  387.                 )
  388.             );
  389.         }
  390.         catch (java.lang.Exception e)
  391.         {
  392.             e.printStackTrace();
  393.         }

  394.         return null;
  395.     }

  396.     /**
  397.      * Generate the Standard ISDA 2.1 CURVATURE Instance of RiskMeasureSensitivitySettingsIR
  398.      *
  399.      * @param currencyList The Currency List
  400.      *
  401.      * @return The Standard ISDA 2.1 CURVATURE Instance of RiskMeasureSensitivitySettingsIR
  402.      */

  403.     public static final RiskMeasureSensitivitySettingsIR ISDA_CURVATURE_21 (
  404.         final java.util.List<java.lang.String> currencyList)
  405.     {
  406.         if (null == currencyList)
  407.         {
  408.             return null;
  409.         }

  410.         int currencyListSize = currencyList.size();

  411.         if (0 == currencyListSize)
  412.         {
  413.             return null;
  414.         }

  415.         double[][] crossCurrencyCorrelation = new double[currencyListSize][currencyListSize];

  416.         java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  417.             bucketCurvatureSettingsMap = new java.util.HashMap<java.lang.String,
  418.                 org.drip.simm.parameters.BucketSensitivitySettingsIR>();

  419.         for (int currencyListIndex = 0; currencyListIndex < currencyListSize; ++currencyListIndex)
  420.         {
  421.             java.lang.String currency = currencyList.get (currencyListIndex);

  422.             bucketCurvatureSettingsMap.put (
  423.                 currency,
  424.                 org.drip.simm.parameters.BucketCurvatureSettingsIR.ISDA_21 (currency)
  425.             );

  426.             for (int currencyListInnerIndex = 0;
  427.                 currencyListInnerIndex < currencyListSize;
  428.                 ++currencyListInnerIndex)
  429.             {
  430.                 crossCurrencyCorrelation[currencyListIndex][currencyListInnerIndex] =
  431.                     currencyListIndex == currencyListInnerIndex ? 1. :
  432.                         org.drip.simm.rates.IRSystemics21.CROSS_CURRENCY_CORRELATION;
  433.             }
  434.         }

  435.         try
  436.         {
  437.             return new RiskMeasureSensitivitySettingsIR (
  438.                 bucketCurvatureSettingsMap,
  439.                 new org.drip.measure.stochastic.LabelCorrelation (
  440.                     currencyList,
  441.                     crossCurrencyCorrelation
  442.                 )
  443.             );
  444.         }
  445.         catch (java.lang.Exception e)
  446.         {
  447.             e.printStackTrace();
  448.         }

  449.         return null;
  450.     }

  451.     /**
  452.      * RiskMeasureSensitivitySettingsIR Constructor
  453.      *
  454.      * @param bucketSensitivitySettingsMap The IR Bucket Sensitivity Settings Map
  455.      * @param crossBucketCorrelation The Cross Bucket Correlation
  456.      *
  457.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  458.      */

  459.     public RiskMeasureSensitivitySettingsIR (
  460.         final java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  461.             bucketSensitivitySettingsMap,
  462.         final org.drip.measure.stochastic.LabelCorrelation crossBucketCorrelation)
  463.         throws java.lang.Exception
  464.     {
  465.         if (null == (_bucketSensitivitySettingsMap = bucketSensitivitySettingsMap) ||
  466.                 0 == _bucketSensitivitySettingsMap.size() ||
  467.             null == (_crossBucketCorrelation = crossBucketCorrelation))
  468.         {
  469.             throw new java.lang.Exception ("RiskMeasureSensitivitySettingsIR Constructor => Invalid Inputs");
  470.         }
  471.     }

  472.     /**
  473.      * Retrieve the Cross Bucket Correlation
  474.      *
  475.      * @return The Cross Bucket Correlation
  476.      */

  477.     public org.drip.measure.stochastic.LabelCorrelation crossBucketCorrelation()
  478.     {
  479.         return _crossBucketCorrelation;
  480.     }

  481.     /**
  482.      * Retrieve the IR Bucket Sensitivity Settings Map
  483.      *
  484.      * @return The IR Bucket Sensitivity Settings Map
  485.      */

  486.     public java.util.Map<java.lang.String, org.drip.simm.parameters.BucketSensitivitySettingsIR>
  487.         bucketSensitivitySettingsMap()
  488.     {
  489.         return _bucketSensitivitySettingsMap;
  490.     }
  491. }