UnitCouponAccrualSetting.java

  1. package org.drip.param.period;

  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>UnitCouponAccrualSetting</i> contains the cash flow periods Coupon/Accrual details. Currently it holds
  81.  * the frequency, the calendar, the coupon/accrual day counts and the EOM adjustment flags, and flag
  82.  * indicating whether the coupon is computed from frequency.
  83.  *
  84.  *  <br><br>
  85.  *  <ul>
  86.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  87.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  88.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/README.md">Product Cash Flow, Valuation, Market, Pricing, and Quoting Parameters</a></li>
  89.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/period">Composite Composable Period Builder Settings</a></li>
  90.  *  </ul>
  91.  *
  92.  * @author Lakshmi Krishnamurthy
  93.  */

  94. public class UnitCouponAccrualSetting {
  95.     private int _iFreq = -1;
  96.     private int _iAccrualCompoundingRule = -1;
  97.     private java.lang.String _strCalendar = "";
  98.     private java.lang.String _strCouponDC = "";
  99.     private java.lang.String _strAccrualDC = "";
  100.     private boolean _bCouponDCFOffOfFreq = false;
  101.     private boolean _bCouponEOMAdjustment = false;
  102.     private boolean _bAccrualEOMAdjustment = false;

  103.     /**
  104.      * UnitCouponAccrualSetting constructor
  105.      *
  106.      * @param iFreq Frequency
  107.      * @param strCouponDC Coupon Day Count
  108.      * @param bCouponEOMAdjustment Coupon EOM Adjustment Flag
  109.      * @param strAccrualDC Accrual Day Count
  110.      * @param bAccrualEOMAdjustment Accrual EOM Adjustment Flag
  111.      * @param strCalendar Calendar
  112.      * @param bCouponDCFOffOfFreq Compute Full Coupon DCF from the Frequency
  113.      * @param iAccrualCompoundingRule The Accrual Compounding Rule
  114.      *
  115.      * @throws java.lang.Exception Thrown if Inputs are invalid
  116.      */

  117.     public UnitCouponAccrualSetting (
  118.         final int iFreq,
  119.         final java.lang.String strCouponDC,
  120.         final boolean bCouponEOMAdjustment,
  121.         final java.lang.String strAccrualDC,
  122.         final boolean bAccrualEOMAdjustment,
  123.         final java.lang.String strCalendar,
  124.         final boolean bCouponDCFOffOfFreq,
  125.         final int iAccrualCompoundingRule)
  126.         throws java.lang.Exception
  127.     {
  128.         if (0 >= (_iFreq = iFreq) || null == (_strCouponDC = strCouponDC) || _strCouponDC.isEmpty() || null
  129.             == (_strAccrualDC = strAccrualDC) || _strAccrualDC.isEmpty() || null == (_strCalendar =
  130.                 strCalendar) || _strCalendar.isEmpty() ||
  131.                     !org.drip.analytics.support.CompositePeriodBuilder.ValidateCompoundingRule
  132.                         (_iAccrualCompoundingRule = iAccrualCompoundingRule))
  133.             throw new java.lang.Exception ("UnitCouponAccrualSetting ctr: Invalid Inputs");

  134.         _bCouponDCFOffOfFreq = bCouponDCFOffOfFreq;
  135.         _bCouponEOMAdjustment = bCouponEOMAdjustment;
  136.         _bAccrualEOMAdjustment = bAccrualEOMAdjustment;
  137.     }

  138.     /**
  139.      * Retrieve the Coupon Frequency
  140.      *
  141.      * @return The Coupon Frequency
  142.      */

  143.     public int freq()
  144.     {
  145.         return _iFreq;
  146.     }

  147.     /**
  148.      * Retrieve the Coupon Day Count
  149.      *
  150.      * @return The Coupon Day Count
  151.      */

  152.     public java.lang.String couponDC()
  153.     {
  154.         return _strCouponDC;
  155.     }

  156.     /**
  157.      * Retrieve the Coupon EOM Adjustment Flag
  158.      *
  159.      * @return The Coupon EOM Adjustment Flag
  160.      */

  161.     public boolean couponEOMAdjustment()
  162.     {
  163.         return _bCouponEOMAdjustment;
  164.     }

  165.     /**
  166.      * Retrieve the Accrual Day Count
  167.      *
  168.      * @return The Accrual Day Count
  169.      */

  170.     public java.lang.String accrualDC()
  171.     {
  172.         return _strAccrualDC;
  173.     }

  174.     /**
  175.      * Retrieve the Accrual EOM Adjustment Flag
  176.      *
  177.      * @return The Accrual EOM Adjustment Flag
  178.      */

  179.     public boolean accrualEOMAdjustment()
  180.     {
  181.         return _bAccrualEOMAdjustment;
  182.     }

  183.     /**
  184.      * Retrieve the Flag indicating whether Coupon DCF is computed off of the DCF Flag
  185.      *
  186.      * @return TRUE - The Flag indicating whether Coupon DCF is computed off of the DCF Flag
  187.      */

  188.     public boolean couponDCFOffOfFreq()
  189.     {
  190.         return _bCouponDCFOffOfFreq;
  191.     }

  192.     /**
  193.      * Retrieve the Calendar
  194.      *
  195.      * @return The Calendar
  196.      */

  197.     public java.lang.String calendar()
  198.     {
  199.         return _strCalendar;
  200.     }

  201.     /**
  202.      * Retrieve the Accrual Compounding Rule
  203.      *
  204.      * @return The Accrual Compounding Rule
  205.      */

  206.     public int accrualCompoundingRule()
  207.     {
  208.         return _iAccrualCompoundingRule;
  209.     }
  210. }