CalibratableComponent.java

  1. package org.drip.product.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.  * 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>CalibratableComponent</i> abstract class provides implementation of Component's calibration interface.
  84.  * It exposes stubs for getting/setting the component’s calibration code, generate calibrated measure values
  85.  * from the market inputs, and compute micro-Jacobians (QuoteDF and PVDF micro-Jacks).
  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/product/README.md">Product Components/Baskets for Credit, FRA, FX, Govvie, Rates, and Option AssetClasses</a></li>
  92.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/credit/README.md">Fixed Income Components/Baskets Definitions</a></li>
  93.  *  </ul>
  94.  * <br><br>
  95.  *
  96.  * @author Lakshmi Krishnamurthy
  97.  */

  98. public abstract class CalibratableComponent extends org.drip.product.definition.Component {

  99.     /**
  100.      * Return the primary code
  101.      *
  102.      * @return Primary Code
  103.      */

  104.     public abstract java.lang.String primaryCode();

  105.     /**
  106.      * Set the component's primary code
  107.      *
  108.      * @param strCode Primary Code
  109.      */

  110.     public abstract void setPrimaryCode (
  111.         final java.lang.String strCode);

  112.     /**
  113.      * Get the component's secondary codes
  114.      *
  115.      * @return Array of strings containing the secondary codes
  116.      */

  117.     public java.lang.String[] secondaryCode()
  118.     {
  119.         return new java.lang.String[] {primaryCode()};
  120.     }

  121.     /**
  122.      * Generate the Product Specific Calibration Quote Set
  123.      *
  124.      * @param aLSS Array of Latent State Specification
  125.      *
  126.      * @return The Product Specific Calibration Quote Set
  127.      */

  128.     public abstract org.drip.product.calib.ProductQuoteSet calibQuoteSet (
  129.         final org.drip.state.representation.LatentStateSpecification[] aLSS);

  130.     /**
  131.      * Generate a Map of the Calibration Measures
  132.      *
  133.      * @param valParams Valuation Parameters
  134.      * @param pricerParams Pricer Parameters
  135.      * @param csqs Market Parameters
  136.      * @param vcp Valuation Customization Parameters
  137.      *
  138.      * @return Map of the Calibration Measures
  139.      */

  140.     public abstract org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> calibMeasures (
  141.         final org.drip.param.valuation.ValuationParams valParams,
  142.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  143.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  144.         final org.drip.param.valuation.ValuationCustomizationParams vcp);

  145.     /**
  146.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged Funding
  147.      *  Curve Discount Factor Latent State from the Component's Cash Flows. The Constraints here typically
  148.      *  correspond to Date/Cash Flow pairs and the corresponding leading PV.
  149.      *
  150.      * @param valParams Valuation Parameters
  151.      * @param pricerParams Pricer Parameters
  152.      * @param csqs Component Market Parameters
  153.      * @param vcp Valuation Customization Parameters
  154.      * @param pqs Product Quote Set
  155.      *
  156.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  157.      *  corresponding PV)
  158.      */

  159.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint fundingPRWC (
  160.         final org.drip.param.valuation.ValuationParams valParams,
  161.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  162.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  163.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  164.         final org.drip.product.calib.ProductQuoteSet pqs);

  165.     /**
  166.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged Forward
  167.      *  Factor Latent State from the Component's Cash Flows. The Constraints here typically correspond to
  168.      *  Date/Cash Flow pairs and the corresponding leading PV.
  169.      *
  170.      * @param valParams Valuation Parameters
  171.      * @param pricerParams Pricer Parameters
  172.      * @param csqs Component Market Parameters
  173.      * @param vcp Valuation Customization Parameters
  174.      * @param pqs Product Quote Set
  175.      *
  176.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  177.      *  corresponding PV)
  178.      */

  179.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint forwardPRWC (
  180.         final org.drip.param.valuation.ValuationParams valParams,
  181.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  182.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  183.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  184.         final org.drip.product.calib.ProductQuoteSet pqs);

  185.     /**
  186.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the merged Funding and
  187.      *  Forward Latent States from the Component's Cash Flows. The Constraints here typically correspond to
  188.      *  Date/Cash Flow pairs and the corresponding leading PV.
  189.      *
  190.      * @param valParams Valuation Parameters
  191.      * @param pricerParams Pricer Parameters
  192.      * @param csqs Component Market Parameters
  193.      * @param vcp Valuation Customization Parameters
  194.      * @param pqs Product Quote Set
  195.      *
  196.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  197.      *  corresponding PV)
  198.      */

  199.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint fundingForwardPRWC (
  200.         final org.drip.param.valuation.ValuationParams valParams,
  201.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  202.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  203.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  204.         final org.drip.product.calib.ProductQuoteSet pqs);

  205.     /**
  206.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged FX Curve
  207.      *  FX Forward Latent State from the Component's Cash Flows. The Constraints here typically correspond to
  208.      *  Date/Cash Flow pairs and the corresponding leading PV.
  209.      *
  210.      * @param valParams Valuation Parameters
  211.      * @param pricerParams Pricer Parameters
  212.      * @param csqs Component Market Parameters
  213.      * @param vcp Valuation Customization Parameters
  214.      * @param pqs Product Quote Set
  215.      *
  216.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  217.      *  corresponding FX Forward)
  218.      */

  219.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint fxPRWC (
  220.         final org.drip.param.valuation.ValuationParams valParams,
  221.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  222.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  223.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  224.         final org.drip.product.calib.ProductQuoteSet pqs);

  225.     /**
  226.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged Govvie
  227.      *  Curve FX Forward Latent State from the Component's Cash Flows. The Constraints here typically
  228.      *  correspond to Date/Cash Flow pairs and the corresponding leading PV.
  229.      *
  230.      * @param valParams Valuation Parameters
  231.      * @param pricerParams Pricer Parameters
  232.      * @param csqs Component Market Parameters
  233.      * @param vcp Valuation Customization Parameters
  234.      * @param pqs Product Quote Set
  235.      *
  236.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  237.      *  corresponding Govvie Forward)
  238.      */

  239.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint govviePRWC (
  240.         final org.drip.param.valuation.ValuationParams valParams,
  241.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  242.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  243.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  244.         final org.drip.product.calib.ProductQuoteSet pqs);

  245.     /**
  246.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged
  247.      *  Volatility Latent State from the Component's Cash Flows. The Constraints here typically correspond to
  248.      *  Date/Cash Flow pairs and the corresponding leading PV.
  249.      *
  250.      * @param valParams Valuation Parameters
  251.      * @param pricerParams Pricer Parameters
  252.      * @param csqs Component Market Parameters
  253.      * @param vcp Valuation Customization Parameters
  254.      * @param pqs Product Quote Set
  255.      *
  256.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  257.      *  corresponding PV)
  258.      */

  259.     public abstract org.drip.state.estimator.PredictorResponseWeightConstraint volatilityPRWC (
  260.         final org.drip.param.valuation.ValuationParams valParams,
  261.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  262.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  263.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  264.         final org.drip.product.calib.ProductQuoteSet pqs);

  265.     /**
  266.      * Compute the Jacobian of the Dirty PV to the Calibrated Input Manifest Measures
  267.      *
  268.      * @param valParams Valuation Parameters
  269.      * @param pricerParams Pricer Parameters
  270.      * @param csqs Component Market Parameters
  271.      * @param vcp Valuation Customization Parameters
  272.      *
  273.      * @return The micro-Jacobian
  274.      */

  275.     public abstract org.drip.numerical.differentiation.WengertJacobian jackDDirtyPVDManifestMeasure (
  276.         final org.drip.param.valuation.ValuationParams valParams,
  277.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  278.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  279.         final org.drip.param.valuation.ValuationCustomizationParams vcp);

  280.     /**
  281.      * Compute the micro-Jacobian of the given measure to the DF
  282.      *
  283.      * @param strMainfestMeasure Manifest Measure Name
  284.      * @param valParams Valuation Parameters
  285.      * @param pricerParams Pricer Parameters
  286.      * @param csqs Component Market Parameters
  287.      * @param vcp Valuation Customization Parameters
  288.      *
  289.      * @return The micro-Jacobian
  290.      */

  291.     public abstract org.drip.numerical.differentiation.WengertJacobian manifestMeasureDFMicroJack (
  292.         final java.lang.String strMainfestMeasure,
  293.         final org.drip.param.valuation.ValuationParams valParams,
  294.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  295.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  296.         final org.drip.param.valuation.ValuationCustomizationParams vcp);

  297.     /**
  298.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Component from the
  299.      *  Market Inputs. The Constraints here typically correspond to Date/Cash Flow pairs and the
  300.      *  corresponding leading PV.
  301.      *
  302.      * @param valParams Valuation Parameters
  303.      * @param pricerParams Pricer Parameters
  304.      * @param csqs Component Market Parameters
  305.      * @param vcp Valuation Customization Parameters
  306.      * @param pqs The Product Calibration Quote Set
  307.      *
  308.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  309.      *  corresponding PV)
  310.      */

  311.     public org.drip.state.estimator.PredictorResponseWeightConstraint calibPRWC (
  312.         final org.drip.param.valuation.ValuationParams valParams,
  313.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  314.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  315.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  316.         final org.drip.product.calib.ProductQuoteSet pqs)
  317.     {
  318.         if (null == valParams || null == pqs) return null;

  319.         if (pqs.containsLatentStateType
  320.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FUNDING) &&
  321.                 pqs.containsLatentStateQuantificationMetric
  322.                     (org.drip.analytics.definition.LatentStateStatic.DISCOUNT_QM_DISCOUNT_FACTOR) &&
  323.                         pqs.containsLatentStateType
  324.                             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FORWARD) &&
  325.                                 pqs.containsLatentStateQuantificationMetric
  326.                                     (org.drip.analytics.definition.LatentStateStatic.FORWARD_QM_FORWARD_RATE))
  327.             return fundingForwardPRWC (valParams, pricerParams, csqs, vcp, pqs);

  328.         if (pqs.containsLatentStateType
  329.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FUNDING) &&
  330.                 pqs.containsLatentStateQuantificationMetric
  331.                     (org.drip.analytics.definition.LatentStateStatic.DISCOUNT_QM_DISCOUNT_FACTOR))
  332.             return fundingPRWC (valParams, pricerParams, csqs, vcp, pqs);

  333.         if (pqs.containsLatentStateType
  334.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FORWARD) &&
  335.                 pqs.containsLatentStateQuantificationMetric
  336.                     (org.drip.analytics.definition.LatentStateStatic.FORWARD_QM_FORWARD_RATE))
  337.             return forwardPRWC (valParams, pricerParams, csqs, vcp, pqs);

  338.         if (pqs.containsLatentStateType
  339.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FX) &&
  340.                 pqs.containsLatentStateQuantificationMetric
  341.                     (org.drip.analytics.definition.LatentStateStatic.FX_QM_FORWARD_OUTRIGHT))
  342.             return fxPRWC (valParams, pricerParams, csqs, vcp, pqs);

  343.         if (pqs.containsLatentStateType
  344.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_GOVVIE) &&
  345.                 pqs.containsLatentStateQuantificationMetric
  346.                     (org.drip.analytics.definition.LatentStateStatic.GOVVIE_QM_YIELD))
  347.             return govviePRWC (valParams, pricerParams, csqs, vcp, pqs);

  348.         if (pqs.containsLatentStateType
  349.             (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_VOLATILITY))
  350.             return volatilityPRWC (valParams, pricerParams, csqs, vcp, pqs);

  351.         return null;
  352.     }
  353. }