ValuationParams.java

  1. package org.drip.param.valuation;

  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>ValuationParams</i> is the place-holder for the valuation parameters for a given product. It contains
  84.  * the valuation and the cash pay/settle dates, as well as the calendar. It also exposes a number of methods
  85.  * to construct standard valuation parameters.
  86.  *
  87.  *  <br><br>
  88.  *  <ul>
  89.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  90.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  91.  *      <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>
  92.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/valuation">Valuation Settlement and Valuation Customization Parameters</a></li>
  93.  *  </ul>
  94.  *
  95.  * @author Lakshmi Krishnamurthy
  96.  */

  97. public class ValuationParams {
  98.     private java.lang.String _strCalendar = "";
  99.     private int _iValueDate = java.lang.Integer.MIN_VALUE;
  100.     private int _iCashPayDate = java.lang.Integer.MIN_VALUE;

  101.     /**
  102.      * Create the valuation parameters object instance from the valuation date, the cash settle lag, and the
  103.      *  settle calendar.
  104.      *
  105.      * @param dtValue Valuation Date
  106.      * @param iCashSettleLag Cash settle lag
  107.      * @param strCalendar Calendar Set
  108.      * @param iAdjustMode The Adjustment Mode Flag
  109.      *
  110.      * @return Valuation Parameters instance
  111.      */

  112.     public static final ValuationParams Spot (
  113.         final org.drip.analytics.date.JulianDate dtValue,
  114.         final int iCashSettleLag,
  115.         final java.lang.String strCalendar,
  116.         final int iAdjustMode)
  117.     {
  118.         try {
  119.             return null == dtValue ? null : new ValuationParams (dtValue, new
  120.                 org.drip.analytics.date.JulianDate (org.drip.analytics.daycount.Convention.Adjust
  121.                     (dtValue.addDays (iCashSettleLag).julian(), strCalendar, iAdjustMode)), strCalendar);
  122.         } catch (java.lang.Exception e) {
  123.             e.printStackTrace();
  124.         }

  125.         return null;
  126.     }

  127.     /**
  128.      * Create the spot valuation parameters for the given valuation date (uses the T+0 settle)
  129.      *  
  130.      * @param iDate Valuation Date
  131.      *
  132.      * @return Valuation Parameters instance
  133.      */

  134.     public static final ValuationParams Spot (
  135.         final int iDate)
  136.     {
  137.         org.drip.analytics.date.JulianDate dtValue = new org.drip.analytics.date.JulianDate (iDate);

  138.         try {
  139.             return new ValuationParams (dtValue, dtValue, "");
  140.         } catch (java.lang.Exception e) {
  141.             e.printStackTrace();
  142.         }

  143.         return null;
  144.     }

  145.     /**
  146.      * Create the standard T+2B settle parameters for the given valuation date and calendar
  147.      *  
  148.      * @param dtValue Valuation Date
  149.      * @param strCalendar Settle Calendar
  150.      *
  151.      * @return Valuation Parameters instance
  152.      */

  153.     public static final ValuationParams Standard (
  154.         final org.drip.analytics.date.JulianDate dtValue,
  155.         final java.lang.String strCalendar)
  156.     {
  157.         return Spot (dtValue, 2, strCalendar, org.drip.analytics.daycount.Convention.DATE_ROLL_FOLLOWING);
  158.     }

  159.     /**
  160.      * Construct ValuationParams from the Valuation Date and the Cash Pay Date parameters
  161.      *
  162.      * @param dtValue Valuation Date
  163.      * @param dtCashPay Cash Pay Date
  164.      * @param strCalendar Calendar Set
  165.      *
  166.      * @throws java.lang.Exception Thrown if inputs are invalid
  167.      */

  168.     public ValuationParams (
  169.         final org.drip.analytics.date.JulianDate dtValue,
  170.         final org.drip.analytics.date.JulianDate dtCashPay,
  171.         final java.lang.String strCalendar)
  172.         throws java.lang.Exception
  173.     {
  174.         if (null == dtValue || null ==  dtCashPay)
  175.             throw new java.lang.Exception ("ValuationParams ctr: Invalid settle/Cash pay into Val Params!");

  176.         _iValueDate = dtValue.julian();

  177.         _iCashPayDate = dtCashPay.julian();

  178.         _strCalendar = strCalendar;
  179.     }

  180.     /**
  181.      * Retrieve the Valuation Date
  182.      *
  183.      * @return The Valuation Date
  184.      */

  185.     public int valueDate()
  186.     {
  187.         return _iValueDate;
  188.     }

  189.     /**
  190.      * Retrieve the Cash Pay Date
  191.      *
  192.      * @return The Cash Pay Date
  193.      */

  194.     public int cashPayDate()
  195.     {
  196.         return _iCashPayDate;
  197.     }

  198.     /**
  199.      * Retrieve the Calendar
  200.      *
  201.      * @return The Calendar
  202.      */

  203.     public java.lang.String calendar()
  204.     {
  205.         return _strCalendar;
  206.     }
  207. }