NotionalSetting.java

  1. package org.drip.product.params;

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

  82. /**
  83.  * <i>NotionalSetting</i> contains the product's notional schedule and the amount. It also incorporates hints
  84.  * on how the notional factors are to be interpreted - off of the original or the current notional. Further
  85.  * flags tell whether the notional factor is to be applied at the start/end/average of the coupon period. It
  86.  * exports serialization into and de-serialization out of byte arrays.
  87.  *
  88.  * <br><br>
  89.  *  <ul>
  90.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  91.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  92.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/README.md">Product Components/Baskets for Credit, FRA, FX, Govvie, Rates, and Option AssetClasses</a></li>
  93.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/params/README.md">Fixed Income Product Customization Parameters</a></li>
  94.  *  </ul>
  95.  * <br><br>
  96.  *
  97.  * @author Lakshmi Krishnamurthy
  98.  */

  99. public class NotionalSetting implements org.drip.product.params.Validatable {

  100.     /**
  101.      * Period amortization proxies to the period start factor
  102.      */

  103.     public static final int PERIOD_AMORT_AT_START = 1;

  104.     /**
  105.      * Period amortization proxies to the period end factor
  106.      */

  107.     public static final int PERIOD_AMORT_AT_END = 2;

  108.     /**
  109.      * Period amortization proxies to the period effective factor
  110.      */

  111.     public static final int PERIOD_AMORT_EFFECTIVE = 3;

  112.     private boolean _bPriceOffOriginalNotional = false;
  113.     private java.lang.String _strDenominationCurrency = "";
  114.     private double _dblNotionalAmount = java.lang.Double.NaN;
  115.     private int _iPeriodAmortizationMode = PERIOD_AMORT_AT_START;
  116.     private org.drip.numerical.common.Array2D _fsOutstanding = null;

  117.     /**
  118.      * Construct the NotionalSetting from the notional schedule and the amount.
  119.      *
  120.      * @param fsOutstanding Outstanding Factor Schedule
  121.      * @param dblNotionalAmount Notional Amount
  122.      * @param strDenominationCurrency The Currency of Denomination
  123.      * @param iPeriodAmortizationMode Period Amortization Proxy Mode
  124.      * @param bPriceOffOriginalNotional Indicates whether the price is based off of the original notional
  125.      */

  126.     public NotionalSetting (
  127.         final double dblNotionalAmount,
  128.         final java.lang.String strDenominationCurrency,
  129.         final org.drip.numerical.common.Array2D fsOutstanding,
  130.         final int iPeriodAmortizationMode,
  131.         final boolean bPriceOffOriginalNotional)
  132.     {
  133.         _fsOutstanding = fsOutstanding;
  134.         _dblNotionalAmount = dblNotionalAmount;
  135.         _iPeriodAmortizationMode = iPeriodAmortizationMode;
  136.         _strDenominationCurrency = strDenominationCurrency;
  137.         _bPriceOffOriginalNotional = bPriceOffOriginalNotional;
  138.     }

  139.     @Override public boolean validate()
  140.     {
  141.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblNotionalAmount) || null ==
  142.             _strDenominationCurrency || _strDenominationCurrency.isEmpty())
  143.             return false;

  144.         if (null == _fsOutstanding) _fsOutstanding = org.drip.numerical.common.Array2D.BulletSchedule();

  145.         return true;
  146.     }

  147.     /**
  148.      * Retrieve the Notional Amount
  149.      *
  150.      * @return The Notional Amount
  151.      */

  152.     public double notionalAmount()
  153.     {
  154.         return _dblNotionalAmount;
  155.     }

  156.     /**
  157.      * Retrieve "Price Off Of Original Notional" Flag
  158.      *
  159.      * @return TRUE - Price Quote is based off of the original notional
  160.      */

  161.     public boolean priceOffOfOriginalNotional()
  162.     {
  163.         return _bPriceOffOriginalNotional;
  164.     }

  165.     /**
  166.      * Retrieve the Period Amortization Mode
  167.      *
  168.      * @return The Period Amortization Mode
  169.      */

  170.     public int periodAmortizationMode()
  171.     {
  172.         return _iPeriodAmortizationMode;
  173.     }

  174.     /**
  175.      * Retrieve the Outstanding Factor Schedule
  176.      *
  177.      * @return The Outstanding Factor Schedule
  178.      */

  179.     public org.drip.numerical.common.Array2D outstandingFactorSchedule()
  180.     {
  181.         return _fsOutstanding;
  182.     }

  183.     /**
  184.      * Currency in which the Notional is specified
  185.      *
  186.      * @return The Currency of Denomination
  187.      */

  188.     public java.lang.String denominationCurrency()
  189.     {
  190.         return _strDenominationCurrency;
  191.     }
  192. }