FloaterIndex.java

  1. package org.drip.market.definition;

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

  79. /**
  80.  * <i>FloaterIndex</i> contains the definitions of the floating rate indexes of different jurisdictions.
  81.  *
  82.  *  <br><br>
  83.  *  <ul>
  84.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  85.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  86.  *      <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>
  87.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market/definition">IBOR, FX, Overnight Index Container</a></li>
  88.  *  </ul>
  89.  *
  90.  * @author Lakshmi Krishnamurthy
  91.  */

  92. abstract public class FloaterIndex {
  93.     private java.lang.String _strName = "";
  94.     private java.lang.String _strFamily = "";
  95.     private int _iAccrualCompoundingRule = -1;
  96.     private java.lang.String _strCalendar = "";
  97.     private java.lang.String _strCurrency = "";
  98.     private java.lang.String _strDayCount = "";

  99.     /**
  100.      * FloaterIndex Constructor
  101.      *
  102.      * @param strName Index Name
  103.      * @param strFamily Index Family
  104.      * @param strCurrency Index Currency
  105.      * @param strDayCount Index Day Count
  106.      * @param strCalendar Index Holiday Calendar
  107.      * @param iAccrualCompoundingRule Accrual Compounding Rule
  108.      *
  109.      * @throws java.lang.Exception Thrown if Inputs are invalid
  110.      */

  111.     public FloaterIndex (
  112.         final java.lang.String strName,
  113.         final java.lang.String strFamily,
  114.         final java.lang.String strCurrency,
  115.         final java.lang.String strDayCount,
  116.         final java.lang.String strCalendar,
  117.         final int iAccrualCompoundingRule)
  118.         throws java.lang.Exception
  119.     {
  120.         if (null == (_strName = strName) || _strName.isEmpty() || null == (_strFamily = strFamily) ||
  121.             _strFamily.isEmpty() || null == (_strCurrency = strCurrency) || _strCurrency.isEmpty() || null ==
  122.                 (_strDayCount = strDayCount) || _strDayCount.isEmpty() ||
  123.                     !org.drip.analytics.support.CompositePeriodBuilder.ValidateCompoundingRule
  124.                         (_iAccrualCompoundingRule = iAccrualCompoundingRule))
  125.             throw new java.lang.Exception ("FloaterIndex ctr: Invalid Inputs");

  126.         _strCalendar = strCalendar;
  127.     }

  128.     /**
  129.      * Retrieve the Index Name
  130.      *
  131.      * @return The Index Name
  132.      */

  133.     public java.lang.String name()
  134.     {
  135.         return _strName;
  136.     }

  137.     /**
  138.      * Retrieve the Index Family
  139.      *
  140.      * @return The Index Family
  141.      */

  142.     public java.lang.String family()
  143.     {
  144.         return _strFamily;
  145.     }

  146.     /**
  147.      * Retrieve the Index Holiday Calendar
  148.      *
  149.      * @return The Index Holiday Calendar
  150.      */

  151.     public java.lang.String calendar()
  152.     {
  153.         return _strCalendar;
  154.     }

  155.     /**
  156.      * Retrieve the Index Currency
  157.      *
  158.      * @return The Index Currency
  159.      */

  160.     public java.lang.String currency()
  161.     {
  162.         return _strCurrency;
  163.     }

  164.     /**
  165.      * Retrieve the Index Day Count Convention
  166.      *
  167.      * @return The Index Day Count Convention
  168.      */

  169.     public java.lang.String dayCount()
  170.     {
  171.         return _strDayCount;
  172.     }

  173.     /**
  174.      * Retrieve the Accrual Compounding Rule
  175.      *
  176.      * @return The Accrual Compounding Rule
  177.      */

  178.     public int accrualCompoundingRule()
  179.     {
  180.         return _iAccrualCompoundingRule;
  181.     }

  182.     /**
  183.      * Retrieve the Spot Lag DAP with Date Roll Previous
  184.      *
  185.      * @return The Spot Lag DAP with Date Roll Previous
  186.      */

  187.     public org.drip.analytics.daycount.DateAdjustParams spotLagDAPBackward()
  188.     {
  189.         return new org.drip.analytics.daycount.DateAdjustParams
  190.             (org.drip.analytics.daycount.Convention.DATE_ROLL_PREVIOUS, spotLag(), _strCalendar);
  191.     }

  192.     /**
  193.      * Retrieve the Spot Lag DAP with Date Roll Following
  194.      *
  195.      * @return The Spot Lag DAP with Date Roll Following
  196.      */

  197.     public org.drip.analytics.daycount.DateAdjustParams spotLagDAPForward()
  198.     {
  199.         return new org.drip.analytics.daycount.DateAdjustParams
  200.             (org.drip.analytics.daycount.Convention.DATE_ROLL_FOLLOWING, spotLag(), _strCalendar);
  201.     }

  202.     /**
  203.      * Retrieve the Index Spot Lag
  204.      *
  205.      * @return The Index Spot Lag
  206.      */

  207.     abstract public int spotLag();
  208. }