NodeStructure.java

  1. package org.drip.analytics.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>NodeStructure</i> exposes the stub that implements the latent state's Node Structure (e.g., a
  81.  * Deterministic Term Structure) - by Construction, this is expected to be non-local.
  82.  *
  83.  *  <br><br>
  84.  *  <ul>
  85.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  86.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  87.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/analytics/README.md">Date, Cash Flow, and Cash Flow Period Measure Generation Utilities</a></li>
  88.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/analytics/definition/README.md">Latent State Curves, Surfaces, Turns</a></li>
  89.  *  </ul>
  90.  *
  91.  * @author Lakshmi Krishnamurthy
  92.  */

  93. public abstract class NodeStructure implements org.drip.analytics.definition.Curve {
  94.     protected java.lang.String _strName = "";
  95.     protected java.lang.String _strCurrency = "";
  96.     protected int _iEpochDate = java.lang.Integer.MIN_VALUE;
  97.     protected org.drip.state.identifier.LatentStateLabel _label = null;

  98.     protected NodeStructure (
  99.         final int iEpochDate,
  100.         final org.drip.state.identifier.LatentStateLabel label,
  101.         final java.lang.String strCurrency)
  102.         throws java.lang.Exception
  103.     {
  104.         if (null == (_label = label) || null == (_strCurrency = strCurrency) || _strCurrency.isEmpty())
  105.             throw new java.lang.Exception ("NodeStructure ctr: Invalid Inputs");

  106.         _iEpochDate = iEpochDate;
  107.     }

  108.     @Override public org.drip.state.identifier.LatentStateLabel label()
  109.     {
  110.         return _label;
  111.     }

  112.     @Override public java.lang.String currency()
  113.     {
  114.         return _strCurrency;
  115.     }

  116.     @Override public org.drip.analytics.date.JulianDate epoch()
  117.     {
  118.         try {
  119.             return new org.drip.analytics.date.JulianDate (_iEpochDate);
  120.         } catch (java.lang.Exception e) {
  121.             e.printStackTrace();
  122.         }

  123.         return null;
  124.     }

  125.     @Override public boolean setCCIS (
  126.         final org.drip.analytics.input.CurveConstructionInputSet ccis)
  127.     {
  128.         return false;
  129.     }

  130.     @Override public org.drip.product.definition.CalibratableComponent[] calibComp()
  131.     {
  132.         return null;
  133.     }

  134.     @Override public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> manifestMeasure (
  135.         final java.lang.String strInstr)
  136.     {
  137.         return null;
  138.     }

  139.     @Override public org.drip.state.representation.LatentState parallelShiftManifestMeasure (
  140.         final java.lang.String strManifestMeasure,
  141.         final double dblShift)
  142.     {
  143.         return null;
  144.     }

  145.     @Override public org.drip.state.representation.LatentState shiftManifestMeasure (
  146.         final int iSpanIndex,
  147.         final java.lang.String strManifestMeasure,
  148.         final double dblShift)
  149.     {
  150.         return null;
  151.     }

  152.     @Override public org.drip.state.representation.LatentState customTweakManifestMeasure (
  153.         final java.lang.String strManifestMeasure,
  154.         final org.drip.param.definition.ManifestMeasureTweak rvtp)
  155.     {
  156.         return null;
  157.     }

  158.     @Override public org.drip.state.representation.LatentState parallelShiftQuantificationMetric (
  159.         final double dblShift)
  160.     {
  161.         return null;
  162.     }

  163.     @Override public org.drip.state.representation.LatentState customTweakQuantificationMetric (
  164.         final org.drip.param.definition.ManifestMeasureTweak rvtp)
  165.     {
  166.         return null;
  167.     }

  168.     /**
  169.      * Get the Market Node at the given Predictor Ordinate
  170.      *
  171.      * @param iPredictorOrdinate The Predictor Ordinate
  172.      *
  173.      * @return The Node evaluated from the Term Structure
  174.      *
  175.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  176.      */

  177.     public abstract double node (
  178.         final int iPredictorOrdinate)
  179.         throws java.lang.Exception;

  180.     /**
  181.      * Get the Market Node Derivative at the given Predictor Ordinate
  182.      *
  183.      * @param iPredictorOrdinate The Predictor Ordinate
  184.      * @param iOrder Order of the Derivative
  185.      *
  186.      * @return The Node Derivative evaluated from the Term Structure
  187.      *
  188.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  189.      */

  190.     public abstract double nodeDerivative (
  191.         final int iPredictorOrdinate,
  192.         final int iOrder)
  193.         throws java.lang.Exception;

  194.     /**
  195.      * Get the Market Node at the given Maturity
  196.      *
  197.      * @param dt The Julian Maturity Date
  198.      *
  199.      * @return The Node evaluated from the Term Structure
  200.      *
  201.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  202.      */

  203.     public double node (
  204.         final org.drip.analytics.date.JulianDate dt)
  205.         throws java.lang.Exception
  206.     {
  207.         if (null == dt) throw new java.lang.Exception ("NodeStructure::node => Invalid Inputs");

  208.         return node (dt.julian());
  209.     }

  210.     /**
  211.      * Get the Market Node at the given Maturity
  212.      *
  213.      * @param strTenor The Maturity Tenor
  214.      *
  215.      * @return The Node evaluated from the Term Structure
  216.      *
  217.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  218.      */

  219.     public double node (
  220.         final java.lang.String strTenor)
  221.         throws java.lang.Exception
  222.     {
  223.         if (null == strTenor || strTenor.isEmpty())
  224.             throw new java.lang.Exception ("NodeStructure::node => Invalid Inputs");

  225.         return node (epoch().addTenor (strTenor).julian());
  226.     }

  227.     /**
  228.      * Get the Market Node Derivative at the given Maturity
  229.      *
  230.      * @param dt The Julian Maturity Date
  231.      * @param iOrder Order of the Derivative
  232.      *
  233.      * @return The Node Derivative evaluated from the Term Structure
  234.      *
  235.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  236.      */

  237.     public double nodeDerivative (
  238.         final org.drip.analytics.date.JulianDate dt,
  239.         final int iOrder)
  240.         throws java.lang.Exception
  241.     {
  242.         if (null == dt) throw new java.lang.Exception ("TermStructure::nodeDerivative => Invalid Inputs");

  243.         return nodeDerivative (dt.julian(), iOrder);
  244.     }

  245.     /**
  246.      * Get the Market Node Derivative at the given Maturity
  247.      *
  248.      * @param strTenor The Maturity Tenor
  249.      * @param iOrder Order of the Derivative
  250.      *
  251.      * @return The Node Derivative evaluated from the Term Structure
  252.      *
  253.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  254.      */

  255.     public double nodeDerivative (
  256.         final java.lang.String strTenor,
  257.         final int iOrder)
  258.         throws java.lang.Exception
  259.     {
  260.         if (null == strTenor || strTenor.isEmpty())
  261.             throw new java.lang.Exception ("TermStructure::nodeDerivative => Invalid Inputs");

  262.         return nodeDerivative (epoch().addTenor (strTenor).julian(), iOrder);
  263.     }
  264. }