BucketSensitivitySettingsIR.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>BucketSensitivitySettingsIR</i> holds the Delta Risk Weights, Concentration Thresholds, and
  77.  * Cross-Tenor/Cross-Curve Correlations for each Currency Curve and its Tenor. 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 BucketSensitivitySettingsIR extends org.drip.simm.parameters.LiquiditySettings
  117. {
  118.     private double _crossCurveCorrelation = java.lang.Double.NaN;
  119.     private org.drip.measure.stochastic.LabelCorrelation _crossTenorCorrelation = null;
  120.     private java.util.Map<java.lang.String, java.lang.Double> _oisTenorRiskWeight = null;
  121.     private java.util.Map<java.lang.String, java.lang.Double> _primeTenorRiskWeight = null;
  122.     private java.util.Map<java.lang.String, java.lang.Double> _libor1MTenorRiskWeight = null;
  123.     private java.util.Map<java.lang.String, java.lang.Double> _libor3MTenorRiskWeight = null;
  124.     private java.util.Map<java.lang.String, java.lang.Double> _libor6MTenorRiskWeight = null;
  125.     private java.util.Map<java.lang.String, java.lang.Double> _libor12MTenorRiskWeight = null;
  126.     private java.util.Map<java.lang.String, java.lang.Double> _municipalTenorRiskWeight = null;

  127.     /**
  128.      * Construct the ISDA 2.0 Standard IR Delta Sensitivity Settings for the Currency
  129.      *
  130.      * @param currency Currency
  131.      *
  132.      * @return The ISDA 2.0 Standard IR Delta Sensitivity Settings for the Currency
  133.      */

  134.     public static final BucketSensitivitySettingsIR ISDA_DELTA_20 (
  135.         final java.lang.String currency)
  136.     {
  137.         org.drip.simm.rates.IRThreshold irThreshold = org.drip.simm.rates.IRThresholdContainer20.Threshold
  138.             (currency);

  139.         org.drip.simm.rates.IRWeight oisRiskWeight = org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  140.             currency,
  141.             org.drip.simm.rates.IRSystemics.SUB_CURVE_OIS
  142.         );

  143.         org.drip.simm.rates.IRWeight libor1MRiskWeight =
  144.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  145.                 currency,
  146.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_1M
  147.             );

  148.         org.drip.simm.rates.IRWeight libor3MRiskWeight =
  149.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  150.                 currency,
  151.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_3M
  152.             );

  153.         org.drip.simm.rates.IRWeight libor6MRiskWeight =
  154.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  155.                 currency,
  156.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_6M
  157.             );

  158.         org.drip.simm.rates.IRWeight libor12MRiskWeight =
  159.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  160.                 currency,
  161.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_12M
  162.             );

  163.         org.drip.simm.rates.IRWeight primeRiskWeight =
  164.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  165.                 currency,
  166.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_PRIME
  167.             );

  168.         org.drip.simm.rates.IRWeight municipalRiskWeight =
  169.             org.drip.simm.rates.IRSettingsContainer20.RiskWeight (
  170.                 currency,
  171.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_MUNICIPAL
  172.             );

  173.         try
  174.         {
  175.             return null == irThreshold ||
  176.                 null == libor1MRiskWeight ||
  177.                 null == libor1MRiskWeight ||
  178.                 null == libor3MRiskWeight ||
  179.                 null == libor6MRiskWeight ||
  180.                 null == libor12MRiskWeight ||
  181.                 null == primeRiskWeight ||
  182.                 null == municipalRiskWeight ? null : new BucketSensitivitySettingsIR (
  183.                     oisRiskWeight.tenorDelta(),
  184.                     libor1MRiskWeight.tenorDelta(),
  185.                     libor3MRiskWeight.tenorDelta(),
  186.                     libor6MRiskWeight.tenorDelta(),
  187.                     libor12MRiskWeight.tenorDelta(),
  188.                     primeRiskWeight.tenorDelta(),
  189.                     municipalRiskWeight.tenorDelta(),
  190.                     org.drip.simm.rates.IRSettingsContainer20.SingleCurveTenorCorrelation(),
  191.                     org.drip.simm.rates.IRSystemics20.SINGLE_CURRENCY_CROSS_CURVE_CORRELATION,
  192.                     irThreshold.deltaVega().delta()
  193.                 );
  194.         }
  195.         catch (java.lang.Exception e)
  196.         {
  197.             e.printStackTrace();
  198.         }

  199.         return null;
  200.     }

  201.     /**
  202.      * Construct the ISDA 2.1 Standard IR Delta Sensitivity Settings for the Currency
  203.      *
  204.      * @param currency Currency
  205.      *
  206.      * @return The ISDA 2.1 Standard IR Delta Sensitivity Settings for the Currency
  207.      */

  208.     public static final BucketSensitivitySettingsIR ISDA_DELTA_21 (
  209.         final java.lang.String currency)
  210.     {
  211.         org.drip.simm.rates.IRThreshold irThreshold = org.drip.simm.rates.IRThresholdContainer21.Threshold
  212.             (currency);

  213.         org.drip.simm.rates.IRWeight oisRiskWeight = org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  214.             currency,
  215.             org.drip.simm.rates.IRSystemics.SUB_CURVE_OIS
  216.         );

  217.         org.drip.simm.rates.IRWeight libor1MRiskWeight =
  218.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  219.                 currency,
  220.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_1M
  221.             );

  222.         org.drip.simm.rates.IRWeight libor3MRiskWeight =
  223.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  224.                 currency,
  225.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_3M
  226.             );

  227.         org.drip.simm.rates.IRWeight libor6MRiskWeight =
  228.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  229.                 currency,
  230.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_6M
  231.             );

  232.         org.drip.simm.rates.IRWeight libor12MRiskWeight =
  233.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  234.                 currency,
  235.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_LIBOR_12M
  236.             );

  237.         org.drip.simm.rates.IRWeight primeRiskWeight =
  238.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  239.                 currency,
  240.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_PRIME
  241.             );

  242.         org.drip.simm.rates.IRWeight municipalRiskWeight =
  243.             org.drip.simm.rates.IRSettingsContainer21.RiskWeight (
  244.                 currency,
  245.                 org.drip.simm.rates.IRSystemics.SUB_CURVE_MUNICIPAL
  246.             );

  247.         try
  248.         {
  249.             return null == irThreshold ||
  250.                 null == libor1MRiskWeight ||
  251.                 null == libor1MRiskWeight ||
  252.                 null == libor3MRiskWeight ||
  253.                 null == libor6MRiskWeight ||
  254.                 null == libor12MRiskWeight ||
  255.                 null == primeRiskWeight ||
  256.                 null == municipalRiskWeight ? null : new BucketSensitivitySettingsIR (
  257.                     oisRiskWeight.tenorDelta(),
  258.                     libor1MRiskWeight.tenorDelta(),
  259.                     libor3MRiskWeight.tenorDelta(),
  260.                     libor6MRiskWeight.tenorDelta(),
  261.                     libor12MRiskWeight.tenorDelta(),
  262.                     primeRiskWeight.tenorDelta(),
  263.                     municipalRiskWeight.tenorDelta(),
  264.                     org.drip.simm.rates.IRSettingsContainer21.SingleCurveTenorCorrelation(),
  265.                     org.drip.simm.rates.IRSystemics21.SINGLE_CURRENCY_CROSS_CURVE_CORRELATION,
  266.                     irThreshold.deltaVega().delta()
  267.                 );
  268.         }
  269.         catch (java.lang.Exception e)
  270.         {
  271.             e.printStackTrace();
  272.         }

  273.         return null;
  274.     }

  275.     /**
  276.      * BucketSensitivitySettingsIR Constructor
  277.      *
  278.      * @param oisTenorRiskWeight The OIS Tenor Risk Weight
  279.      * @param libor1MTenorRiskWeight The LIBOR 1M Tenor Risk Weight
  280.      * @param libor3MTenorRiskWeight The LIBOR 3M Tenor Risk Weight
  281.      * @param libor6MTenorRiskWeight The LIBOR 6M Tenor Risk Weight
  282.      * @param libor12MTenorRiskWeight The LIBOR 12M Tenor Risk Weight
  283.      * @param primeTenorRiskWeight The PRIME Tenor Risk Weight
  284.      * @param municipalTenorRiskWeight The MUNICIPAL Tenor Risk Weight
  285.      * @param crossTenorCorrelation Single Curve Cross-Tenor Correlation
  286.      * @param crossCurveCorrelation Cross Curve Correlation
  287.      * @param concentrationThreshold The Concentration Threshold
  288.      *
  289.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  290.      */

  291.     public BucketSensitivitySettingsIR (
  292.         final java.util.Map<java.lang.String, java.lang.Double> oisTenorRiskWeight,
  293.         final java.util.Map<java.lang.String, java.lang.Double> libor1MTenorRiskWeight,
  294.         final java.util.Map<java.lang.String, java.lang.Double> libor3MTenorRiskWeight,
  295.         final java.util.Map<java.lang.String, java.lang.Double> libor6MTenorRiskWeight,
  296.         final java.util.Map<java.lang.String, java.lang.Double> libor12MTenorRiskWeight,
  297.         final java.util.Map<java.lang.String, java.lang.Double> primeTenorRiskWeight,
  298.         final java.util.Map<java.lang.String, java.lang.Double> municipalTenorRiskWeight,
  299.         final org.drip.measure.stochastic.LabelCorrelation crossTenorCorrelation,
  300.         final double crossCurveCorrelation,
  301.         final double concentrationThreshold)
  302.         throws java.lang.Exception
  303.     {
  304.         super (concentrationThreshold);

  305.         if (null == (_oisTenorRiskWeight = oisTenorRiskWeight) ||
  306.             null == (_libor1MTenorRiskWeight = libor1MTenorRiskWeight) ||
  307.             null == (_libor3MTenorRiskWeight = libor3MTenorRiskWeight) ||
  308.             null == (_libor6MTenorRiskWeight = libor6MTenorRiskWeight) ||
  309.             null == (_libor12MTenorRiskWeight = libor12MTenorRiskWeight) ||
  310.             null == (_primeTenorRiskWeight = primeTenorRiskWeight) ||
  311.             null == (_municipalTenorRiskWeight = municipalTenorRiskWeight) ||
  312.             null == (_crossTenorCorrelation = crossTenorCorrelation) ||
  313.             !org.drip.numerical.common.NumberUtil.IsValid (_crossCurveCorrelation = crossCurveCorrelation) ||
  314.                 -1. > _crossCurveCorrelation || 1. < _crossCurveCorrelation)
  315.         {
  316.             throw new java.lang.Exception ("BucketSensitivitySettingsIR Constructor => Invalid Inputs");
  317.         }
  318.     }

  319.     /**
  320.      * Retrieve the OIS Tenor Risk Weight
  321.      *
  322.      * @return The OIS Tenor Risk Weight
  323.      */

  324.     public java.util.Map<java.lang.String, java.lang.Double> oisTenorRiskWeight()
  325.     {
  326.         return _oisTenorRiskWeight;
  327.     }

  328.     /**
  329.      * Retrieve the LIBOR 1M Tenor Risk Weight
  330.      *
  331.      * @return The LIBOR 1M Tenor Risk Weight
  332.      */

  333.     public java.util.Map<java.lang.String, java.lang.Double> libor1MTenorRiskWeight()
  334.     {
  335.         return _libor1MTenorRiskWeight;
  336.     }

  337.     /**
  338.      * Retrieve the LIBOR 3M Tenor Risk Weight
  339.      *
  340.      * @return The LIBOR 3M Tenor Risk Weight
  341.      */

  342.     public java.util.Map<java.lang.String, java.lang.Double> libor3MTenorRiskWeight()
  343.     {
  344.         return _libor3MTenorRiskWeight;
  345.     }

  346.     /**
  347.      * Retrieve the LIBOR 6M Tenor Risk Weight
  348.      *
  349.      * @return The LIBOR 6M Tenor Risk Weight
  350.      */

  351.     public java.util.Map<java.lang.String, java.lang.Double> libor6MTenorRiskWeight()
  352.     {
  353.         return _libor6MTenorRiskWeight;
  354.     }

  355.     /**
  356.      * Retrieve the LIBOR 12M Tenor Risk Weight
  357.      *
  358.      * @return The LIBOR 12M Tenor Risk Weight
  359.      */

  360.     public java.util.Map<java.lang.String, java.lang.Double> libor12MTenorRiskWeight()
  361.     {
  362.         return _libor12MTenorRiskWeight;
  363.     }

  364.     /**
  365.      * Retrieve the PRIME Tenor Risk Weight
  366.      *
  367.      * @return The PRIME Tenor Risk Weight
  368.      */

  369.     public java.util.Map<java.lang.String, java.lang.Double> primeTenorRiskWeight()
  370.     {
  371.         return _primeTenorRiskWeight;
  372.     }

  373.     /**
  374.      * Retrieve the MUNICIPAL Curve Tenor Risk Weight
  375.      *
  376.      * @return The MUNICIPAL Curve Tenor Risk Weight
  377.      */

  378.     public java.util.Map<java.lang.String, java.lang.Double> municipalTenorRiskWeight()
  379.     {
  380.         return _municipalTenorRiskWeight;
  381.     }

  382.     /**
  383.      * Retrieve the Cross Curve Correlation
  384.      *
  385.      * @return The Cross Curve Correlation
  386.      */

  387.     public double crossCurveCorrelation()
  388.     {
  389.         return _crossCurveCorrelation;
  390.     }

  391.     /**
  392.      * Retrieve the Single Curve Cross Tenor Correlation
  393.      *
  394.      * @return The Single Curve Cross Tenor Correlation
  395.      */

  396.     public org.drip.measure.stochastic.LabelCorrelation crossTenorCorrelation()
  397.     {
  398.         return _crossTenorCorrelation;
  399.     }
  400. }