CompositePeriod.java

  1. package org.drip.analytics.cashflow;

  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>CompositePeriod</i> implements the Composite Coupon Period Functionality. It contains the Composite
  81.  * Period Coupon Frequency, Tenor, Accrual Compounding Rule, Day Count, Base Notional, Coupon/Notional
  82.  * Schedules, Pay Currency, Credit Label, FX Fixing Setting, and the List of Composable Period Units.
  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/analytics/README.md">Date, Cash Flow, and Cash Flow Period Measure Generation Utilities</a></li>
  89.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/analytics/cashflow/README.md">Unit and Composite Cash Flow Periods</a></li>
  90.  *  </ul>
  91.  *
  92.  * @author Lakshmi Krishnamurthy
  93.  */

  94. public abstract class CompositePeriod {
  95.     private int _iFreq = -1;
  96.     private java.lang.String _strTenor = "";
  97.     private int _iAccrualCompoundingRule = -1;
  98.     private java.lang.String _strPayCurrency = "";
  99.     private int _iPayDate = java.lang.Integer.MIN_VALUE;
  100.     private double _dblBaseNotional = java.lang.Double.NaN;
  101.     private org.drip.numerical.common.Array2D _fsCoupon = null;
  102.     private org.drip.numerical.common.Array2D _fsNotional = null;
  103.     private org.drip.state.identifier.EntityCDSLabel _creditLabel = null;
  104.     private org.drip.param.period.FixingSetting _fxFixingSetting = null;
  105.     private java.util.List<org.drip.analytics.cashflow.ComposableUnitPeriod> _lsCUP = null;

  106.     protected CompositePeriod (
  107.         final org.drip.param.period.CompositePeriodSetting cps,
  108.         final java.util.List<org.drip.analytics.cashflow.ComposableUnitPeriod> lsCUP)
  109.         throws java.lang.Exception
  110.     {
  111.         if (
  112.             null == cps ||
  113.             null == (_lsCUP = lsCUP) || 0 == _lsCUP.size()
  114.         )
  115.             throw new java.lang.Exception ("CompositePeriod Constructor => Invalid Inputs");

  116.         _iFreq = cps.freq();

  117.         _strTenor = cps.tenor();

  118.         org.drip.analytics.daycount.DateAdjustParams dapPay = cps.dapPay();

  119.         org.drip.analytics.cashflow.ComposableUnitPeriod cupFinal = _lsCUP.get (_lsCUP.size() - 1);

  120.         _iAccrualCompoundingRule = cupFinal.accrualCompoundingRule();

  121.         _iPayDate = cupFinal.endDate();

  122.         if (null != dapPay) _iPayDate = dapPay.roll (_iPayDate);

  123.         _strPayCurrency = cps.payCurrency();

  124.         _dblBaseNotional = cps.baseNotional();

  125.         _fxFixingSetting = cps.fxFixingSetting();

  126.         _creditLabel = cps.creditLabel();

  127.         _fsNotional = cps.notionalSchedule();

  128.         _fsCoupon = cps.couponSchedule();
  129.     }

  130.     /**
  131.      * Retrieve the List of Composable Periods
  132.      *
  133.      * @return The List of Composable Periods
  134.      */

  135.     public java.util.List<org.drip.analytics.cashflow.ComposableUnitPeriod> periods()
  136.     {
  137.         return _lsCUP;
  138.     }

  139.     /**
  140.      * Retrieve the Period Start Date
  141.      *
  142.      * @return The Period Start Date
  143.      */

  144.     public int startDate()
  145.     {
  146.         return _lsCUP.get (0).startDate();
  147.     }

  148.     /**
  149.      * Retrieve the Period End Date
  150.      *
  151.      * @return The Period End Date
  152.      */

  153.     public int endDate()
  154.     {
  155.         return _lsCUP.get (_lsCUP.size() - 1).endDate();
  156.     }

  157.     /**
  158.      * Check whether the supplied Date is inside the Period specified
  159.      *
  160.      * @param iDate Date
  161.      *
  162.      * @return TRUE - The specified Date is inside the Period
  163.      */

  164.     public boolean contains (
  165.         final int iDate)
  166.     {
  167.         return iDate >= startDate() && iDate <= endDate();
  168.     }

  169.     /**
  170.      * Return the Unit Period to which the Date belongs
  171.      *
  172.      * @param iDate Date
  173.      *
  174.      * @return The Unit Period to which the Date belongs
  175.      */

  176.     public org.drip.analytics.cashflow.ComposableUnitPeriod enclosingCUP (
  177.         final int iDate)
  178.     {
  179.         if (!contains (iDate)) return null;

  180.         for (org.drip.analytics.cashflow.ComposableUnitPeriod cup : _lsCUP) {
  181.             int iDateLocation = cup.dateLocation (iDate);

  182.             if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_INSIDE_SEGMENT == iDateLocation)
  183.                 return cup;
  184.         }

  185.         return null;
  186.     }

  187.     /**
  188.      * Retrieve the Accrual Compounding Rule
  189.      *
  190.      * @return The Accrual Compounding Rule
  191.      */

  192.     public int accrualCompoundingRule()
  193.     {
  194.         return _iAccrualCompoundingRule;
  195.     }

  196.     /**
  197.      * Return the Period Pay Date
  198.      *
  199.      * @return Period Pay Date
  200.      */

  201.     public int payDate()
  202.     {
  203.         return _iPayDate;
  204.     }

  205.     /**
  206.      * Return the Period FX Fixing Date
  207.      *
  208.      * @return Period FX Fixing Date
  209.      *
  210.      * @throws java.lang.Exception Thrown if FX Fixing Date cannot be generated
  211.      */

  212.     public int fxFixingDate()
  213.         throws java.lang.Exception
  214.     {
  215.         if (null == _fxFixingSetting) return _iPayDate;

  216.         int iUnadjustedFixingDate = java.lang.Integer.MIN_VALUE;

  217.         int iFixingType = _fxFixingSetting.type();

  218.         if (org.drip.param.period.FixingSetting.FIXING_COMPOSITE_PERIOD_END == iFixingType)
  219.             iUnadjustedFixingDate = endDate();
  220.         else if (org.drip.param.period.FixingSetting.FIXING_COMPOSITE_PERIOD_START == iFixingType)
  221.             iUnadjustedFixingDate = startDate();
  222.         else if (org.drip.param.period.FixingSetting.FIXING_PRESET_STATIC == iFixingType)
  223.             iUnadjustedFixingDate = _fxFixingSetting.staticDate();

  224.         org.drip.analytics.daycount.DateAdjustParams dapFixing = _fxFixingSetting.dap();

  225.         if (null == dapFixing) return iUnadjustedFixingDate;

  226.         return dapFixing.roll (iUnadjustedFixingDate);
  227.     }

  228.     /**
  229.      * Is this Cash Flow FX MTM?
  230.      *
  231.      * @return TRUE - FX MTM is on (i.e., FX is not Driven by Fixing)
  232.      */

  233.     public boolean isFXMTM()
  234.     {
  235.         return null == _fxFixingSetting;
  236.     }

  237.     /**
  238.      * Coupon Period FX
  239.      *
  240.      * @param csqc Market Parameters
  241.      *
  242.      * @return The Period FX
  243.      *
  244.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  245.      */

  246.     public double fx (
  247.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  248.         throws java.lang.Exception
  249.     {
  250.         org.drip.state.identifier.FXLabel fxLabel = fxLabel();

  251.         if (null == fxLabel) return 1.;

  252.         if (null == csqc) throw new java.lang.Exception ("CompositePeriod::fx => Invalid Inputs");

  253.         if (!isFXMTM())
  254.             return csqc.fixing (
  255.                 fxFixingDate(),
  256.                 fxLabel
  257.             );

  258.         org.drip.state.fx.FXCurve fxfc = csqc.fxState (fxLabel);

  259.         if (null == fxfc)
  260.             throw new java.lang.Exception ("CompositePeriod::fx => No Curve for " +
  261.                 fxLabel.fullyQualifiedName());

  262.         return fxfc.fx (_iPayDate);
  263.     }

  264.     /**
  265.      * Retrieve the Coupon Frequency
  266.      *
  267.      * @return The Coupon Frequency
  268.      */

  269.     public int freq()
  270.     {
  271.         return _iFreq;
  272.     }

  273.     /**
  274.      * Convert the Coupon Frequency into a Tenor
  275.      *
  276.      * @return The Coupon Frequency converted into a Tenor
  277.      */

  278.     public java.lang.String tenor()
  279.     {
  280.         if (null != _strTenor && !_strTenor.isEmpty()) return _strTenor;

  281.         int iTenorInMonths = 12 / freq() ;

  282.         return
  283.             1 == iTenorInMonths ||
  284.             2 == iTenorInMonths ||
  285.             3 == iTenorInMonths ||
  286.             6 == iTenorInMonths ||
  287.             12 == iTenorInMonths ?
  288.             iTenorInMonths + "M" : "ON";
  289.     }

  290.     /**
  291.      * Retrieve the Pay Currency
  292.      *
  293.      * @return The Pay Currency
  294.      */

  295.     public java.lang.String payCurrency()
  296.     {
  297.         return _strPayCurrency;
  298.     }

  299.     /**
  300.      * Retrieve the Coupon Currency
  301.      *
  302.      * @return The Coupon Currency
  303.      */

  304.     public java.lang.String couponCurrency()
  305.     {
  306.         return _lsCUP.get (0).couponCurrency();
  307.     }

  308.     /**
  309.      * Retrieve the Period Basis
  310.      *
  311.      * @return The Period Basis
  312.      */

  313.     public double basis()
  314.     {
  315.         return _lsCUP.get (0).basis();
  316.     }

  317.     /**
  318.      * Coupon Period Survival Probability
  319.      *
  320.      * @param csqc Market Parameters
  321.      *
  322.      * @return The Period Survival Probability
  323.      *
  324.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  325.      */

  326.     public double survival (
  327.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  328.         throws java.lang.Exception
  329.     {
  330.         org.drip.state.identifier.EntityCDSLabel creditLabel = creditLabel();

  331.         if (null == creditLabel) return 1.;

  332.         if (null == csqc) throw new java.lang.Exception ("CompositePeriod::survival => Invalid Inputs");

  333.         org.drip.state.credit.CreditCurve cc = csqc.creditState (creditLabel);

  334.         if (null == cc)
  335.             throw new java.lang.Exception ("CompositePeriod::survival => No Curve for " +
  336.                 creditLabel.fullyQualifiedName());

  337.         return cc.survival (_iPayDate);
  338.     }

  339.     /**
  340.      * Retrieve the Coupon Period Recovery
  341.      *
  342.      * @param csqc Market Parameters
  343.      *
  344.      * @return The Period Recovery
  345.      *
  346.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  347.      */

  348.     public double recovery (
  349.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  350.         throws java.lang.Exception
  351.     {
  352.         org.drip.state.identifier.EntityCDSLabel creditLabel = creditLabel();

  353.         if (null == creditLabel) return 1.;

  354.         if (null == csqc) throw new java.lang.Exception ("CompositePeriod::recovery => Invalid Inputs");

  355.         org.drip.state.credit.CreditCurve cc = csqc.creditState (creditLabel);

  356.         if (null == cc)
  357.             throw new java.lang.Exception ("CompositePeriod::recovery => No Curve for " +
  358.                 creditLabel.fullyQualifiedName());

  359.         return cc.recovery (_iPayDate);
  360.     }

  361.     /**
  362.      * Retrieve the Coupon Period Discount Factor
  363.      *
  364.      * @param csqc Market Parameters
  365.      *
  366.      * @return The Period Discount Factor
  367.      *
  368.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  369.      */

  370.     public double df (
  371.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  372.         throws java.lang.Exception
  373.     {
  374.         org.drip.state.identifier.FundingLabel fundingLabel = fundingLabel();

  375.         if (null == csqc) throw new java.lang.Exception ("CompositePeriod::df => Invalid Inputs");

  376.         org.drip.state.discount.MergedDiscountForwardCurve dc = csqc.fundingState (fundingLabel);

  377.         if (null == dc)
  378.             throw new java.lang.Exception ("CompositePeriod::df => No Curve for " +
  379.                 fundingLabel.fullyQualifiedName());

  380.         return dc.df (_iPayDate);
  381.     }

  382.     /**
  383.      * Get the Period Base Notional
  384.      *
  385.      * @return Period Base Notional
  386.      */

  387.     public double baseNotional()
  388.     {
  389.         return _dblBaseNotional;
  390.     }

  391.     /**
  392.      * Get the Period Notional Schedule
  393.      *
  394.      * @return Period Notional Schedule
  395.      */

  396.     public org.drip.numerical.common.Array2D notionalSchedule()
  397.     {
  398.         return _fsNotional;
  399.     }

  400.     /**
  401.      * Retrieve the Coupon Period Notional Corresponding to the specified Date
  402.      *
  403.      * @param iDate The Specified Date
  404.      *
  405.      * @return The Period Notional Corresponding to the specified Date
  406.      *
  407.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  408.      */

  409.     public double notional (
  410.         final int iDate)
  411.         throws java.lang.Exception
  412.     {
  413.         if (!contains (iDate))
  414.             throw new java.lang.Exception ("CompositePeriod::notional => Invalid Inputs: " + iDate + " [" +
  415.                 startDate() + " => " + endDate() + "]");

  416.         return _dblBaseNotional * (null == _fsNotional ? 1. : _fsNotional.y (iDate));
  417.     }

  418.     /**
  419.      * Retrieve the Coupon Period Notional Aggregated over the specified Dates
  420.      *
  421.      * @param iDate1 The Date #1
  422.      * @param iDate2 The Date #2
  423.      *
  424.      * @return The Period Notional Aggregated over the specified Dates
  425.      *
  426.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  427.      */

  428.     public double notional (
  429.         final int iDate1,
  430.         final int iDate2)
  431.         throws java.lang.Exception
  432.     {
  433.         if (
  434.             !contains (iDate1) ||
  435.             !contains (iDate2)
  436.         )
  437.             throw new java.lang.Exception ("CompositePeriod::notional => Invalid Dates");

  438.         return _dblBaseNotional * (
  439.             null == _fsNotional ? 1. : _fsNotional.y (
  440.                 iDate1,
  441.                 iDate2
  442.             )
  443.         );
  444.     }

  445.     /**
  446.      * Get the Period Coupon Schedule
  447.      *
  448.      * @return Period Coupon Schedule
  449.      */

  450.     public org.drip.numerical.common.Array2D couponSchedule()
  451.     {
  452.         return _fsCoupon;
  453.     }

  454.     /**
  455.      * Retrieve the Period Coupon Schedule Factor Corresponding to the specified Date
  456.      *
  457.      * @param iDate The Specified Date
  458.      *
  459.      * @return The Period Coupon Schedule Factor Corresponding to the specified Date
  460.      *
  461.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  462.      */

  463.     public double couponFactor (
  464.         final int iDate)
  465.         throws java.lang.Exception
  466.     {
  467.         if (!contains (iDate))
  468.             throw new java.lang.Exception ("CompositePeriod::couponFactor => Invalid Inputs");

  469.         return null == _fsCoupon ? 1. : _fsCoupon.y (iDate);
  470.     }

  471.     /**
  472.      * Retrieve the Period Coupon Schedule Factor Aggregated over the specified Dates
  473.      *
  474.      * @param iDate1 The Date #1
  475.      * @param iDate2 The Date #2
  476.      *
  477.      * @return The Period Coupon Schedule Factor Aggregated over the specified Dates
  478.      *
  479.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  480.      */

  481.     public double couponFactor (
  482.         final int iDate1,
  483.         final int iDate2)
  484.         throws java.lang.Exception
  485.     {
  486.         if (!contains (iDate1) || !contains (iDate2))
  487.             throw new java.lang.Exception ("CompositePeriod::couponFactor => Invalid Dates");

  488.         return null == _fsCoupon ? 1. : _fsCoupon.y (
  489.             iDate1,
  490.             iDate2
  491.         );
  492.     }

  493.     /**
  494.      * Return the Credit Label
  495.      *
  496.      * @return The Credit Label
  497.      */

  498.     public org.drip.state.identifier.EntityCDSLabel creditLabel()
  499.     {
  500.         return _creditLabel;
  501.     }

  502.     /**
  503.      * Return the Floater Label
  504.      *
  505.      * @return The Floater Label
  506.      */

  507.     public org.drip.state.identifier.FloaterLabel floaterLabel()
  508.     {
  509.         org.drip.analytics.cashflow.ComposableUnitPeriod cp = _lsCUP.get (0);

  510.         return cp instanceof org.drip.analytics.cashflow.ComposableUnitFixedPeriod ? null :
  511.             ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  512.                 cp).referenceIndexPeriod().floaterLabel();
  513.     }

  514.     /**
  515.      * Return the Funding Label
  516.      *
  517.      * @return The Funding Label
  518.      */

  519.     public org.drip.state.identifier.FundingLabel fundingLabel()
  520.     {
  521.         return org.drip.state.identifier.FundingLabel.Standard (_strPayCurrency);
  522.     }

  523.     /**
  524.      * Return the FX Label
  525.      *
  526.      * @return The FX Label
  527.      */

  528.     public org.drip.state.identifier.FXLabel fxLabel()
  529.     {
  530.         java.lang.String strCouponCurrency = couponCurrency();

  531.         return _strPayCurrency.equalsIgnoreCase (strCouponCurrency) ? null :
  532.             org.drip.state.identifier.FXLabel.Standard (_strPayCurrency + "/" + strCouponCurrency);
  533.     }

  534.     /**
  535.      * Compute the Convexity Adjustment for the Composable Periods that use Arithmetic Compounding using the
  536.      *  specified Value Date using the Market Data provided
  537.      *
  538.      * @param iValueDate The Valuation Date
  539.      * @param csqc The Market Curves/Surface
  540.      *
  541.      * @return The List of Convexity Adjustments
  542.      */

  543.     public java.util.List<org.drip.analytics.output.ConvexityAdjustment> periodWiseConvexityAdjustment (
  544.         final int iValueDate,
  545.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  546.     {
  547.         java.util.List<org.drip.analytics.output.ConvexityAdjustment> lsConvAdj = new
  548.             java.util.ArrayList<org.drip.analytics.output.ConvexityAdjustment>();

  549.         if (null == csqc || iValueDate >= _iPayDate) {
  550.             for (int i = 0; i < _lsCUP.size(); ++i)
  551.                 lsConvAdj.add (new org.drip.analytics.output.ConvexityAdjustment());

  552.             return lsConvAdj;
  553.         }

  554.         org.drip.state.identifier.FXLabel fxLabel = fxLabel();

  555.         org.drip.state.identifier.EntityCDSLabel creditLabel = creditLabel();

  556.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  557.         org.drip.state.identifier.ForwardLabel forwardLabel = floaterLabel instanceof
  558.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  559.                 null;

  560.         org.drip.state.identifier.FundingLabel fundingLabel = fundingLabel();

  561.         org.drip.state.volatility.VolatilityCurve vcFX = csqc.fxVolatility (fxLabel);

  562.         org.drip.state.volatility.VolatilityCurve vcCredit = csqc.creditVolatility (creditLabel);

  563.         org.drip.state.volatility.VolatilityCurve vcForward = csqc.forwardVolatility (forwardLabel);

  564.         org.drip.state.volatility.VolatilityCurve vcFunding = csqc.fundingVolatility (fundingLabel);

  565.         org.drip.function.definition.R1ToR1 r1ToR1CreditForwardCorr = csqc.creditForwardCorrelation (
  566.             creditLabel,
  567.             forwardLabel
  568.         );

  569.         org.drip.function.definition.R1ToR1 r1ToR1ForwardFundingCorr = csqc.forwardFundingCorrelation (
  570.             forwardLabel,
  571.             fundingLabel
  572.         );

  573.         org.drip.function.definition.R1ToR1 r1ToR1ForwardFXCorr = csqc.forwardFXCorrelation (
  574.             forwardLabel,
  575.             fxLabel
  576.         );

  577.         try {
  578.             double dblCreditFundingConvexityAdjustment = java.lang.Math.exp (
  579.                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  580.                     vcCredit,
  581.                     vcFunding,
  582.                     csqc.creditFundingCorrelation (
  583.                         creditLabel,
  584.                         fundingLabel
  585.                     ),
  586.                     iValueDate,
  587.                     _iPayDate
  588.                 )
  589.             );

  590.             double dblCreditFXConvexityAdjustment = isFXMTM() ? java.lang.Math.exp (
  591.                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  592.                     vcCredit,
  593.                     vcFX,
  594.                     csqc.creditFXCorrelation (
  595.                         creditLabel,
  596.                         fxLabel
  597.                     ),
  598.                     iValueDate,
  599.                     _iPayDate
  600.                 )
  601.             ) : 1.;

  602.             double dblFundingFXConvexityAdjustment = isFXMTM() ? java.lang.Math.exp (
  603.                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  604.                     vcFunding,
  605.                     vcFX,
  606.                     csqc.fundingFXCorrelation (
  607.                         fundingLabel,
  608.                         fxLabel
  609.                     ),
  610.                     iValueDate,
  611.                     _iPayDate
  612.                 )
  613.             ): 1.;

  614.             for (org.drip.analytics.cashflow.ComposableUnitPeriod cup : _lsCUP) {
  615.                 org.drip.analytics.output.ConvexityAdjustment convAdj = new
  616.                     org.drip.analytics.output.ConvexityAdjustment();

  617.                 if (
  618.                     !convAdj.setCreditFunding (dblCreditFundingConvexityAdjustment) ||
  619.                     !convAdj.setCreditFX (dblCreditFXConvexityAdjustment) ||
  620.                     !convAdj.setFundingFX (dblFundingFXConvexityAdjustment)
  621.                 )
  622.                     return null;

  623.                 if (null != forwardLabel) {
  624.                     if (!(cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod))
  625.                         return null;

  626.                     int iFixingDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  627.                         cup).referenceIndexPeriod().fixingDate();

  628.                     if (
  629.                         !convAdj.setCreditForward (
  630.                             iValueDate < iFixingDate ? java.lang.Math.exp (
  631.                                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  632.                                     vcCredit,
  633.                                     vcForward,
  634.                                     r1ToR1CreditForwardCorr,
  635.                                     iValueDate,
  636.                                     iFixingDate
  637.                                 )
  638.                             ) : 1.
  639.                         )
  640.                     )
  641.                         return null;

  642.                     if (
  643.                         !convAdj.setForwardFunding (
  644.                             iValueDate < iFixingDate ? java.lang.Math.exp (
  645.                                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  646.                                     vcForward,
  647.                                     vcFunding,
  648.                                     r1ToR1ForwardFundingCorr,
  649.                                     iValueDate,
  650.                                     iFixingDate
  651.                                 )
  652.                             ) : 1.
  653.                         )
  654.                     )
  655.                         return null;

  656.                     if (
  657.                         !convAdj.setForwardFX (
  658.                             isFXMTM() && iValueDate < iFixingDate ? java.lang.Math.exp (
  659.                                 org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  660.                                     vcForward,
  661.                                     vcFX,
  662.                                     r1ToR1ForwardFXCorr,
  663.                                     iValueDate,
  664.                                     iFixingDate
  665.                                 )
  666.                             ) : 1.
  667.                         )
  668.                     )
  669.                         return null;
  670.                 }

  671.                 lsConvAdj.add (convAdj);
  672.             }

  673.             return lsConvAdj;
  674.         } catch (java.lang.Exception e) {
  675.             e.printStackTrace();
  676.         }

  677.         return null;
  678.     }

  679.     /**
  680.      * Compute the Convexity Adjustment for the Composable Periods that use geometric Compounding using the
  681.      *  specified Value Date using the Market Data provided
  682.      *
  683.      * @param iValueDate The Valuation Date
  684.      * @param csqc The Market Curves/Surface
  685.      *
  686.      * @return The Convexity Adjustment
  687.      */

  688.     public org.drip.analytics.output.ConvexityAdjustment terminalConvexityAdjustment (
  689.         final int iValueDate,
  690.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  691.     {
  692.         if (null == csqc || iValueDate >= _iPayDate)
  693.             return new org.drip.analytics.output.ConvexityAdjustment();

  694.         boolean bFXIsMTM = isFXMTM();

  695.         org.drip.state.identifier.FXLabel fxLabel = fxLabel();

  696.         org.drip.state.identifier.EntityCDSLabel creditLabel = creditLabel();

  697.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  698.         org.drip.state.identifier.ForwardLabel forwardLabel = floaterLabel instanceof
  699.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  700.                 null;

  701.         org.drip.state.identifier.FundingLabel fundingLabel = fundingLabel();

  702.         org.drip.state.volatility.VolatilityCurve vcFX = csqc.fxVolatility (fxLabel);

  703.         org.drip.state.volatility.VolatilityCurve vcCredit = csqc.creditVolatility (creditLabel);

  704.         org.drip.state.volatility.VolatilityCurve vcForward = csqc.forwardVolatility (forwardLabel);

  705.         org.drip.state.volatility.VolatilityCurve vcFunding = csqc.fundingVolatility (fundingLabel);

  706.         org.drip.analytics.output.ConvexityAdjustment convAdj = new
  707.             org.drip.analytics.output.ConvexityAdjustment();

  708.         try {
  709.             if (
  710.                 !convAdj.setCreditFunding (
  711.                     java.lang.Math.exp (
  712.                         org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  713.                             vcCredit,
  714.                             vcFunding,
  715.                             csqc.creditFundingCorrelation (
  716.                                 creditLabel,
  717.                                 fundingLabel
  718.                             ), iValueDate, _iPayDate
  719.                         )
  720.                     )
  721.                 )
  722.             )
  723.                 return null;

  724.             if (
  725.                 bFXIsMTM && !convAdj.setCreditFX (
  726.                     java.lang.Math.exp (
  727.                         org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  728.                             vcCredit,
  729.                             vcFX,
  730.                             csqc.creditFXCorrelation (
  731.                                 creditLabel,
  732.                                 fxLabel
  733.                             ),
  734.                             iValueDate,
  735.                             _iPayDate
  736.                         )
  737.                     )
  738.                 )
  739.             )
  740.                 return null;

  741.             if (
  742.                 bFXIsMTM && !convAdj.setFundingFX (
  743.                     java.lang.Math.exp (
  744.                         org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  745.                             vcFunding,
  746.                             vcFX,
  747.                             csqc.fundingFXCorrelation (
  748.                                 fundingLabel,
  749.                                 fxLabel
  750.                             ),
  751.                             iValueDate,
  752.                             _iPayDate
  753.                         )
  754.                     )
  755.                 )
  756.             )
  757.                 return null;

  758.             if (null == forwardLabel) return convAdj;

  759.             org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (0);

  760.             if (!(cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)) return null;

  761.             int iFixingDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  762.                 cup).referenceIndexPeriod().fixingDate();

  763.             if (iValueDate < iFixingDate) {
  764.                 if (
  765.                     !convAdj.setCreditForward (
  766.                         java.lang.Math.exp (
  767.                             org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  768.                                 vcCredit,
  769.                                 vcForward,
  770.                                 csqc.creditForwardCorrelation (
  771.                                     creditLabel,
  772.                                     forwardLabel
  773.                                 ),
  774.                                 iValueDate,
  775.                                 iFixingDate
  776.                             )
  777.                         )
  778.                     )
  779.                 )
  780.                     return null;

  781.                 if (
  782.                     !convAdj.setForwardFunding (
  783.                         java.lang.Math.exp (
  784.                             org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  785.                                 vcForward,
  786.                                 vcFunding,
  787.                                 csqc.forwardFundingCorrelation (
  788.                                     forwardLabel,
  789.                                     fundingLabel
  790.                                 ),
  791.                                 iValueDate,
  792.                                 iFixingDate
  793.                             )
  794.                         )
  795.                     )
  796.                 )
  797.                     return null;

  798.                 if (
  799.                     bFXIsMTM && !convAdj.setForwardFX (
  800.                         java.lang.Math.exp (
  801.                             org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto (
  802.                                 vcForward,
  803.                                 vcFX,
  804.                                 csqc.forwardFXCorrelation (
  805.                                     forwardLabel,
  806.                                     fxLabel
  807.                                 ),
  808.                                 iValueDate,
  809.                                 iFixingDate
  810.                             )
  811.                         )
  812.                     )
  813.                 )
  814.                     return null;
  815.             }

  816.             return convAdj;
  817.         } catch (java.lang.Exception e) {
  818.             e.printStackTrace();
  819.         }

  820.         return null;
  821.     }

  822.     /**
  823.      * Compute the Unit Period Convexity Measures
  824.      *
  825.      * @param iValueDate Valuation Date
  826.      * @param csqc The Market Curve Surface/Quote Set
  827.      *
  828.      * @return The Unit Period Convexity Measures
  829.      */

  830.     public java.util.List<org.drip.analytics.output.UnitPeriodConvexityMetrics> unitPeriodConvexityMetrics (
  831.         final int iValueDate,
  832.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  833.     {
  834.         java.util.List<org.drip.analytics.output.UnitPeriodConvexityMetrics> lsUPCM = new
  835.             java.util.ArrayList<org.drip.analytics.output.UnitPeriodConvexityMetrics>();

  836.         int iNumPeriodUnit = _lsCUP.size();

  837.         try {
  838.             if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_ARITHMETIC ==
  839.                 _iAccrualCompoundingRule) {
  840.                 java.util.List<org.drip.analytics.output.ConvexityAdjustment> lsConvAdj =
  841.                     periodWiseConvexityAdjustment (
  842.                         iValueDate,
  843.                         csqc
  844.                     );

  845.                 if (null == lsConvAdj || iNumPeriodUnit != lsConvAdj.size()) return null;

  846.                 for (int i = 0; i < iNumPeriodUnit; ++i) {
  847.                     org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  848.                     lsUPCM.add (
  849.                         new org.drip.analytics.output.UnitPeriodConvexityMetrics (
  850.                             cup.startDate(),
  851.                             cup.endDate(),
  852.                             lsConvAdj.get (i)
  853.                         )
  854.                     );
  855.                 }
  856.             } else if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  857.                 == _iAccrualCompoundingRule)
  858.                 lsUPCM.add (
  859.                     new org.drip.analytics.output.UnitPeriodConvexityMetrics (
  860.                         startDate(),
  861.                         endDate(),
  862.                         terminalConvexityAdjustment (
  863.                             iValueDate,
  864.                             csqc
  865.                         )
  866.                     )
  867.                 );

  868.             return lsUPCM;
  869.         } catch (java.lang.Exception e) {
  870.             e.printStackTrace();
  871.         }

  872.         return null;
  873.     }

  874.     /**
  875.      * Compute the Full Period Coupon Measures
  876.      *
  877.      * @param iValueDate Valuation Date
  878.      * @param csqc The Market Curve Surface/Quote Set
  879.      *
  880.      * @return The Full Period Coupon Measures
  881.      */

  882.     public org.drip.analytics.output.CompositePeriodCouponMetrics couponMetrics (
  883.         final int iValueDate,
  884.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  885.     {
  886.         if (!org.drip.numerical.common.NumberUtil.IsValid (iValueDate)) return null;

  887.         java.util.List<org.drip.analytics.output.UnitPeriodMetrics> lsUPM = new
  888.             java.util.ArrayList<org.drip.analytics.output.UnitPeriodMetrics>();

  889.         int iNumPeriodUnit = _lsCUP.size();

  890.         double dblUnitAccrual = 1.;

  891.         try {
  892.             if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_ARITHMETIC ==
  893.                 _iAccrualCompoundingRule) {
  894.                 java.util.List<org.drip.analytics.output.ConvexityAdjustment> lsConvAdj =
  895.                     periodWiseConvexityAdjustment (
  896.                         iValueDate,
  897.                         csqc
  898.                     );

  899.                 if (null == lsConvAdj || iNumPeriodUnit != lsConvAdj.size()) return null;

  900.                 for (int i = 0; i < iNumPeriodUnit; ++i) {
  901.                     org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  902.                     lsUPM.add (
  903.                         new org.drip.analytics.output.UnitPeriodMetrics (
  904.                             cup.startDate(),
  905.                             cup.endDate(),
  906.                             cup.fullCouponDCF(),
  907.                             cup.fullCouponRate (csqc),
  908.                             lsConvAdj.get (i)
  909.                         )
  910.                     );
  911.                 }
  912.             } else if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  913.                 == _iAccrualCompoundingRule) {
  914.                 double dblDCF = 0.;

  915.                 for (int i = 0; i < iNumPeriodUnit; ++i) {
  916.                     org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  917.                     double dblPeriodDCF = cup.fullCouponDCF();

  918.                     dblDCF += dblPeriodDCF;

  919.                     dblUnitAccrual *= (1. + cup.fullCouponRate (csqc) * dblPeriodDCF);
  920.                 }

  921.                 lsUPM.add (
  922.                     new org.drip.analytics.output.UnitPeriodMetrics (
  923.                         startDate(),
  924.                         endDate(),
  925.                         dblDCF,
  926.                         (dblUnitAccrual - 1.) / dblDCF,
  927.                         terminalConvexityAdjustment (
  928.                             iValueDate,
  929.                             csqc
  930.                         )
  931.                     )
  932.                 );
  933.             }

  934.             return org.drip.analytics.output.CompositePeriodCouponMetrics.Create (lsUPM);
  935.         } catch (java.lang.Exception e) {
  936.             e.printStackTrace();
  937.         }

  938.         return null;
  939.     }

  940.     /**
  941.      * Compute the Coupon Accrual DCF to the specified Accrual End Date
  942.      *
  943.      * @param iValueDate The Valuation Date
  944.      *
  945.      * @return The Coupon Accrual DCF to the specified Accrual End Date
  946.      *
  947.      * @throws java.lang.Exception Thrown if the Accrual DCF cannot be calculated
  948.      */

  949.     public double accrualDCF (
  950.         final int iValueDate)
  951.         throws java.lang.Exception
  952.     {
  953.         if (!contains (iValueDate)) return 0.;

  954.         int iNumPeriodUnit = _lsCUP.size();

  955.         double dblAccrualDCF = 0.;

  956.         for (int i = 0; i < iNumPeriodUnit; ++i) {
  957.             org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  958.             int iDateLocation = cup.dateLocation (iValueDate);

  959.             if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_INSIDE_SEGMENT == iDateLocation)
  960.                 dblAccrualDCF += cup.accrualDCF (iValueDate);
  961.             else if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_RIGHT_OF_SEGMENT ==
  962.                 iDateLocation)
  963.                 dblAccrualDCF += cup.fullCouponDCF();
  964.         }

  965.         return dblAccrualDCF;
  966.     }

  967.     /**
  968.      * Compute the Full Coupon DCF
  969.      *
  970.      * @return The Full Coupon DCF
  971.      *
  972.      * @throws java.lang.Exception Thrown if the Full Coupon DCF cannot be calculated
  973.      */

  974.     public double couponDCF()
  975.         throws java.lang.Exception
  976.     {
  977.         int iNumPeriodUnit = _lsCUP.size();

  978.         double dblAccrualDCF = 0.;

  979.         for (int i = 0; i < iNumPeriodUnit; ++i)
  980.             dblAccrualDCF += _lsCUP.get (i).fullCouponDCF();

  981.         return dblAccrualDCF;
  982.     }

  983.     /**
  984.      * Compute the Coupon Accrual Measures to the specified Accrual End Date
  985.      *
  986.      * @param iValueDate The Valuation Date
  987.      * @param csqc The Market Curve Surface/Quote Set
  988.      *
  989.      * @return The Coupon Accrual Measures to the specified Accrual End Date
  990.      */

  991.     public org.drip.analytics.output.CompositePeriodAccrualMetrics accrualMetrics (
  992.         final int iValueDate,
  993.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  994.     {
  995.         try {
  996.             if (!contains (iValueDate)) return null;

  997.             java.util.List<org.drip.analytics.output.UnitPeriodMetrics> lsUPM = new
  998.                 java.util.ArrayList<org.drip.analytics.output.UnitPeriodMetrics>();

  999.             int iNumPeriodUnit = _lsCUP.size();

  1000.             int iResetDate = java.lang.Integer.MIN_VALUE;

  1001.             if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_ARITHMETIC ==
  1002.                 _iAccrualCompoundingRule) {
  1003.                 java.util.List<org.drip.analytics.output.ConvexityAdjustment> lsConvAdj =
  1004.                     periodWiseConvexityAdjustment (
  1005.                         iValueDate,
  1006.                         csqc
  1007.                     );

  1008.                 if (null == lsConvAdj || iNumPeriodUnit != lsConvAdj.size()) return null;

  1009.                 for (int i = 0; i < iNumPeriodUnit; ++i) {
  1010.                     org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  1011.                     int iDateLocation = cup.dateLocation (iValueDate);

  1012.                     if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_INSIDE_SEGMENT ==
  1013.                         iDateLocation) {
  1014.                         if (cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1015.                             iResetDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1016.                                 cup).referenceIndexPeriod().fixingDate();

  1017.                         lsUPM.add (
  1018.                             new org.drip.analytics.output.UnitPeriodMetrics (
  1019.                                 cup.startDate(),
  1020.                                 iValueDate,
  1021.                                 cup.accrualDCF (iValueDate),
  1022.                                 cup.fullCouponRate (csqc),
  1023.                                 lsConvAdj.get (i)
  1024.                             )
  1025.                         );
  1026.                     } else if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_RIGHT_OF_SEGMENT ==
  1027.                         iDateLocation) {
  1028.                         if (cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1029.                             iResetDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1030.                                 cup).referenceIndexPeriod().fixingDate();

  1031.                         lsUPM.add (
  1032.                             new org.drip.analytics.output.UnitPeriodMetrics (
  1033.                                 cup.startDate(),
  1034.                                 cup.endDate(),
  1035.                                 cup.fullCouponDCF(),
  1036.                                 cup.fullCouponRate (csqc),
  1037.                                 lsConvAdj.get (i)
  1038.                             )
  1039.                         );
  1040.                     }
  1041.                 }
  1042.             } else if (org.drip.analytics.support.CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  1043.                 == _iAccrualCompoundingRule) {
  1044.                 double dblAccrualDCF = 0.;
  1045.                 double dblUnitAccrual = 1.;

  1046.                 for (int i = 0; i < iNumPeriodUnit; ++i) {
  1047.                     org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (i);

  1048.                     int iDateLocation = cup.dateLocation (iValueDate);

  1049.                     if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_INSIDE_SEGMENT ==
  1050.                         iDateLocation) {
  1051.                         double dblPeriodAccrualDCF = cup.accrualDCF (iValueDate);

  1052.                         dblAccrualDCF += dblPeriodAccrualDCF;

  1053.                         dblUnitAccrual *= (1. + cup.fullCouponRate (csqc) * dblPeriodAccrualDCF);

  1054.                         if (cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1055.                             iResetDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1056.                                 cup).referenceIndexPeriod().fixingDate();
  1057.                     } else if (org.drip.analytics.cashflow.ComposableUnitFixedPeriod.NODE_RIGHT_OF_SEGMENT ==
  1058.                         iDateLocation) {
  1059.                         double dblPeriodDCF = cup.fullCouponDCF();

  1060.                         dblAccrualDCF += dblPeriodDCF;

  1061.                         dblUnitAccrual *= (1. + cup.fullCouponRate (csqc) * dblPeriodDCF);

  1062.                         if (cup instanceof org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1063.                             iResetDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod)
  1064.                                 cup).referenceIndexPeriod().fixingDate();
  1065.                     }
  1066.                 }

  1067.                 if (0. < dblAccrualDCF)
  1068.                     lsUPM.add (
  1069.                         new org.drip.analytics.output.UnitPeriodMetrics (
  1070.                             startDate(),
  1071.                             iValueDate,
  1072.                             dblAccrualDCF,
  1073.                             (dblUnitAccrual - 1.) / dblAccrualDCF, terminalConvexityAdjustment (
  1074.                                 iValueDate,
  1075.                                 csqc
  1076.                             )
  1077.                         )
  1078.                     );
  1079.             }

  1080.             return 0 == lsUPM.size() ? null : org.drip.analytics.output.CompositePeriodAccrualMetrics.Create (
  1081.                 iResetDate,
  1082.                 lsUPM
  1083.             );
  1084.         } catch (java.lang.Exception e) {
  1085.             e.printStackTrace();
  1086.         }

  1087.         return null;
  1088.     }

  1089.     /**
  1090.      * Create a List of Loss Period Measures
  1091.      *
  1092.      * @param creditComponent Component for which the Measures are to be generated
  1093.      * @param valuationParameters Valuation Parameters from which the Periods are generated
  1094.      * @param cpp Pricer Parameters that control the Generation Characteristics
  1095.      * @param iWorkoutDate Date representing the Absolute End of all the generated Periods
  1096.      * @param csqc Market Parameters
  1097.      *  
  1098.      * @return The Generated Loss Quadrature Metrics
  1099.      */

  1100.     public java.util.List<org.drip.analytics.cashflow.LossQuadratureMetrics> lossMetrics (
  1101.         final org.drip.product.definition.CreditComponent creditComponent,
  1102.         final org.drip.param.valuation.ValuationParams valuationParameters,
  1103.         final org.drip.param.pricer.CreditPricerParams cpp,
  1104.         final int iWorkoutDate,
  1105.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc)
  1106.     {
  1107.         if (
  1108.             null == creditComponent || null == csqc.creditState (creditComponent.creditLabel()) ||
  1109.             null == valuationParameters ||
  1110.             null == cpp ||
  1111.             null == csqc ||
  1112.             startDate() > iWorkoutDate
  1113.         )
  1114.             return null;

  1115.         org.drip.state.discount.MergedDiscountForwardCurve dc = csqc.fundingState
  1116.             (org.drip.state.identifier.FundingLabel.Standard (_strPayCurrency));

  1117.         if (null == dc) return null;

  1118.         int iEndDate = endDate();

  1119.         int iDiscretizationScheme = cpp.discretizationScheme();

  1120.         int iPeriodEndDate = iEndDate < iWorkoutDate ? iEndDate : iWorkoutDate;
  1121.         java.util.List<org.drip.analytics.cashflow.LossQuadratureMetrics> lsLQM = null;

  1122.         if (
  1123.             org.drip.param.pricer.CreditPricerParams.PERIOD_DISCRETIZATION_DAY_STEP == iDiscretizationScheme
  1124.             && (
  1125.                 null == (
  1126.                     lsLQM = org.drip.analytics.support.LossQuadratureGenerator.GenerateDayStepLossPeriods (
  1127.                         creditComponent,
  1128.                         valuationParameters,
  1129.                         this,
  1130.                         iPeriodEndDate,
  1131.                         cpp.unitSize(),
  1132.                         csqc
  1133.                     )
  1134.                 ) || 0 == lsLQM.size()
  1135.             )
  1136.         )
  1137.             return null;

  1138.         if (
  1139.             org.drip.param.pricer.CreditPricerParams.PERIOD_DISCRETIZATION_PERIOD_STEP ==
  1140.             iDiscretizationScheme && (
  1141.                 null == (
  1142.                     lsLQM = org.drip.analytics.support.LossQuadratureGenerator.GeneratePeriodUnitLossPeriods (
  1143.                         creditComponent,
  1144.                         valuationParameters,
  1145.                         this,
  1146.                         iPeriodEndDate,
  1147.                         cpp.unitSize(),
  1148.                         csqc
  1149.                     )
  1150.                 ) || 0 == lsLQM.size()
  1151.             )
  1152.         )
  1153.             return null;

  1154.         if (
  1155.             org.drip.param.pricer.CreditPricerParams.PERIOD_DISCRETIZATION_FULL_COUPON ==
  1156.             iDiscretizationScheme && (
  1157.                 null == (
  1158.                     lsLQM = org.drip.analytics.support.LossQuadratureGenerator.GenerateWholeLossPeriods (
  1159.                         creditComponent,
  1160.                         valuationParameters,
  1161.                         this,
  1162.                         iPeriodEndDate,
  1163.                         csqc
  1164.                     )
  1165.                 ) || 0 == lsLQM.size()
  1166.             )
  1167.         )
  1168.             return null;

  1169.         return lsLQM;
  1170.     }

  1171.     /**
  1172.      * Generate the Forward Predictor/Response Constraint
  1173.      *
  1174.      * @param iValueDate The Valuation Date
  1175.      * @param csqc The Market Curve Surface/Quote Set
  1176.      * @param pqs Product Quote Set
  1177.      *
  1178.      * @return The Forward Predictor/Response Constraint
  1179.      */

  1180.     public org.drip.state.estimator.PredictorResponseWeightConstraint forwardPRWC (
  1181.         final int iValueDate,
  1182.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1183.         final org.drip.product.calib.ProductQuoteSet pqs)
  1184.     {
  1185.         if (null == pqs) return null;

  1186.         double dblDF = java.lang.Double.NaN;
  1187.         double dblFX = java.lang.Double.NaN;
  1188.         double dblBasis = java.lang.Double.NaN;
  1189.         double dblAccrued = java.lang.Double.NaN;
  1190.         double dblBaseRate = java.lang.Double.NaN;
  1191.         double dblNotional = java.lang.Double.NaN;
  1192.         double dblSurvival = java.lang.Double.NaN;

  1193.         org.drip.product.calib.CompositePeriodQuoteSet cpqs = periodQuoteSet (
  1194.             pqs,
  1195.             csqc
  1196.         );

  1197.         try {
  1198.             dblDF = df (csqc);

  1199.             dblFX = fx (csqc);

  1200.             dblSurvival = survival (csqc);

  1201.             int iEndDate = endDate();

  1202.             dblBasis = cpqs.containsBasis() ? cpqs.basis() : 0.;

  1203.             dblBaseRate = cpqs.containsBaseRate() ? cpqs.baseRate() : 0.;

  1204.             dblNotional = notional (iEndDate) * couponFactor (iEndDate);

  1205.             dblAccrued = dblNotional * dblFX * accrualDCF (iValueDate) * (dblBaseRate + dblBasis);
  1206.         } catch (java.lang.Exception e) {
  1207.             e.printStackTrace();

  1208.             return null;
  1209.         }

  1210.         org.drip.analytics.output.CompositePeriodCouponMetrics cpm = couponMetrics (
  1211.             iValueDate,
  1212.             csqc
  1213.         );

  1214.         if (null == cpm) return null;

  1215.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1216.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1217.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  1218.         org.drip.state.identifier.ForwardLabel forwardLabel = floaterLabel instanceof
  1219.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  1220.                 null;

  1221.         if (null == forwardLabel) {
  1222.             for (org.drip.analytics.output.UnitPeriodMetrics upm : cpm.unitMetrics()) {
  1223.                 if (!prwc.updateValue (-1. * dblNotional * dblFX * upm.dcf() * (dblBaseRate + dblBasis) *
  1224.                     dblSurvival * dblDF * upm.convAdj().cumulative()))
  1225.                     return null;
  1226.             }

  1227.             if (!prwc.updateValue (dblAccrued)) return null;
  1228.         } else if (!forwardLabel.match (pqs.forwardLabel())) {
  1229.             java.util.List<org.drip.analytics.output.UnitPeriodMetrics> lsUPM = cpm.unitMetrics();

  1230.             for (int i = 0; i < lsUPM.size(); ++i) {
  1231.                 org.drip.analytics.output.UnitPeriodMetrics upm = lsUPM.get (i);

  1232.                 try {
  1233.                     if (!prwc.updateValue (-1. * dblNotional * dblFX * upm.dcf() * (_lsCUP.get (i).baseRate
  1234.                         (csqc) + dblBasis) * dblSurvival * dblDF * upm.convAdj().cumulative()))
  1235.                         return null;
  1236.                 } catch (java.lang.Exception e) {
  1237.                     e.printStackTrace();

  1238.                     return null;
  1239.                 }
  1240.             }

  1241.             if (!prwc.updateValue (dblAccrued)) return null;
  1242.         } else {
  1243.             for (org.drip.analytics.output.UnitPeriodMetrics upm : cpm.unitMetrics()) {
  1244.                 int iDateAnchor = upm.endDate();

  1245.                 if (cpqs.containsBaseRate()) {
  1246.                     if (
  1247.                         !prwc.addPredictorResponseWeight (
  1248.                             iDateAnchor,
  1249.                             1.
  1250.                         )
  1251.                     )
  1252.                         return null;

  1253.                     if (
  1254.                         !prwc.addDResponseWeightDManifestMeasure (
  1255.                             "PV",
  1256.                             iDateAnchor,
  1257.                             1.
  1258.                         )
  1259.                     ) return null;
  1260.                 } else {
  1261.                     double dblForwardLoading = dblNotional * dblFX * upm.dcf() * dblSurvival * dblDF *
  1262.                         upm.convAdj().cumulative();

  1263.                     if (
  1264.                         !prwc.addPredictorResponseWeight (
  1265.                             iDateAnchor,
  1266.                             dblForwardLoading
  1267.                         )
  1268.                     )
  1269.                         return null;

  1270.                     if (
  1271.                         !prwc.addDResponseWeightDManifestMeasure (
  1272.                             "PV",
  1273.                             iDateAnchor,
  1274.                             dblForwardLoading
  1275.                         )
  1276.                     )
  1277.                         return null;

  1278.                     if (!prwc.updateValue (-1. * dblForwardLoading * dblBasis)) return null;
  1279.                 }
  1280.             }

  1281.             if (!prwc.updateValue (cpqs.containsBaseRate() ? dblBaseRate : dblAccrued)) return null;
  1282.         }

  1283.         if (
  1284.             !prwc.updateDValueDManifestMeasure (
  1285.                 "PV",
  1286.                 1.
  1287.             )
  1288.         )
  1289.             return null;

  1290.         return prwc;
  1291.     }

  1292.     /**
  1293.      * Generate the Funding Predictor/Response Constraint
  1294.      *
  1295.      * @param iValueDate The Valuation Date
  1296.      * @param csqc The Market Curve Surface/Quote Set
  1297.      * @param pqs Product Quote Set
  1298.      *
  1299.      * @return The Funding Predictor/Response Constraint
  1300.      */

  1301.     public org.drip.state.estimator.PredictorResponseWeightConstraint fundingPRWC (
  1302.         final int iValueDate,
  1303.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1304.         final org.drip.product.calib.ProductQuoteSet pqs)
  1305.     {
  1306.         if (null == pqs) return null;

  1307.         double dblDF = java.lang.Double.NaN;
  1308.         double dblFX = java.lang.Double.NaN;
  1309.         double dblBasis = java.lang.Double.NaN;
  1310.         double dblAccrued = java.lang.Double.NaN;
  1311.         double dblBaseRate = java.lang.Double.NaN;
  1312.         double dblNotional = java.lang.Double.NaN;
  1313.         double dblSurvival = java.lang.Double.NaN;

  1314.         org.drip.product.calib.CompositePeriodQuoteSet cpqs = periodQuoteSet (
  1315.             pqs,
  1316.             csqc
  1317.         );

  1318.         try {
  1319.             dblFX = fx (csqc);

  1320.             dblSurvival = survival (csqc);

  1321.             dblBasis = cpqs.containsBasis() ? cpqs.basis() : 0.;

  1322.             dblBaseRate = cpqs.containsBaseRate() ? cpqs.baseRate() : 0.;

  1323.             dblNotional = notional (_iPayDate) * couponFactor (_iPayDate);

  1324.             dblAccrued = dblNotional * dblFX * accrualDCF (iValueDate) * (dblBaseRate + dblBasis);
  1325.         } catch (java.lang.Exception e) {
  1326.             e.printStackTrace();

  1327.             return null;
  1328.         }

  1329.         org.drip.analytics.output.CompositePeriodCouponMetrics cpcm = couponMetrics (
  1330.             iValueDate,
  1331.             csqc
  1332.         );

  1333.         if (null == cpcm) return null;

  1334.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1335.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1336.         org.drip.state.identifier.FundingLabel fundingLabel = fundingLabel();

  1337.         if (!fundingLabel.match (pqs.fundingLabel())) {
  1338.             try {
  1339.                 dblDF = df (csqc);
  1340.             } catch (java.lang.Exception e) {
  1341.                 e.printStackTrace();

  1342.                 return null;
  1343.             }

  1344.             for (org.drip.analytics.output.UnitPeriodMetrics upm : cpcm.unitMetrics()) {
  1345.                 if (!prwc.updateValue (-1. * dblNotional * dblFX * upm.dcf() * (dblBaseRate + dblBasis) *
  1346.                     dblSurvival * dblDF * upm.convAdj().cumulative()))
  1347.                     return null;
  1348.             }
  1349.         } else {
  1350.             for (org.drip.analytics.output.UnitPeriodMetrics upm : cpcm.unitMetrics()) {
  1351.                 double dblFundingLoading = dblNotional * dblFX * upm.dcf() * (dblBaseRate + dblBasis) *
  1352.                     dblSurvival * upm.convAdj().cumulative();

  1353.                 if (
  1354.                     !prwc.addPredictorResponseWeight (
  1355.                         _iPayDate,
  1356.                         dblFundingLoading
  1357.                     )
  1358.                 )
  1359.                     return null;

  1360.                 if (
  1361.                     !prwc.addDResponseWeightDManifestMeasure (
  1362.                         "PV",
  1363.                         _iPayDate,
  1364.                         dblFundingLoading
  1365.                     )
  1366.                 )
  1367.                     return null;
  1368.             }
  1369.         }

  1370.         if (!prwc.updateValue (dblAccrued)) return null;

  1371.         if (
  1372.             !prwc.updateDValueDManifestMeasure (
  1373.                 "PV",
  1374.                 1.
  1375.             )
  1376.         )
  1377.             return null;

  1378.         return prwc;
  1379.     }

  1380.     /**
  1381.      * Generate the Merged Forward/Funding Predictor/Response Constraint
  1382.      *
  1383.      * @param iValueDate The Valuation Date
  1384.      * @param csqc The Market Curve Surface/Quote Set
  1385.      * @param pqs Product Quote Set
  1386.      *
  1387.      * @return The Merged Forward/Funding Predictor/Response Constraint
  1388.      */

  1389.     public org.drip.state.estimator.PredictorResponseWeightConstraint forwardFundingPRWC (
  1390.         final int iValueDate,
  1391.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1392.         final org.drip.product.calib.ProductQuoteSet pqs)
  1393.     {
  1394.         if (null == pqs) return null;

  1395.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  1396.         org.drip.state.identifier.ForwardLabel forwardLabel = floaterLabel instanceof
  1397.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  1398.                 null;

  1399.         if (null == forwardLabel || !fundingLabel().match (pqs.fundingLabel()))
  1400.             return fundingPRWC (
  1401.                 iValueDate,
  1402.                 csqc,
  1403.                 pqs
  1404.             );

  1405.         double dblFX = java.lang.Double.NaN;
  1406.         double dblAccrued = java.lang.Double.NaN;
  1407.         double dblNotional = java.lang.Double.NaN;
  1408.         double dblSurvival = java.lang.Double.NaN;

  1409.         org.drip.product.calib.CompositePeriodQuoteSet cpqs = periodQuoteSet (
  1410.             pqs,
  1411.             csqc
  1412.         );

  1413.         try {
  1414.             dblFX = fx (csqc);

  1415.             dblSurvival = survival (csqc);

  1416.             dblNotional = notional (_iPayDate) * couponFactor (_iPayDate);

  1417.             dblAccrued = accrualDCF (iValueDate) * cpqs.basis() * dblNotional * dblFX;
  1418.         } catch (java.lang.Exception e) {
  1419.             e.printStackTrace();

  1420.             return null;
  1421.         }

  1422.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1423.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1424.         if (cpqs.containsBaseRate()) {
  1425.             int iEndDate = endDate();

  1426.             int iStartDate = startDate();

  1427.             org.drip.analytics.cashflow.ComposableUnitPeriod cup = _lsCUP.get (0);

  1428.             try {
  1429.                 double dblForwardDF = 1. / (
  1430.                     1. + org.drip.analytics.daycount.Convention.YearFraction (
  1431.                         iStartDate,
  1432.                         iEndDate,
  1433.                         cup.couponDC(),
  1434.                         false,
  1435.                         null,
  1436.                         cup.calendar()
  1437.                     ) * cpqs.baseRate()
  1438.                 );

  1439.                 if (
  1440.                     !prwc.addPredictorResponseWeight (
  1441.                         iStartDate,
  1442.                         dblNotional * dblForwardDF
  1443.                     )
  1444.                 )
  1445.                     return null;

  1446.                 if (
  1447.                     !prwc.addDResponseWeightDManifestMeasure (
  1448.                         "PV",
  1449.                         iStartDate,
  1450.                         dblNotional * dblForwardDF
  1451.                     )
  1452.                 )
  1453.                     return null;
  1454.             } catch (java.lang.Exception e) {
  1455.                 e.printStackTrace();

  1456.                 return null;
  1457.             }

  1458.             if (
  1459.                 !prwc.addPredictorResponseWeight (
  1460.                     iEndDate,
  1461.                     -1. * dblNotional
  1462.                 )
  1463.             )
  1464.                 return null;

  1465.             if (
  1466.                 !prwc.addDResponseWeightDManifestMeasure (
  1467.                     "PV",
  1468.                     iEndDate,
  1469.                     -1. * dblNotional
  1470.                 )
  1471.             )
  1472.                 return null;
  1473.         } else {
  1474.             java.util.List<org.drip.analytics.output.UnitPeriodConvexityMetrics> lsUPCM =
  1475.                 unitPeriodConvexityMetrics (
  1476.                     iValueDate,
  1477.                     csqc
  1478.                 );

  1479.             if (null == lsUPCM || 0 == lsUPCM.size()) return null;

  1480.             for (org.drip.analytics.output.UnitPeriodConvexityMetrics upcm : lsUPCM) {
  1481.                 double dblFundingLoading = dblNotional * dblFX * dblSurvival * upcm.convAdj().cumulative();

  1482.                 int iStartDate = upcm.startDate();

  1483.                 int iEndDate = upcm.endDate();

  1484.                 if (
  1485.                     !prwc.addPredictorResponseWeight (
  1486.                         iStartDate,
  1487.                         dblFundingLoading
  1488.                     )
  1489.                 )
  1490.                     return null;

  1491.                 if (
  1492.                     !prwc.addPredictorResponseWeight (
  1493.                         iEndDate,
  1494.                         -1. * dblFundingLoading
  1495.                     )
  1496.                 )
  1497.                     return null;

  1498.                 if (
  1499.                     !prwc.addDResponseWeightDManifestMeasure (
  1500.                         "PV",
  1501.                         iStartDate,
  1502.                         dblFundingLoading
  1503.                     )
  1504.                 )
  1505.                     return null;

  1506.                 if (
  1507.                     !prwc.addDResponseWeightDManifestMeasure (
  1508.                         "PV",
  1509.                         iEndDate,
  1510.                         -1. * dblFundingLoading
  1511.                     )
  1512.                 )
  1513.                     return null;
  1514.             }

  1515.             if (!prwc.updateValue (dblAccrued)) return null;
  1516.         }

  1517.         if (
  1518.             !prwc.updateDValueDManifestMeasure (
  1519.                 "PV",
  1520.                 1.
  1521.             )
  1522.         )
  1523.             return null;

  1524.         if (!prwc.addMergeLabel (forwardLabel)) return null;

  1525.         return prwc;
  1526.     }

  1527.     /**
  1528.      * Generate the FX Predictor/Response Constraint
  1529.      *
  1530.      * @param iValueDate The Valuation Date
  1531.      * @param csqc The Market Curve Surface/Quote Set
  1532.      * @param pqs Product Quote Set
  1533.      *
  1534.      * @return The FX Predictor/Response Constraint
  1535.      */

  1536.     public org.drip.state.estimator.PredictorResponseWeightConstraint fxPRWC (
  1537.         final int iValueDate,
  1538.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1539.         final org.drip.product.calib.ProductQuoteSet pqs)
  1540.     {
  1541.         if (null == pqs) return null;

  1542.         int iEndDate = endDate();

  1543.         if (iValueDate > iEndDate) return null;

  1544.         org.drip.state.identifier.FXLabel fxLabel = fxLabel();

  1545.         if (null == fxLabel || !fxLabel.match (pqs.fxLabel())) return null;

  1546.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1547.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1548.         if (
  1549.             !prwc.addPredictorResponseWeight (
  1550.                 iEndDate,
  1551.                 1.
  1552.             )
  1553.         )
  1554.             return null;

  1555.         if (
  1556.             !prwc.addDResponseWeightDManifestMeasure (
  1557.                 "Outright",
  1558.                 iEndDate,
  1559.                 1.
  1560.             )
  1561.         )
  1562.             return null;

  1563.         return prwc;
  1564.     }

  1565.     /**
  1566.      * Generate the Volatility Predictor/Response Constraint
  1567.      *
  1568.      * @param iValueDate The Valuation Date
  1569.      * @param csqc The Market Curve Surface/Quote Set
  1570.      * @param pqs Product Quote Set
  1571.      *
  1572.      * @return The Volatility Predictor/Response Constraint
  1573.      */

  1574.     public org.drip.state.estimator.PredictorResponseWeightConstraint volatilityPRWC (
  1575.         final int iValueDate,
  1576.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1577.         final org.drip.product.calib.ProductQuoteSet pqs)
  1578.     {
  1579.         if (null == pqs) return null;

  1580.         int iEndDate = endDate();

  1581.         if (iValueDate > iEndDate) return null;

  1582.         org.drip.state.identifier.VolatilityLabel volLabel = pqs.volatilityLabel();

  1583.         if (null == volLabel) return null;

  1584.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  1585.         org.drip.state.identifier.ForwardLabel forwardLabel = floaterLabel instanceof
  1586.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  1587.                 null;

  1588.         if (null == forwardLabel || !forwardLabel.match (volLabel.underlyingLatentState())) return null;

  1589.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1590.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1591.         if (
  1592.             !prwc.addPredictorResponseWeight (
  1593.                 iEndDate,
  1594.                 1.
  1595.             )
  1596.         )
  1597.             return null;

  1598.         if (
  1599.             !prwc.addDResponseWeightDManifestMeasure (
  1600.                 "OptionPV",
  1601.                 iEndDate,
  1602.                 1.
  1603.             )
  1604.         )
  1605.             return null;

  1606.         return prwc;
  1607.     }

  1608.     /**
  1609.      * Retrieve the Period Calibration Quotes from the specified product quote set
  1610.      *
  1611.      * @param pqs The Product Quote Set
  1612.      * @param csqc The Market Curve Surface/Quote Set
  1613.      *
  1614.      * @return The Composed Period Quote Set
  1615.      */

  1616.     public abstract org.drip.product.calib.CompositePeriodQuoteSet periodQuoteSet (
  1617.         final org.drip.product.calib.ProductQuoteSet pqs,
  1618.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc);

  1619.     /**
  1620.      * Retrieve the Period Calibration Basis Quote from the specified product quote set
  1621.      *
  1622.      * @param pqs The Product Quote Set
  1623.      *
  1624.      * @return The Period Calibration Basis Quote
  1625.      */

  1626.     public abstract double basisQuote (
  1627.         final org.drip.product.calib.ProductQuoteSet pqs);
  1628. }