CreditIndexConventionContainer.java

  1. package org.drip.market.otc;

  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.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  11.  *
  12.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  13.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  14.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  15.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  16.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  17.  *      and computational support.
  18.  *  
  19.  *      https://lakshmidrip.github.io/DROP/
  20.  *  
  21.  *  DROP is composed of three modules:
  22.  *  
  23.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  24.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  25.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  26.  *
  27.  *  DROP Product Core implements libraries for the following:
  28.  *  - Fixed Income Analytics
  29.  *  - Loan Analytics
  30.  *  - Transaction Cost Analytics
  31.  *
  32.  *  DROP Portfolio Core implements libraries for the following:
  33.  *  - Asset Allocation Analytics
  34.  *  - Asset Liability Management Analytics
  35.  *  - Capital Estimation Analytics
  36.  *  - Exposure Analytics
  37.  *  - Margin Analytics
  38.  *  - XVA Analytics
  39.  *
  40.  *  DROP Computational Core implements libraries for the following:
  41.  *  - Algorithm Support
  42.  *  - Computation Support
  43.  *  - Function Analysis
  44.  *  - Model Validation
  45.  *  - Numerical Analysis
  46.  *  - Numerical Optimizer
  47.  *  - Spline Builder
  48.  *  - Statistical Learning
  49.  *
  50.  *  Documentation for DROP is Spread Over:
  51.  *
  52.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  53.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  54.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  55.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  56.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  57.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  58.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  59.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  60.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  61.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  62.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  63.  *
  64.  *  Licensed under the Apache License, Version 2.0 (the "License");
  65.  *      you may not use this file except in compliance with the License.
  66.  *  
  67.  *  You may obtain a copy of the License at
  68.  *      http://www.apache.org/licenses/LICENSE-2.0
  69.  *  
  70.  *  Unless required by applicable law or agreed to in writing, software
  71.  *      distributed under the License is distributed on an "AS IS" BASIS,
  72.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  73.  *  
  74.  *  See the License for the specific language governing permissions and
  75.  *      limitations under the License.
  76.  */

  77. /**
  78.  * <i>CreditIndexConventionContainer</i> contains the Conventions of the Credit Index of an OTC Index CDS
  79.  * Contract.
  80.  *
  81.  *  <br><br>
  82.  *  <ul>
  83.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  84.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  85.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market">Static Market Fields - the Definitions, the OTC/Exchange Traded Products, and Treasury Settings</a></li>
  86.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market/otc">OTC Dual Stream Option Container</a></li>
  87.  *  </ul>
  88.  *
  89.  * @author Lakshmi Krishnamurthy
  90.  */

  91. public class CreditIndexConventionContainer {
  92.     private static java.util.Map<java.lang.String, org.drip.market.otc.CreditIndexConvention>
  93.         _mapIndexConvention = null;

  94.     private static final boolean AddIndexConvention (
  95.         final java.lang.String strIndexType,
  96.         final java.lang.String strIndexSubType,
  97.         final java.lang.String strSeriesName,
  98.         final java.lang.String strTenor,
  99.         final java.lang.String strCurrency,
  100.         final org.drip.analytics.date.JulianDate dtEffective,
  101.         final org.drip.analytics.date.JulianDate dtMaturity,
  102.         final int iFreq,
  103.         final java.lang.String strDayCount,
  104.         final double dblFixedCoupon,
  105.         final double dblRecoveryRate,
  106.         final int iNumConstituent)
  107.     {
  108.         try {
  109.             org.drip.market.otc.CreditIndexConvention cic = new org.drip.market.otc.CreditIndexConvention
  110.                 (strIndexType, strIndexSubType, strSeriesName, strTenor, strCurrency, dtEffective,
  111.                     dtMaturity, iFreq, strDayCount, dblFixedCoupon, dblRecoveryRate, iNumConstituent);

  112.             _mapIndexConvention.put (cic.fullName(), cic);

  113.             return true;
  114.         } catch (java.lang.Exception e) {
  115.             e.printStackTrace();
  116.         }

  117.         return false;
  118.     }

  119.     private static final boolean AddCDXNAIG5YSeries (
  120.         final java.lang.String strSeriesName,
  121.         final org.drip.analytics.date.JulianDate dtEffective,
  122.         final org.drip.analytics.date.JulianDate dtMaturity)
  123.     {
  124.         return AddIndexConvention ("CDX.NA", "IG", strSeriesName, "5Y", "USD", dtEffective, dtMaturity, 4,
  125.             "Act/360", 0.01, 0.4, 125);
  126.     }

  127.     /**
  128.      * Initialize the Credit Index Conventions Container with the pre-set CDX Contract Settings
  129.      *
  130.      * @return TRUE - The Credit Index Conventions Container successfully initialized
  131.      */

  132.     public static final boolean Init()
  133.     {
  134.         if (null != _mapIndexConvention) return true;

  135.         _mapIndexConvention = new java.util.TreeMap<java.lang.String,
  136.             org.drip.market.otc.CreditIndexConvention>();

  137.         if (!AddCDXNAIG5YSeries ("S15", org.drip.analytics.date.DateUtil.CreateFromYMD (2010,
  138.             org.drip.analytics.date.DateUtil.SEPTEMBER, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  139.                 (2015, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  140.             return false;

  141.         if (!AddCDXNAIG5YSeries ("S16", org.drip.analytics.date.DateUtil.CreateFromYMD (2011,
  142.             org.drip.analytics.date.DateUtil.MARCH, 21), org.drip.analytics.date.DateUtil.CreateFromYMD
  143.                 (2016, org.drip.analytics.date.DateUtil.JUNE, 20)))
  144.             return false;

  145.         if (!AddCDXNAIG5YSeries ("S17", org.drip.analytics.date.DateUtil.CreateFromYMD (2011,
  146.             org.drip.analytics.date.DateUtil.SEPTEMBER, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  147.                 (2016, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  148.             return false;

  149.         if (!AddCDXNAIG5YSeries ("S18", org.drip.analytics.date.DateUtil.CreateFromYMD (2012,
  150.             org.drip.analytics.date.DateUtil.MARCH, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  151.                 (2017, org.drip.analytics.date.DateUtil.JUNE, 20)))
  152.             return false;

  153.         if (!AddCDXNAIG5YSeries ("S19", org.drip.analytics.date.DateUtil.CreateFromYMD (2012,
  154.             org.drip.analytics.date.DateUtil.SEPTEMBER, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  155.                 (2017, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  156.             return false;

  157.         if (!AddCDXNAIG5YSeries ("S20", org.drip.analytics.date.DateUtil.CreateFromYMD (2013,
  158.             org.drip.analytics.date.DateUtil.MARCH, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  159.                 (2018, org.drip.analytics.date.DateUtil.JUNE, 20)))
  160.             return false;

  161.         if (!AddCDXNAIG5YSeries ("S21", org.drip.analytics.date.DateUtil.CreateFromYMD (2013,
  162.             org.drip.analytics.date.DateUtil.SEPTEMBER, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  163.                 (2018, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  164.             return false;

  165.         if (!AddCDXNAIG5YSeries ("S22", org.drip.analytics.date.DateUtil.CreateFromYMD (2014,
  166.             org.drip.analytics.date.DateUtil.MARCH, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  167.                 (2019, org.drip.analytics.date.DateUtil.JUNE, 20)))
  168.             return false;

  169.         if (!AddCDXNAIG5YSeries ("S23", org.drip.analytics.date.DateUtil.CreateFromYMD (2014,
  170.             org.drip.analytics.date.DateUtil.SEPTEMBER, 22), org.drip.analytics.date.DateUtil.CreateFromYMD
  171.                 (2019, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  172.             return false;

  173.         if (!AddCDXNAIG5YSeries ("S24", org.drip.analytics.date.DateUtil.CreateFromYMD (2015,
  174.             org.drip.analytics.date.DateUtil.MARCH, 20), org.drip.analytics.date.DateUtil.CreateFromYMD
  175.                 (2020, org.drip.analytics.date.DateUtil.JUNE, 20)))
  176.             return false;

  177.         if (!AddCDXNAIG5YSeries ("S25", org.drip.analytics.date.DateUtil.CreateFromYMD (2015,
  178.             org.drip.analytics.date.DateUtil.SEPTEMBER, 21), org.drip.analytics.date.DateUtil.CreateFromYMD
  179.                 (2020, org.drip.analytics.date.DateUtil.DECEMBER, 20)))
  180.             return false;

  181.         if (!AddCDXNAIG5YSeries ("S26", org.drip.analytics.date.DateUtil.CreateFromYMD (2016,
  182.             org.drip.analytics.date.DateUtil.MARCH, 21), org.drip.analytics.date.DateUtil.CreateFromYMD
  183.                 (2021, org.drip.analytics.date.DateUtil.JUNE, 20)))
  184.             return false;

  185.         return true;
  186.     }

  187.     /**
  188.      * Retrieve the OTC Credit Index Convention Instance from the Full Index Name
  189.      *
  190.      * @param strCreditIndexFullName The Credit index Full Name
  191.      *
  192.      * @return The OTC Credit Index Convention Instance
  193.      */

  194.     public static final org.drip.market.otc.CreditIndexConvention ConventionFromFullName (
  195.         final java.lang.String strCreditIndexFullName)
  196.     {
  197.         return null == strCreditIndexFullName || !_mapIndexConvention.containsKey (strCreditIndexFullName) ?
  198.             null : _mapIndexConvention.get (strCreditIndexFullName);
  199.     }
  200. }