Stream.java

  1. package org.drip.product.rates;

  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>Stream</i> implements the fixed and the floating streams.
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  85.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  86.  *      <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>
  87.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/rates/README.md">Fixed Income Multi-Stream Components</a></li>
  88.  *  </ul>
  89.  * <br><br>
  90.  *
  91.  * @author Lakshmi Krishnamurthy
  92.  */

  93. public class Stream {
  94.     private java.util.List<org.drip.analytics.cashflow.CompositePeriod> _lsPeriod = null;

  95.     private double fxAdjustedNotional (
  96.         final int iDate,
  97.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs)
  98.         throws java.lang.Exception
  99.     {
  100.         org.drip.analytics.cashflow.CompositePeriod cpLeft = _lsPeriod.get (0);

  101.         int iLeftStartDate = cpLeft.startDate();

  102.         if (iDate <= iLeftStartDate)
  103.             return cpLeft.notional (iLeftStartDate) * cpLeft.couponFactor (iLeftStartDate) * cpLeft.fx
  104.                 (csqs);

  105.         for (org.drip.analytics.cashflow.CompositePeriod cp : _lsPeriod) {
  106.             if (cp.contains (iDate))
  107.                 return cp.notional (iDate) * cp.couponFactor (iDate) * cp.fx (csqs);
  108.         }

  109.         org.drip.analytics.cashflow.CompositePeriod cpRight = _lsPeriod.get (_lsPeriod.size() - 1);

  110.         int iRightEndDate = cpRight.endDate();

  111.         return cpRight.notional (iRightEndDate) * cpRight.couponFactor (iRightEndDate) * cpRight.fx (csqs);
  112.     }

  113.     /**
  114.      * Stream constructor
  115.      *
  116.      * @param lsPeriod List of the Coupon Periods
  117.      *
  118.      * @throws java.lang.Exception Thrown if inputs are invalid
  119.      */

  120.     public Stream (
  121.         final java.util.List<org.drip.analytics.cashflow.CompositePeriod> lsPeriod)
  122.         throws java.lang.Exception
  123.     {
  124.         if (null == (_lsPeriod = lsPeriod) || 0 == _lsPeriod.size())
  125.             throw new java.lang.Exception ("Stream ctr => Invalid Input params!");
  126.     }

  127.     /**
  128.      * Retrieve a list of the component's coupon periods
  129.      *
  130.      * @return List of Coupon Period
  131.      */

  132.     public java.util.List<org.drip.analytics.cashflow.CompositePeriod> periods()
  133.     {
  134.         return _lsPeriod;
  135.     }

  136.     /**
  137.      * Retrieve the Stream Frequency
  138.      *
  139.      * @return The Stream Frequency
  140.      */

  141.     public int freq()
  142.     {
  143.         return _lsPeriod.get (0).freq();
  144.     }

  145.     /**
  146.      * Retrieve the Coupon Day Count
  147.      *
  148.      * @return The Coupon Day Count
  149.      */

  150.     public java.lang.String couponDC()
  151.     {
  152.         return _lsPeriod.get (0).periods().get (0).couponDC();
  153.     }

  154.     /**
  155.      * Retrieve the Coupon EOM Adjustment
  156.      *
  157.      * @return The Coupon EOM Adjustment
  158.      */

  159.     public boolean couponEOMAdjustment()
  160.     {
  161.         return _lsPeriod.get (0).periods().get (0).couponEOMAdjustment();
  162.     }

  163.     /**
  164.      * Retrieve the Calendar
  165.      *
  166.      * @return The Calendar
  167.      */

  168.     public java.lang.String calendar()
  169.     {
  170.         return _lsPeriod.get (0).periods().get (0).calendar();
  171.     }

  172.     /**
  173.      * Retrieve the Accrual Day Count
  174.      *
  175.      * @return The Accrual Day Count
  176.      */

  177.     public java.lang.String accrualDC()
  178.     {
  179.         return _lsPeriod.get (0).periods().get (0).accrualDC();
  180.     }

  181.     /**
  182.      * Retrieve the Accrual EOM Adjustment
  183.      *
  184.      * @return The Accrual EOM Adjustment
  185.      */

  186.     public boolean accrualEOMAdjustment()
  187.     {
  188.         return _lsPeriod.get (0).periods().get (0).accrualEOMAdjustment();
  189.     }

  190.     /**
  191.      * Retrieve the Credit Label
  192.      *
  193.      * @return The Credit Label
  194.      */

  195.     public org.drip.state.identifier.EntityCDSLabel creditLabel()
  196.     {
  197.         return _lsPeriod.get (0).creditLabel();
  198.     }

  199.     /**
  200.      * Retrieve the Floater Label
  201.      *
  202.      * @return The Floater Label
  203.      */

  204.     public org.drip.state.identifier.FloaterLabel floaterLabel()
  205.     {
  206.         return _lsPeriod.get (0).floaterLabel();
  207.     }

  208.     /**
  209.      * Retrieve the Forward Label, if Present
  210.      *
  211.      * @return The Forward Label
  212.      */

  213.     public org.drip.state.identifier.ForwardLabel forwardLabel()
  214.     {
  215.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  216.         return null != floaterLabel && floaterLabel instanceof org.drip.state.identifier.ForwardLabel ?
  217.             (org.drip.state.identifier.ForwardLabel) floaterLabel : null;
  218.     }

  219.     /**
  220.      * Retrieve the OTC Fix Float Label, if Present
  221.      *
  222.      * @return The OTC Fix Float Label
  223.      */

  224.     public org.drip.state.identifier.OTCFixFloatLabel otcFixFloatLabel()
  225.     {
  226.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  227.         return null != floaterLabel && floaterLabel instanceof org.drip.state.identifier.OTCFixFloatLabel ?
  228.             (org.drip.state.identifier.OTCFixFloatLabel) floaterLabel : null;
  229.     }

  230.     /**
  231.      * Retrieve the Funding Label
  232.      *
  233.      * @return The Funding Label
  234.      */

  235.     public org.drip.state.identifier.FundingLabel fundingLabel()
  236.     {
  237.         return _lsPeriod.get (0).fundingLabel();
  238.     }

  239.     /**
  240.      * Retrieve the FX Label
  241.      *
  242.      * @return The FX Label
  243.      */

  244.     public org.drip.state.identifier.FXLabel fxLabel()
  245.     {
  246.         return _lsPeriod.get (0).fxLabel();
  247.     }

  248.     /**
  249.      * Retrieve the Coupon Period List
  250.      *
  251.      * @return The Coupon Period List
  252.      */

  253.     public java.util.List<org.drip.analytics.cashflow.CompositePeriod> cashFlowPeriod()
  254.     {
  255.         return _lsPeriod;
  256.     }

  257.     /**
  258.      * Retrieve the Period Instance enveloping the specified Date
  259.      *
  260.      * @param iDate The Date
  261.      *
  262.      * @return The Period Instance enveloping the specified Date
  263.      */

  264.     public org.drip.analytics.cashflow.CompositePeriod containingPeriod (
  265.         final int iDate)
  266.     {
  267.         try {
  268.             for (org.drip.analytics.cashflow.CompositePeriod cp : _lsPeriod) {
  269.                 if (cp.contains (iDate)) return cp;
  270.             }
  271.         } catch (java.lang.Exception e) {
  272.             e.printStackTrace();
  273.         }

  274.         return null;
  275.     }

  276.     /**
  277.      * Retrieve the Initial Notional
  278.      *
  279.      * @return The Initial Notional
  280.      */

  281.     public double initialNotional()
  282.     {
  283.         return _lsPeriod.get (0).baseNotional();
  284.     }

  285.     /**
  286.      * Retrieve the Notional corresponding to the specified Date
  287.      *
  288.      * @param iDate The Date
  289.      *
  290.      * @return The Notional corresponding to the specified Date
  291.      *
  292.      * @throws java.lang.Exception Thrown if the Notional cannot be computed
  293.      */

  294.     public double notional (
  295.         final int iDate)
  296.         throws java.lang.Exception
  297.     {
  298.         int iEffectiveDate = effective().julian();

  299.         int iAdjustedDate = iEffectiveDate > iDate ? iEffectiveDate : iDate;

  300.         org.drip.analytics.cashflow.CompositePeriod cp = containingPeriod (iAdjustedDate);

  301.         if (null == cp) throw new java.lang.Exception ("Stream::notional => Invalid Input");

  302.         return cp.notional (iAdjustedDate);
  303.     }

  304.     /**
  305.      * Retrieve the Notional aggregated over the Date Pairs
  306.      *
  307.      * @param iDate1 The Date #1
  308.      * @param iDate2 The Date #2
  309.      *
  310.      * @return The Notional aggregated over the Date Pairs
  311.      *
  312.      * @throws java.lang.Exception Thrown if the Notional cannot be computed
  313.      */

  314.     public double notional (
  315.         final int iDate1,
  316.         final int iDate2)
  317.         throws java.lang.Exception
  318.     {
  319.         org.drip.analytics.cashflow.CompositePeriod cp = containingPeriod (iDate1);

  320.         if (null == cp || !cp.contains (iDate2))
  321.             throw new java.lang.Exception ("Stream::notional => Invalid Inputs");

  322.         org.drip.numerical.common.Array2D notlSchedule = cp.notionalSchedule();

  323.         return initialNotional() * (null == notlSchedule ? 1. : notlSchedule.y (iDate1, iDate2));
  324.     }

  325.     /**
  326.      * Retrieve the Effective Date
  327.      *
  328.      * @return The Effective Date
  329.      */

  330.     public org.drip.analytics.date.JulianDate effective()
  331.     {
  332.         try {
  333.             return new org.drip.analytics.date.JulianDate (_lsPeriod.get (0).startDate());
  334.         } catch (java.lang.Exception e) {
  335.             e.printStackTrace();
  336.         }

  337.         return null;
  338.     }

  339.     /**
  340.      * Retrieve the Maturity Date
  341.      *
  342.      * @return The Maturity Date
  343.      */

  344.     public org.drip.analytics.date.JulianDate maturity()
  345.     {
  346.         try {
  347.             return new org.drip.analytics.date.JulianDate (_lsPeriod.get (_lsPeriod.size() - 1).endDate());
  348.         } catch (java.lang.Exception e) {
  349.             e.printStackTrace();
  350.         }

  351.         return null;
  352.     }

  353.     /**
  354.      * Retrieve the First Coupon Pay Date
  355.      *
  356.      * @return The First Coupon Pay Date
  357.      */

  358.     public org.drip.analytics.date.JulianDate firstCouponDate()
  359.     {
  360.         try {
  361.             return new org.drip.analytics.date.JulianDate (_lsPeriod.get (0).endDate());
  362.         } catch (java.lang.Exception e) {
  363.             e.printStackTrace();
  364.         }

  365.         return null;
  366.     }

  367.     /**
  368.      * Retrieve the Coupon Currency
  369.      *
  370.      * @return The Coupon Currency
  371.      */

  372.     public java.lang.String couponCurrency()
  373.     {
  374.         return _lsPeriod.get (_lsPeriod.size() - 1).couponCurrency();
  375.     }

  376.     /**
  377.      * Retrieve the Pay Currency
  378.      *
  379.      * @return The Pay Currency
  380.      */

  381.     public java.lang.String payCurrency()
  382.     {
  383.         return _lsPeriod.get (_lsPeriod.size() - 1).payCurrency();
  384.     }

  385.     /**
  386.      * Retrieve the Cash Flow Currency Set
  387.      *
  388.      * @return The Cash Flow Currency Set
  389.      */

  390.     public java.util.Set<java.lang.String> cashflowCurrencySet()
  391.     {
  392.         java.util.Set<java.lang.String> setCcy = new java.util.HashSet<java.lang.String>();

  393.         setCcy.add (payCurrency());

  394.         setCcy.add (couponCurrency());

  395.         return setCcy;
  396.     }

  397.     /**
  398.      * Retrieve the Stream Name
  399.      *
  400.      * @return The Stream Name
  401.      */

  402.     public java.lang.String name()
  403.     {
  404.         org.drip.state.identifier.FloaterLabel floaterLabel = floaterLabel();

  405.         java.lang.String strTrailer = "::{" + effective() + "->" + maturity() + "}";

  406.         if (null != floaterLabel)
  407.             return "FLOATSTREAM::" + payCurrency() + "::" + floaterLabel.fullyQualifiedName() + strTrailer;

  408.         return "FIXEDSTREAM::" + payCurrency() + "/" + couponCurrency() + "::" + (12 / freq()) + strTrailer;
  409.     }

  410.     /**
  411.      * Get the Coupon Metrics for the period corresponding to the specified accrual end date
  412.      *
  413.      * @param iAccrualEndDate The Accrual End Date
  414.      * @param valParams Valuation parameters
  415.      * @param csqs Market Parameters
  416.      *
  417.      * @return The Coupon Metrics for the period corresponding to the specified accrual end date
  418.      */

  419.     public org.drip.analytics.output.CompositePeriodCouponMetrics coupon (
  420.         final int iAccrualEndDate,
  421.         final org.drip.param.valuation.ValuationParams valParams,
  422.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs)
  423.     {
  424.         if (null == valParams) return null;

  425.         org.drip.analytics.cashflow.CompositePeriod cp = containingPeriod (iAccrualEndDate);

  426.         return null == cp ? null : cp.couponMetrics (valParams.valueDate(), csqs);
  427.     }

  428.     /**
  429.      * Generate the Calibration Quote Set corresponding to the specified Latent State Array
  430.      *
  431.      * @param aLSS The Latent State Array
  432.      *
  433.      * @return The Calibration Quote Set corresponding to the specified Latent State Array
  434.      */

  435.     public org.drip.product.calib.ProductQuoteSet calibQuoteSet (
  436.         final org.drip.state.representation.LatentStateSpecification[] aLSS)
  437.     {
  438.         try {
  439.             return null == floaterLabel() ? new org.drip.product.calib.FixedStreamQuoteSet (aLSS) : new
  440.                 org.drip.product.calib.FloatingStreamQuoteSet (aLSS);
  441.         } catch (java.lang.Exception e) {
  442.             e.printStackTrace();
  443.         }

  444.         return null;
  445.     }

  446.     /**
  447.      * Retrieve the Stream Coupon Basis
  448.      *
  449.      * @return The Stream Coupon Basis
  450.      */

  451.     public double basis()
  452.     {
  453.         return _lsPeriod.get (0).basis();
  454.     }

  455.     /**
  456.      * Generate a Value Map for the Stream
  457.      *
  458.      * @param valParams The Valuation Parameters
  459.      * @param pricerParams The Pricer parameters
  460.      * @param csqs The Market Parameters
  461.      * @param vcp Valuation Customization Parameters
  462.      *
  463.      * @return The Value Map for the Stream
  464.      */

  465.     public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> value (
  466.         final org.drip.param.valuation.ValuationParams valParams,
  467.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  468.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  469.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  470.     {
  471.         if (null == valParams || null == csqs) return null;

  472.         org.drip.state.discount.MergedDiscountForwardCurve dcFunding = csqs.fundingState (fundingLabel());

  473.         if (null == dcFunding) return null;

  474.         long lStart = System.nanoTime();

  475.         int iValueDate = valParams.valueDate();

  476.         double dblAccrued01 = 0.;
  477.         double dblTotalCoupon = 0.;
  478.         double dblCumulativeCouponDCF = 0.;
  479.         double dblCumulativeCouponAmount = 0.;
  480.         double dblAccrualCoupon = java.lang.Double.NaN;
  481.         double dblUnadjustedDirtyPV = 0.;
  482.         double dblUnadjustedDirtyDV01 = 0.;
  483.         double dblCompoundingAdjustedDirtyPV = 0.;
  484.         double dblCompoundingAdjustedDirtyDV01 = 0.;
  485.         double dblCashPayDF = java.lang.Double.NaN;
  486.         int iResetDate = java.lang.Integer.MIN_VALUE;
  487.         double dblFXAdjustedValueNotional = java.lang.Double.NaN;
  488.         double dblCreditForwardConvexityAdjustedDirtyPV = 0.;
  489.         double dblCreditForwardConvexityAdjustedDirtyDV01 = 0.;
  490.         double dblCreditFundingConvexityAdjustedDirtyPV = 0.;
  491.         double dblCreditFundingConvexityAdjustedDirtyDV01 = 0.;
  492.         double dblCreditFXConvexityAdjustedDirtyPV = 0.;
  493.         double dblCreditFXConvexityAdjustedDirtyDV01 = 0.;
  494.         double dblCumulativeConvexityAdjustedDirtyPV = 0.;
  495.         double dblCumulativeConvexityAdjustedDirtyDV01 = 0.;
  496.         double dblForwardFundingConvexityAdjustedDirtyPV = 0.;
  497.         double dblForwardFundingConvexityAdjustedDirtyDV01 = 0.;
  498.         double dblForwardFXConvexityAdjustedDirtyPV = 0.;
  499.         double dblForwardFXConvexityAdjustedDirtyDV01 = 0.;
  500.         double dblFundingFXConvexityAdjustedDirtyPV = 0.;
  501.         double dblFundingFXConvexityAdjustedDirtyDV01 = 0.;

  502.         if (iValueDate >= maturity().julian()) return null;

  503.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  504.             double dblPeriodFX = java.lang.Double.NaN;
  505.             double dblPeriodNotional = java.lang.Double.NaN;
  506.             double dblUnadjustedDirtyPeriodDV01 = java.lang.Double.NaN;

  507.             int iPeriodPayDate = period.payDate();

  508.             int iPeriodEndDate = period.endDate();

  509.             try {
  510.                 dblPeriodNotional = period.notional (iPeriodEndDate) * period.couponFactor (iPeriodEndDate);

  511.                 dblPeriodFX = period.fx (csqs);
  512.             } catch (java.lang.Exception e) {
  513.                 e.printStackTrace();

  514.                 return null;
  515.             }

  516.             if (iPeriodPayDate < iValueDate) {
  517.                 org.drip.analytics.output.CompositePeriodCouponMetrics cpcm = period.couponMetrics
  518.                     (iPeriodEndDate, csqs);

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

  520.                 double dblPeriodDCF = cpcm.dcf();

  521.                 dblCumulativeCouponDCF += dblPeriodDCF;

  522.                 dblCumulativeCouponAmount += dblPeriodNotional * dblPeriodFX * cpcm.rate() * dblPeriodDCF;

  523.                 continue;
  524.             }

  525.             org.drip.analytics.output.CompositePeriodCouponMetrics cpcm = period.couponMetrics (iValueDate,
  526.                 csqs);

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

  528.             double dblPeriodDCF = cpcm.dcf();

  529.             double dblPeriodFullRate = cpcm.rate();

  530.             org.drip.analytics.output.CompositePeriodAccrualMetrics cpam = period.accrualMetrics (iValueDate,
  531.                 csqs);

  532.             try {
  533.                 if (null != cpam) {
  534.                     dblAccrualCoupon = cpam.rate();

  535.                     iResetDate = cpam.resetDate();

  536.                     double dblPeriodAccrualDCF = cpam.dcf();

  537.                     dblCumulativeCouponDCF += dblPeriodAccrualDCF;
  538.                     dblAccrued01 = 0.0001 * dblPeriodAccrualDCF * dblPeriodNotional * dblPeriodFX;

  539.                     dblCumulativeCouponAmount += dblPeriodNotional * dblPeriodFX * dblAccrualCoupon *
  540.                         dblPeriodAccrualDCF;
  541.                 }

  542.                 dblUnadjustedDirtyPeriodDV01 = 0.0001 * dblPeriodDCF * dblPeriodNotional * dblPeriodFX *
  543.                     period.survival (csqs) * period.df (csqs);
  544.             } catch (java.lang.Exception e) {
  545.                 e.printStackTrace();

  546.                 return null;
  547.             }

  548.             double dblCompoundingAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 * cpcm.compounding();

  549.             double dblCreditForwardConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  550.                 cpcm.creditForward();

  551.             double dblCreditFundingConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  552.                 cpcm.creditFunding();

  553.             double dblCreditFXConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  554.                 cpcm.creditFX();

  555.             double dblCumulativeConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  556.                 cpcm.cumulative();

  557.             double dblForwardFundingConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  558.                 cpcm.forwardFunding();

  559.             double dblForwardFXConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  560.                 cpcm.forwardFX();

  561.             double dblFundingFXConvexityAdjustedDirtyPeriodDV01 = dblUnadjustedDirtyPeriodDV01 *
  562.                 cpcm.fundingFX();

  563.             dblTotalCoupon += dblPeriodFullRate;
  564.             dblUnadjustedDirtyDV01 += dblUnadjustedDirtyPeriodDV01;
  565.             dblUnadjustedDirtyPV += dblUnadjustedDirtyPeriodDV01 * 10000. * dblPeriodFullRate;
  566.             dblCompoundingAdjustedDirtyDV01 += dblCompoundingAdjustedDirtyPeriodDV01;
  567.             dblCompoundingAdjustedDirtyPV += dblCompoundingAdjustedDirtyPeriodDV01 * 10000. *
  568.                 dblPeriodFullRate;
  569.             dblCreditForwardConvexityAdjustedDirtyDV01 += dblCreditForwardConvexityAdjustedDirtyPeriodDV01;
  570.             dblCreditForwardConvexityAdjustedDirtyPV += dblCreditForwardConvexityAdjustedDirtyPeriodDV01 *
  571.                 10000. * dblPeriodFullRate;
  572.             dblCreditFundingConvexityAdjustedDirtyDV01 += dblCreditFundingConvexityAdjustedDirtyPeriodDV01;
  573.             dblCreditFundingConvexityAdjustedDirtyPV += dblCreditFundingConvexityAdjustedDirtyPeriodDV01 *
  574.                 10000. * dblPeriodFullRate;
  575.             dblCreditFXConvexityAdjustedDirtyDV01 += dblCreditFXConvexityAdjustedDirtyPeriodDV01;
  576.             dblCreditFXConvexityAdjustedDirtyPV += dblCreditFXConvexityAdjustedDirtyPeriodDV01 * 10000. *
  577.                 dblPeriodFullRate;
  578.             dblCumulativeConvexityAdjustedDirtyDV01 += dblCumulativeConvexityAdjustedDirtyPeriodDV01;
  579.             dblCumulativeConvexityAdjustedDirtyPV += dblCumulativeConvexityAdjustedDirtyPeriodDV01 * 10000. *
  580.                 dblPeriodFullRate;
  581.             dblForwardFundingConvexityAdjustedDirtyDV01 += dblForwardFundingConvexityAdjustedDirtyPeriodDV01;
  582.             dblForwardFundingConvexityAdjustedDirtyPV += dblForwardFundingConvexityAdjustedDirtyPeriodDV01 *
  583.                 10000. * dblPeriodFullRate;
  584.             dblForwardFXConvexityAdjustedDirtyDV01 += dblForwardFXConvexityAdjustedDirtyPeriodDV01;
  585.             dblForwardFXConvexityAdjustedDirtyPV += dblForwardFXConvexityAdjustedDirtyPeriodDV01 * 10000. *
  586.                 dblPeriodFullRate;
  587.             dblFundingFXConvexityAdjustedDirtyDV01 += dblFundingFXConvexityAdjustedDirtyPeriodDV01;
  588.             dblFundingFXConvexityAdjustedDirtyPV += dblFundingFXConvexityAdjustedDirtyPeriodDV01 * 10000. *
  589.                 dblPeriodFullRate;
  590.         }

  591.         try {
  592.             dblCashPayDF = dcFunding.df (iValueDate);

  593.             dblFXAdjustedValueNotional = fxAdjustedNotional (iValueDate, csqs);
  594.         } catch (java.lang.Exception e) {
  595.             e.printStackTrace();

  596.             return null;
  597.         }

  598.         dblUnadjustedDirtyPV /= dblCashPayDF;
  599.         dblUnadjustedDirtyDV01 /= dblCashPayDF;
  600.         dblCompoundingAdjustedDirtyPV /= dblCashPayDF;
  601.         dblCompoundingAdjustedDirtyDV01 /= dblCashPayDF;
  602.         dblCreditForwardConvexityAdjustedDirtyPV /= dblCashPayDF;
  603.         dblCreditForwardConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  604.         dblCreditFundingConvexityAdjustedDirtyPV /= dblCashPayDF;
  605.         dblCreditFundingConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  606.         dblCreditFXConvexityAdjustedDirtyPV /= dblCashPayDF;
  607.         dblCreditFXConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  608.         dblCumulativeConvexityAdjustedDirtyPV /= dblCashPayDF;
  609.         dblCumulativeConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  610.         dblForwardFundingConvexityAdjustedDirtyPV /= dblCashPayDF;
  611.         dblForwardFundingConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  612.         dblForwardFXConvexityAdjustedDirtyPV /= dblCashPayDF;
  613.         dblForwardFXConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  614.         dblFundingFXConvexityAdjustedDirtyPV /= dblCashPayDF;
  615.         dblFundingFXConvexityAdjustedDirtyDV01 /= dblCashPayDF;
  616.         double dblAccrued = 0. == dblAccrued01 ? 0. : dblAccrued01 * 10000. * dblAccrualCoupon;
  617.         double dblUnadjustedCleanPV = dblUnadjustedDirtyPV - dblAccrued;
  618.         double dblUnadjustedCleanDV01 = dblUnadjustedDirtyDV01 - dblAccrued01;
  619.         double dblUnadjustedFairPremium = 0.0001 * dblUnadjustedCleanPV / dblUnadjustedCleanDV01;
  620.         double dblCompoundingAdjustedCleanPV = dblCompoundingAdjustedDirtyPV - dblAccrued;
  621.         double dblCompoundingAdjustedCleanDV01 = dblCompoundingAdjustedDirtyDV01 - dblAccrued01;
  622.         double dblCompoundingAdjustedFairPremium = 0.0001 * dblCompoundingAdjustedCleanPV /
  623.             dblCompoundingAdjustedCleanDV01;
  624.         double dblCreditForwardConvexityAdjustedCleanPV = dblCreditForwardConvexityAdjustedDirtyPV -
  625.             dblAccrued;
  626.         double dblCreditForwardConvexityAdjustedCleanDV01 = dblCreditForwardConvexityAdjustedDirtyDV01 -
  627.             dblAccrued01;
  628.         double dblCreditForwardConvexityAdjustedFairPremium = 0.0001 *
  629.             dblCreditForwardConvexityAdjustedCleanPV / dblCreditForwardConvexityAdjustedCleanDV01;
  630.         double dblCreditFundingConvexityAdjustedCleanPV = dblCreditFundingConvexityAdjustedDirtyPV -
  631.             dblAccrued;
  632.         double dblCreditFundingConvexityAdjustedCleanDV01 = dblCreditFundingConvexityAdjustedDirtyDV01 -
  633.             dblAccrued01;
  634.         double dblCreditFundingConvexityAdjustedFairPremium = 0.0001 *
  635.             dblCreditFundingConvexityAdjustedCleanPV / dblCreditFundingConvexityAdjustedCleanDV01;
  636.         double dblCreditFXConvexityAdjustedCleanPV = dblCreditFXConvexityAdjustedDirtyPV - dblAccrued;
  637.         double dblCreditFXConvexityAdjustedCleanDV01 = dblCreditFXConvexityAdjustedDirtyDV01 - dblAccrued01;
  638.         double dblCreditFXConvexityAdjustedFairPremium = 0.0001 * dblCreditFXConvexityAdjustedCleanPV /
  639.             dblCreditFXConvexityAdjustedCleanDV01;
  640.         double dblCumulativeConvexityAdjustedCleanPV = dblCumulativeConvexityAdjustedDirtyPV - dblAccrued;
  641.         double dblCumulativeConvexityAdjustedCleanDV01 = dblCumulativeConvexityAdjustedDirtyDV01 -
  642.             dblAccrued01;
  643.         double dblCumulativeConvexityAdjustedFairPremium = 0.0001 * dblCumulativeConvexityAdjustedCleanPV /
  644.             dblCumulativeConvexityAdjustedCleanDV01;
  645.         double dblForwardFundingConvexityAdjustedCleanPV = dblForwardFundingConvexityAdjustedDirtyPV -
  646.             dblAccrued;
  647.         double dblForwardFundingConvexityAdjustedCleanDV01 = dblForwardFundingConvexityAdjustedDirtyDV01 -
  648.             dblAccrued01;
  649.         double dblForwardFundingConvexityAdjustedFairPremium = 0.0001 *
  650.             dblForwardFundingConvexityAdjustedCleanPV / dblForwardFundingConvexityAdjustedCleanDV01;
  651.         double dblForwardFXConvexityAdjustedCleanPV = dblForwardFXConvexityAdjustedDirtyPV - dblAccrued;
  652.         double dblForwardFXConvexityAdjustedCleanDV01 = dblForwardFXConvexityAdjustedDirtyDV01 -
  653.             dblAccrued01;
  654.         double dblForwardFXConvexityAdjustedFairPremium = 0.0001 * dblForwardFXConvexityAdjustedCleanPV /
  655.             dblForwardFXConvexityAdjustedCleanDV01;
  656.         double dblFundingFXConvexityAdjustedCleanPV = dblFundingFXConvexityAdjustedDirtyPV - dblAccrued;
  657.         double dblFundingFXConvexityAdjustedCleanDV01 = dblFundingFXConvexityAdjustedDirtyDV01 -
  658.             dblAccrued01;
  659.         double dblFundingFXConvexityAdjustedFairPremium = 0.0001 * dblFundingFXConvexityAdjustedCleanPV /
  660.             dblFundingFXConvexityAdjustedCleanDV01;

  661.         org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapResult = new
  662.             org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double>();

  663.         mapResult.put ("AccrualCoupon", dblAccrualCoupon);

  664.         mapResult.put ("Accrued", dblAccrued);

  665.         mapResult.put ("Accrued01", dblAccrued01);

  666.         mapResult.put ("CleanDV01", dblCumulativeConvexityAdjustedCleanDV01);

  667.         mapResult.put ("CleanPV", dblCumulativeConvexityAdjustedCleanPV);

  668.         mapResult.put ("CompoundingAdjustedCleanDV01", dblCompoundingAdjustedCleanDV01);

  669.         mapResult.put ("CompoundingAdjustedCleanPV", dblCompoundingAdjustedCleanPV);

  670.         mapResult.put ("CompoundingAdjustedDirtyPV", dblCompoundingAdjustedDirtyPV);

  671.         mapResult.put ("CompoundingAdjustedDirtyDV01", dblCompoundingAdjustedDirtyDV01);

  672.         mapResult.put ("CompoundingAdjustedDirtyPV", dblCompoundingAdjustedDirtyPV);

  673.         mapResult.put ("CompoundingAdjustedFairPremium", dblCompoundingAdjustedFairPremium);

  674.         mapResult.put ("CompoundingAdjustedParRate", dblCompoundingAdjustedFairPremium);

  675.         mapResult.put ("CompoundingAdjustedPV", dblCompoundingAdjustedCleanPV);

  676.         mapResult.put ("CompoundingAdjustedRate", dblCompoundingAdjustedFairPremium);

  677.         mapResult.put ("CompoundingAdjustedUpfront", dblCompoundingAdjustedCleanPV);

  678.         mapResult.put ("CompoundingAdjustmentFactor", dblCompoundingAdjustedDirtyDV01 /
  679.             dblUnadjustedDirtyDV01);

  680.         mapResult.put ("CompoundingAdjustmentPremium", dblCompoundingAdjustedCleanPV - dblUnadjustedCleanPV);

  681.         mapResult.put ("CompoundingAdjustmentPremiumUpfront", (dblCompoundingAdjustedCleanPV -
  682.             dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  683.         mapResult.put ("CreditForwardConvexityAdjustedCleanDV01",
  684.             dblCreditForwardConvexityAdjustedCleanDV01);

  685.         mapResult.put ("CreditForwardConvexityAdjustedCleanPV", dblCreditForwardConvexityAdjustedCleanPV);

  686.         mapResult.put ("CreditForwardConvexityAdjustedDirtyDV01",
  687.             dblCreditForwardConvexityAdjustedDirtyDV01);

  688.         mapResult.put ("CreditForwardConvexityAdjustedDirtyPV", dblCreditForwardConvexityAdjustedDirtyPV);

  689.         mapResult.put ("CreditForwardConvexityAdjustedDV01", dblCreditForwardConvexityAdjustedDirtyDV01);

  690.         mapResult.put ("CreditForwardConvexityAdjustedFairPremium",
  691.             dblCreditForwardConvexityAdjustedFairPremium);

  692.         mapResult.put ("CreditForwardConvexityAdjustedParRate",
  693.             dblCreditForwardConvexityAdjustedFairPremium);

  694.         mapResult.put ("CreditForwardConvexityAdjustedPV", dblCreditForwardConvexityAdjustedCleanPV);

  695.         mapResult.put ("CreditForwardConvexityAdjustedRate", dblCreditForwardConvexityAdjustedFairPremium);

  696.         mapResult.put ("CreditForwardConvexityAdjustedUpfront", dblCreditForwardConvexityAdjustedCleanPV);

  697.         mapResult.put ("CreditForwardConvexityAdjustmentFactor", dblCreditForwardConvexityAdjustedDirtyDV01
  698.             / dblUnadjustedDirtyDV01);

  699.         mapResult.put ("CreditForwardConvexityAdjustmentPremium", dblCreditForwardConvexityAdjustedCleanPV
  700.             - dblUnadjustedCleanPV);

  701.         mapResult.put ("CreditForwardConvexityAdjustmentPremiumUpfront",
  702.             (dblCreditForwardConvexityAdjustedCleanPV - dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  703.         mapResult.put ("CreditFundingConvexityAdjustedCleanDV01",
  704.             dblCreditFundingConvexityAdjustedCleanDV01);

  705.         mapResult.put ("CreditFundingConvexityAdjustedCleanPV", dblCreditFundingConvexityAdjustedCleanPV);

  706.         mapResult.put ("CreditFundingConvexityAdjustedDirtyDV01",
  707.             dblCreditFundingConvexityAdjustedDirtyDV01);

  708.         mapResult.put ("CreditFundingConvexityAdjustedDirtyPV", dblCreditFundingConvexityAdjustedDirtyPV);

  709.         mapResult.put ("CreditFundingConvexityAdjustedDV01", dblCreditFundingConvexityAdjustedDirtyDV01);

  710.         mapResult.put ("CreditFundingConvexityAdjustedFairPremium",
  711.             dblCreditFundingConvexityAdjustedFairPremium);

  712.         mapResult.put ("CreditFundingConvexityAdjustedParRate",
  713.             dblCreditFundingConvexityAdjustedFairPremium);

  714.         mapResult.put ("CreditFundingConvexityAdjustedPV", dblCreditFundingConvexityAdjustedCleanPV);

  715.         mapResult.put ("CreditFundingConvexityAdjustedRate", dblCreditFundingConvexityAdjustedFairPremium);

  716.         mapResult.put ("CreditFundingConvexityAdjustedUpfront", dblCreditFundingConvexityAdjustedCleanPV);

  717.         mapResult.put ("CreditFundingConvexityAdjustmentFactor", dblCreditFundingConvexityAdjustedDirtyDV01
  718.             / dblUnadjustedDirtyDV01);

  719.         mapResult.put ("CreditFundingConvexityAdjustmentPremium", dblCreditFundingConvexityAdjustedCleanPV
  720.             - dblUnadjustedCleanPV);

  721.         mapResult.put ("CreditFundingConvexityAdjustmentPremiumUpfront",
  722.             (dblCreditFundingConvexityAdjustedCleanPV - dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  723.         mapResult.put ("CreditFXConvexityAdjustedCleanDV01", dblCreditFXConvexityAdjustedCleanDV01);

  724.         mapResult.put ("CreditFXConvexityAdjustedCleanPV", dblCreditFXConvexityAdjustedCleanPV);

  725.         mapResult.put ("CreditFXConvexityAdjustedDirtyDV01", dblCreditFXConvexityAdjustedDirtyDV01);

  726.         mapResult.put ("CreditFXConvexityAdjustedDirtyPV", dblCreditFXConvexityAdjustedDirtyPV);

  727.         mapResult.put ("CreditFXConvexityAdjustedDV01", dblCreditFXConvexityAdjustedDirtyDV01);

  728.         mapResult.put ("CreditFXConvexityAdjustedFairPremium", dblCreditFXConvexityAdjustedFairPremium);

  729.         mapResult.put ("CreditFXConvexityAdjustedParRate", dblCreditFXConvexityAdjustedFairPremium);

  730.         mapResult.put ("CreditFXConvexityAdjustedPV", dblCreditFXConvexityAdjustedCleanPV);

  731.         mapResult.put ("CreditFXConvexityAdjustedRate", dblCreditFXConvexityAdjustedFairPremium);

  732.         mapResult.put ("CreditFXConvexityAdjustedUpfront", dblCreditFXConvexityAdjustedCleanPV);

  733.         mapResult.put ("CreditFXConvexityAdjustmentFactor", dblCreditFXConvexityAdjustedDirtyDV01 /
  734.             dblUnadjustedDirtyDV01);

  735.         mapResult.put ("CreditFXConvexityAdjustmentPremium", dblCreditFXConvexityAdjustedCleanPV -
  736.             dblUnadjustedCleanPV);

  737.         mapResult.put ("CreditFXConvexityAdjustmentPremiumUpfront", (dblCreditFXConvexityAdjustedCleanPV -
  738.             dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  739.         mapResult.put ("CumulativeConvexityAdjustedCleanDV01", dblCumulativeConvexityAdjustedCleanDV01);

  740.         mapResult.put ("CumulativeConvexityAdjustedCleanPV", dblCumulativeConvexityAdjustedCleanPV);

  741.         mapResult.put ("CumulativeConvexityAdjustedDirtyDV01", dblCumulativeConvexityAdjustedDirtyDV01);

  742.         mapResult.put ("CumulativeConvexityAdjustedDirtyPV", dblCumulativeConvexityAdjustedDirtyPV);

  743.         mapResult.put ("CumulativeConvexityAdjustedDV01", dblCumulativeConvexityAdjustedDirtyDV01);

  744.         mapResult.put ("CumulativeConvexityAdjustedFairPremium", dblCumulativeConvexityAdjustedFairPremium);

  745.         mapResult.put ("CumulativeConvexityAdjustedParRate", dblCumulativeConvexityAdjustedFairPremium);

  746.         mapResult.put ("CumulativeConvexityAdjustedPV", dblCumulativeConvexityAdjustedCleanPV);

  747.         mapResult.put ("CumulativeConvexityAdjustedRate", dblCumulativeConvexityAdjustedFairPremium);

  748.         mapResult.put ("CumulativeConvexityAdjustedUpfront", dblCumulativeConvexityAdjustedCleanPV);

  749.         mapResult.put ("CumulativeConvexityAdjustmentFactor", dblCumulativeConvexityAdjustedDirtyDV01 /
  750.             dblUnadjustedDirtyDV01);

  751.         mapResult.put ("CumulativeConvexityAdjustmentPremium", dblCumulativeConvexityAdjustedCleanPV -
  752.             dblUnadjustedCleanPV);

  753.         mapResult.put ("CumulativeConvexityAdjustmentPremiumUpfront", (dblCumulativeConvexityAdjustedCleanPV
  754.             - dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  755.         mapResult.put ("CumulativeCouponAmount", dblCumulativeCouponAmount);

  756.         mapResult.put ("CumulativeCouponDCF", dblCumulativeCouponDCF);

  757.         mapResult.put ("CV01", dblCumulativeConvexityAdjustedCleanDV01);

  758.         mapResult.put ("DirtyDV01", dblCumulativeConvexityAdjustedDirtyDV01);

  759.         mapResult.put ("DirtyPV", dblCumulativeConvexityAdjustedDirtyPV);

  760.         mapResult.put ("DV01", dblCumulativeConvexityAdjustedCleanDV01);

  761.         mapResult.put ("FairPremium", dblCumulativeConvexityAdjustedFairPremium);

  762.         mapResult.put ("Fixing01", dblAccrued01);

  763.         mapResult.put ("ForwardFundingConvexityAdjustedCleanDV01",
  764.             dblForwardFundingConvexityAdjustedCleanDV01);

  765.         mapResult.put ("ForwardFundingConvexityAdjustedCleanPV", dblForwardFundingConvexityAdjustedCleanPV);

  766.         mapResult.put ("ForwardFundingConvexityAdjustedDirtyDV01",
  767.             dblForwardFundingConvexityAdjustedDirtyDV01);

  768.         mapResult.put ("ForwardFundingConvexityAdjustedDirtyPV", dblForwardFundingConvexityAdjustedDirtyPV);

  769.         mapResult.put ("ForwardFundingConvexityAdjustedDV01", dblForwardFundingConvexityAdjustedDirtyDV01);

  770.         mapResult.put ("ForwardFundingConvexityAdjustedFairPremium",
  771.             dblForwardFundingConvexityAdjustedFairPremium);

  772.         mapResult.put ("ForwardFundingConvexityAdjustedParRate",
  773.             dblForwardFundingConvexityAdjustedFairPremium);

  774.         mapResult.put ("ForwardFundingConvexityAdjustedPV", dblForwardFundingConvexityAdjustedCleanPV);

  775.         mapResult.put ("ForwardFundingConvexityAdjustedRate", dblForwardFundingConvexityAdjustedFairPremium);

  776.         mapResult.put ("ForwardFundingConvexityAdjustedUpfront", dblForwardFundingConvexityAdjustedCleanPV);

  777.         mapResult.put ("ForwardFundingConvexityAdjustmentFactor", dblForwardFundingConvexityAdjustedDirtyDV01
  778.             / dblUnadjustedDirtyDV01);

  779.         mapResult.put ("ForwardFundingConvexityAdjustmentPremium", dblForwardFundingConvexityAdjustedCleanPV
  780.             - dblUnadjustedCleanPV);

  781.         mapResult.put ("ForwardFundingConvexityAdjustmentPremiumUpfront",
  782.             (dblForwardFundingConvexityAdjustedCleanPV - dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  783.         mapResult.put ("ForwardFXConvexityAdjustedCleanDV01", dblForwardFXConvexityAdjustedCleanDV01);

  784.         mapResult.put ("ForwardFXConvexityAdjustedCleanPV", dblForwardFXConvexityAdjustedCleanPV);

  785.         mapResult.put ("ForwardFXConvexityAdjustedDirtyDV01", dblForwardFXConvexityAdjustedDirtyDV01);

  786.         mapResult.put ("ForwardFXConvexityAdjustedDirtyPV", dblForwardFXConvexityAdjustedDirtyPV);

  787.         mapResult.put ("ForwardFXConvexityAdjustedDV01", dblForwardFXConvexityAdjustedDirtyDV01);

  788.         mapResult.put ("ForwardFXConvexityAdjustedFairPremium", dblForwardFXConvexityAdjustedFairPremium);

  789.         mapResult.put ("ForwardFXConvexityAdjustedParRate", dblForwardFXConvexityAdjustedFairPremium);

  790.         mapResult.put ("ForwardFXConvexityAdjustedPV", dblForwardFXConvexityAdjustedCleanPV);

  791.         mapResult.put ("ForwardFXConvexityAdjustedRate", dblForwardFXConvexityAdjustedFairPremium);

  792.         mapResult.put ("ForwardFXConvexityAdjustedUpfront", dblForwardFXConvexityAdjustedCleanPV);

  793.         mapResult.put ("ForwardFXConvexityAdjustmentFactor", dblForwardFXConvexityAdjustedDirtyDV01 /
  794.             dblUnadjustedDirtyDV01);

  795.         mapResult.put ("ForwardFXConvexityAdjustmentPremium", dblForwardFXConvexityAdjustedCleanPV -
  796.             dblUnadjustedCleanPV);

  797.         mapResult.put ("ForwardFXConvexityAdjustmentPremiumUpfront", (dblForwardFXConvexityAdjustedCleanPV -
  798.             dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  799.         mapResult.put ("FundingFXConvexityAdjustedCleanDV01", dblFundingFXConvexityAdjustedCleanDV01);

  800.         mapResult.put ("FundingFXConvexityAdjustedCleanPV", dblFundingFXConvexityAdjustedCleanPV);

  801.         mapResult.put ("FundingFXConvexityAdjustedDirtyDV01", dblFundingFXConvexityAdjustedDirtyDV01);

  802.         mapResult.put ("FundingFXConvexityAdjustedDirtyPV", dblFundingFXConvexityAdjustedDirtyPV);

  803.         mapResult.put ("FundingFXConvexityAdjustedDV01", dblFundingFXConvexityAdjustedDirtyDV01);

  804.         mapResult.put ("FundingFXConvexityAdjustedFairPremium", dblFundingFXConvexityAdjustedFairPremium);

  805.         mapResult.put ("FundingFXConvexityAdjustedParRate", dblFundingFXConvexityAdjustedFairPremium);

  806.         mapResult.put ("FundingFXConvexityAdjustedPV", dblFundingFXConvexityAdjustedCleanPV);

  807.         mapResult.put ("FundingFXConvexityAdjustedRate", dblFundingFXConvexityAdjustedFairPremium);

  808.         mapResult.put ("FundingFXConvexityAdjustedUpfront", dblFundingFXConvexityAdjustedCleanPV);

  809.         mapResult.put ("FundingFXConvexityAdjustmentFactor", dblFundingFXConvexityAdjustedDirtyDV01 /
  810.             dblUnadjustedDirtyDV01);

  811.         mapResult.put ("FundingFXConvexityAdjustmentPremium", dblFundingFXConvexityAdjustedCleanPV -
  812.             dblUnadjustedCleanPV);

  813.         mapResult.put ("FundingFXConvexityAdjustmentPremiumUpfront", (dblFundingFXConvexityAdjustedCleanPV -
  814.             dblUnadjustedCleanPV) / dblFXAdjustedValueNotional);

  815.         mapResult.put ("ParRate", dblCumulativeConvexityAdjustedFairPremium);

  816.         mapResult.put ("PV", dblCumulativeConvexityAdjustedCleanPV);

  817.         mapResult.put ("Rate", dblCumulativeConvexityAdjustedFairPremium);

  818.         mapResult.put ("ResetDate", (double) iResetDate);

  819.         mapResult.put ("ResetRate", dblAccrualCoupon - basis());

  820.         mapResult.put ("TotalCoupon", dblTotalCoupon);

  821.         mapResult.put ("UnadjustedCleanDV01", dblUnadjustedCleanDV01);

  822.         mapResult.put ("UnadjustedCleanPV", dblUnadjustedCleanPV);

  823.         mapResult.put ("UnadjustedDirtyDV01", dblUnadjustedDirtyDV01);

  824.         mapResult.put ("UnadjustedDirtyPV", dblUnadjustedDirtyPV);

  825.         mapResult.put ("UnadjustedFairPremium", dblUnadjustedFairPremium);

  826.         mapResult.put ("UnadjustedParRate", dblUnadjustedFairPremium);

  827.         mapResult.put ("UnadjustedPV", dblUnadjustedCleanPV);

  828.         mapResult.put ("UnadjustedRate", dblUnadjustedFairPremium);

  829.         mapResult.put ("UnadjustedUpfront", dblUnadjustedCleanPV);

  830.         mapResult.put ("Upfront", dblCumulativeConvexityAdjustedCleanPV);

  831.         double dblCompoundingAdjustedCleanPrice = 100. * (1. + (dblCompoundingAdjustedCleanPV /
  832.             dblFXAdjustedValueNotional));
  833.         double dblCreditForwardConvexityAdjustedCleanPrice = 100. * (1. +
  834.             (dblCreditForwardConvexityAdjustedCleanPV / dblFXAdjustedValueNotional));
  835.         double dblCreditFundingConvexityAdjustedCleanPrice = 100. * (1. +
  836.             (dblCreditFundingConvexityAdjustedCleanPV / dblFXAdjustedValueNotional));
  837.         double dblCreditFXConvexityAdjustedCleanPrice = 100. * (1. + (dblCreditFXConvexityAdjustedCleanPV
  838.             / dblFXAdjustedValueNotional));
  839.         double dblCumulativeConvexityAdjustedCleanPrice = 100. * (1. + (dblCumulativeConvexityAdjustedCleanPV
  840.             / dblFXAdjustedValueNotional));
  841.         double dblForwardFundingConvexityAdjustedCleanPrice = 100. * (1. +
  842.             (dblForwardFundingConvexityAdjustedCleanPV / dblFXAdjustedValueNotional));
  843.         double dblForwardFXConvexityAdjustedCleanPrice = 100. * (1. + (dblForwardFXConvexityAdjustedCleanPV /
  844.             dblFXAdjustedValueNotional));
  845.         double dblFundingFXConvexityAdjustedCleanPrice = 100. * (1. + (dblFundingFXConvexityAdjustedCleanPV /
  846.             dblFXAdjustedValueNotional));
  847.         double dblUnadjustedCleanPrice = 100. * (1. + (dblUnadjustedCleanPV / dblFXAdjustedValueNotional));

  848.         mapResult.put ("CleanPrice", dblCumulativeConvexityAdjustedCleanPrice);

  849.         mapResult.put ("CompoundingAdjustedCleanPrice", dblCompoundingAdjustedCleanPrice);

  850.         mapResult.put ("CompoundingAdjustedDirtyPrice", 100. * (1. + (dblCompoundingAdjustedDirtyPV /
  851.             dblFXAdjustedValueNotional)));

  852.         mapResult.put ("CompoundingAdjustedPrice", dblCompoundingAdjustedCleanPrice);

  853.         mapResult.put ("CreditForwardConvexityAdjustedCleanPrice",
  854.             dblCreditForwardConvexityAdjustedCleanPrice);

  855.         mapResult.put ("CreditForwardConvexityAdjustedDirtyPrice", 100. * (1. +
  856.             (dblCreditForwardConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  857.         mapResult.put ("CreditForwardConvexityAdjustedPrice", dblCreditForwardConvexityAdjustedCleanPrice);

  858.         mapResult.put ("CreditFundingConvexityAdjustedCleanPrice",
  859.             dblCreditFundingConvexityAdjustedCleanPrice);

  860.         mapResult.put ("CreditFundingConvexityAdjustedDirtyPrice", 100. * (1. +
  861.             (dblCreditFundingConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  862.         mapResult.put ("CreditFundingConvexityAdjustedPrice", dblCreditFundingConvexityAdjustedCleanPrice);

  863.         mapResult.put ("CreditFXConvexityAdjustedCleanPrice", dblCreditFXConvexityAdjustedCleanPrice);

  864.         mapResult.put ("CreditFXConvexityAdjustedDirtyPrice", 100. * (1. +
  865.             (dblCreditFXConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  866.         mapResult.put ("CreditFXConvexityAdjustedPrice", dblCreditFXConvexityAdjustedCleanPrice);

  867.         mapResult.put ("CumulativeConvexityAdjustedCleanPrice", dblCumulativeConvexityAdjustedCleanPrice);

  868.         mapResult.put ("CumulativeConvexityAdjustedDirtyPrice", 100. * (1. +
  869.             (dblCumulativeConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  870.         mapResult.put ("CumulativeConvexityAdjustedPrice", dblCumulativeConvexityAdjustedCleanPrice);

  871.         mapResult.put ("DirtyPrice", 100. * (1. + (dblCumulativeConvexityAdjustedDirtyPV /
  872.             dblFXAdjustedValueNotional)));

  873.         mapResult.put ("ForwardFundingConvexityAdjustedCleanPrice",
  874.             dblForwardFundingConvexityAdjustedCleanPrice);

  875.         mapResult.put ("ForwardFundingConvexityAdjustedDirtyPrice", 100. * (1. +
  876.             (dblForwardFundingConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  877.         mapResult.put ("ForwardFundingConvexityAdjustedPrice", dblForwardFundingConvexityAdjustedCleanPrice);

  878.         mapResult.put ("ForwardFXConvexityAdjustedCleanPrice", dblForwardFXConvexityAdjustedCleanPrice);

  879.         mapResult.put ("ForwardFXConvexityAdjustedDirtyPrice", 100. * (1. +
  880.             (dblForwardFXConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  881.         mapResult.put ("ForwardFXConvexityAdjustedPrice", dblForwardFXConvexityAdjustedCleanPrice);

  882.         mapResult.put ("FundingFXConvexityAdjustedCleanPrice", dblFundingFXConvexityAdjustedCleanPrice);

  883.         mapResult.put ("FundingFXConvexityAdjustedDirtyPrice", 100. * (1. +
  884.             (dblFundingFXConvexityAdjustedDirtyPV / dblFXAdjustedValueNotional)));

  885.         mapResult.put ("FundingFXConvexityAdjustedPrice", dblFundingFXConvexityAdjustedCleanPrice);

  886.         mapResult.put ("Price", dblCumulativeConvexityAdjustedCleanPrice);

  887.         mapResult.put ("UnadjustedCleanPrice", dblUnadjustedCleanPrice);

  888.         mapResult.put ("UnadjustedDirtyPrice", 100. * (1. + (dblUnadjustedDirtyPV /
  889.             dblFXAdjustedValueNotional)));

  890.         mapResult.put ("UnadjustedPrice", dblUnadjustedCleanPrice);

  891.         mapResult.put ("CalcTime", (System.nanoTime() - lStart) * 1.e-09);

  892.         return mapResult;
  893.     }

  894.     /**
  895.      * Retrieve the set of the implemented measures
  896.      *
  897.      * @return The set of the implemented measures
  898.      */

  899.     public java.util.Set<java.lang.String> availableMeasures()
  900.     {
  901.         java.util.Set<java.lang.String> setstrMeasures = new java.util.TreeSet<java.lang.String>();

  902.         setstrMeasures.add ("AccrualCoupon");

  903.         setstrMeasures.add ("Accrued");

  904.         setstrMeasures.add ("Accrued01");

  905.         setstrMeasures.add ("CleanDV01");

  906.         setstrMeasures.add ("CleanPV");

  907.         setstrMeasures.add ("CompoundingAdjustedCleanDV01");

  908.         setstrMeasures.add ("CompoundingAdjustedCleanPV");

  909.         setstrMeasures.add ("CompoundingAdjustedDirtyDV01");

  910.         setstrMeasures.add ("CompoundingAdjustedDirtyPV");

  911.         setstrMeasures.add ("CompoundingAdjustedFairPremium");

  912.         setstrMeasures.add ("CompoundingAdjustedParRate");

  913.         setstrMeasures.add ("CompoundingAdjustedPV");

  914.         setstrMeasures.add ("CompoundingAdjustedRate");

  915.         setstrMeasures.add ("CompoundingAdjustedUpfront");

  916.         setstrMeasures.add ("CompoundingAdjustmentFactor");

  917.         setstrMeasures.add ("CompoundingAdjustmentPremium");

  918.         setstrMeasures.add ("CompoundingAdjustmentPremiumUpfront");

  919.         setstrMeasures.add ("CreditForwardConvexityAdjustedCleanDV01");

  920.         setstrMeasures.add ("CreditForwardConvexityAdjustedCleanPV");

  921.         setstrMeasures.add ("CreditForwardConvexityAdjustedDirtyDV01");

  922.         setstrMeasures.add ("CreditForwardConvexityAdjustedDirtyPV");

  923.         setstrMeasures.add ("CreditForwardConvexityAdjustedDV01");

  924.         setstrMeasures.add ("CreditForwardConvexityAdjustedFairPremium");

  925.         setstrMeasures.add ("CreditForwardConvexityAdjustedParRate");

  926.         setstrMeasures.add ("CreditForwardConvexityAdjustedPV");

  927.         setstrMeasures.add ("CreditForwardConvexityAdjustedRate");

  928.         setstrMeasures.add ("CreditForwardConvexityAdjustedUpfront");

  929.         setstrMeasures.add ("CreditForwardConvexityAdjustmentFactor");

  930.         setstrMeasures.add ("CreditForwardConvexityAdjustmentPremium");

  931.         setstrMeasures.add ("CreditForwardConvexityAdjustmentPremiumUpfront");

  932.         setstrMeasures.add ("CreditFundingConvexityAdjustedCleanDV01");

  933.         setstrMeasures.add ("CreditFundingConvexityAdjustedCleanPV");

  934.         setstrMeasures.add ("CreditFundingConvexityAdjustedDirtyDV01");

  935.         setstrMeasures.add ("CreditFundingConvexityAdjustedDirtyPV");

  936.         setstrMeasures.add ("CreditFundingConvexityAdjustedDV01");

  937.         setstrMeasures.add ("CreditFundingConvexityAdjustedFairPremium");

  938.         setstrMeasures.add ("CreditFundingConvexityAdjustedParRate");

  939.         setstrMeasures.add ("CreditFundingConvexityAdjustedPV");

  940.         setstrMeasures.add ("CreditFundingConvexityAdjustedRate");

  941.         setstrMeasures.add ("CreditFundingConvexityAdjustedUpfront");

  942.         setstrMeasures.add ("CreditFundingConvexityAdjustmentFactor");

  943.         setstrMeasures.add ("CreditFundingConvexityAdjustmentPremium");

  944.         setstrMeasures.add ("CreditFundingConvexityAdjustmentPremiumUpfront");

  945.         setstrMeasures.add ("CreditFXConvexityAdjustedCleanDV01");

  946.         setstrMeasures.add ("CreditFXConvexityAdjustedCleanPV");

  947.         setstrMeasures.add ("CreditFXConvexityAdjustedDirtyDV01");

  948.         setstrMeasures.add ("CreditFXConvexityAdjustedDirtyPV");

  949.         setstrMeasures.add ("CreditFXConvexityAdjustedDV01");

  950.         setstrMeasures.add ("CreditFXConvexityAdjustedFairPremium");

  951.         setstrMeasures.add ("CreditFXConvexityAdjustedParRate");

  952.         setstrMeasures.add ("CreditFXConvexityAdjustedPV");

  953.         setstrMeasures.add ("CreditFXConvexityAdjustedRate");

  954.         setstrMeasures.add ("CreditFXConvexityAdjustedUpfront");

  955.         setstrMeasures.add ("CreditFXConvexityAdjustmentFactor");

  956.         setstrMeasures.add ("CreditFXConvexityAdjustmentPremium");

  957.         setstrMeasures.add ("CreditFXConvexityAdjustmentPremiumUpfront");

  958.         setstrMeasures.add ("CumulativeConvexityAdjustedCleanDV01");

  959.         setstrMeasures.add ("CumulativeConvexityAdjustedCleanPV");

  960.         setstrMeasures.add ("CumulativeConvexityAdjustedDirtyDV01");

  961.         setstrMeasures.add ("CumulativeConvexityAdjustedDirtyPV");

  962.         setstrMeasures.add ("CumulativeConvexityAdjustedDV01");

  963.         setstrMeasures.add ("CumulativeConvexityAdjustedFairPremium");

  964.         setstrMeasures.add ("CumulativeConvexityAdjustedParRate");

  965.         setstrMeasures.add ("CumulativeConvexityAdjustedPV");

  966.         setstrMeasures.add ("CumulativeConvexityAdjustedRate");

  967.         setstrMeasures.add ("CumulativeConvexityAdjustedUpfront");

  968.         setstrMeasures.add ("CumulativeConvexityAdjustmentFactor");

  969.         setstrMeasures.add ("CumulativeConvexityAdjustmentPremium");

  970.         setstrMeasures.add ("CumulativeConvexityAdjustmentPremiumUpfront");

  971.         setstrMeasures.add ("CumulativeCouponAmount");

  972.         setstrMeasures.add ("CV01");

  973.         setstrMeasures.add ("DirtyDV01");

  974.         setstrMeasures.add ("DirtyPV");

  975.         setstrMeasures.add ("DV01");

  976.         setstrMeasures.add ("FairPremium");

  977.         setstrMeasures.add ("Fixing01");

  978.         setstrMeasures.add ("ForwardFundingConvexityAdjustedCleanDV01");

  979.         setstrMeasures.add ("ForwardFundingConvexityAdjustedCleanPV");

  980.         setstrMeasures.add ("ForwardFundingConvexityAdjustedDirtyDV01");

  981.         setstrMeasures.add ("ForwardFundingConvexityAdjustedDirtyPV");

  982.         setstrMeasures.add ("ForwardFundingConvexityAdjustedDV01");

  983.         setstrMeasures.add ("ForwardFundingConvexityAdjustedFairPremium");

  984.         setstrMeasures.add ("ForwardFundingConvexityAdjustedParRate");

  985.         setstrMeasures.add ("ForwardFundingConvexityAdjustedPV");

  986.         setstrMeasures.add ("ForwardFundingConvexityAdjustedRate");

  987.         setstrMeasures.add ("ForwardFundingConvexityAdjustedUpfront");

  988.         setstrMeasures.add ("ForwardFundingConvexityAdjustmentFactor");

  989.         setstrMeasures.add ("ForwardFundingConvexityAdjustmentPremium");

  990.         setstrMeasures.add ("ForwardFundingConvexityAdjustmentPremiumUpfront");

  991.         setstrMeasures.add ("ForwardFXConvexityAdjustedCleanDV01");

  992.         setstrMeasures.add ("ForwardFXConvexityAdjustedCleanPV");

  993.         setstrMeasures.add ("ForwardFXConvexityAdjustedDirtyDV01");

  994.         setstrMeasures.add ("ForwardFXConvexityAdjustedDirtyPV");

  995.         setstrMeasures.add ("ForwardFXConvexityAdjustedDV01");

  996.         setstrMeasures.add ("ForwardFXConvexityAdjustedFairPremium");

  997.         setstrMeasures.add ("ForwardFXConvexityAdjustedParRate");

  998.         setstrMeasures.add ("ForwardFXConvexityAdjustedPV");

  999.         setstrMeasures.add ("ForwardFXConvexityAdjustedRate");

  1000.         setstrMeasures.add ("ForwardFXConvexityAdjustedUpfront");

  1001.         setstrMeasures.add ("ForwardFXConvexityAdjustmentFactor");

  1002.         setstrMeasures.add ("ForwardFXConvexityAdjustmentPremium");

  1003.         setstrMeasures.add ("ForwardFXConvexityAdjustmentPremiumUpfront");

  1004.         setstrMeasures.add ("FundingFXConvexityAdjustedCleanDV01");

  1005.         setstrMeasures.add ("FundingFXConvexityAdjustedCleanPV");

  1006.         setstrMeasures.add ("FundingFXConvexityAdjustedDirtyDV01");

  1007.         setstrMeasures.add ("FundingFXConvexityAdjustedDirtyPV");

  1008.         setstrMeasures.add ("FundingFXConvexityAdjustedDV01");

  1009.         setstrMeasures.add ("FundingFXConvexityAdjustedFairPremium");

  1010.         setstrMeasures.add ("FundingFXConvexityAdjustedParRate");

  1011.         setstrMeasures.add ("FundingFXConvexityAdjustedPV");

  1012.         setstrMeasures.add ("FundingFXConvexityAdjustedRate");

  1013.         setstrMeasures.add ("FundingFXConvexityAdjustedUpfront");

  1014.         setstrMeasures.add ("FundingFXConvexityAdjustmentFactor");

  1015.         setstrMeasures.add ("FundingFXConvexityAdjustmentPremium");

  1016.         setstrMeasures.add ("FundingFXConvexityAdjustmentPremiumUpfront");

  1017.         setstrMeasures.add ("ParRate");

  1018.         setstrMeasures.add ("PV");

  1019.         setstrMeasures.add ("Rate");

  1020.         setstrMeasures.add ("ResetDate");

  1021.         setstrMeasures.add ("ResetRate");

  1022.         setstrMeasures.add ("TotalCoupon");

  1023.         setstrMeasures.add ("UnadjustedCleanDV01");

  1024.         setstrMeasures.add ("UnadjustedCleanPV");

  1025.         setstrMeasures.add ("UnadjustedDirtyDV01");

  1026.         setstrMeasures.add ("UnadjustedDirtyPV");

  1027.         setstrMeasures.add ("UnadjustedFairPremium");

  1028.         setstrMeasures.add ("UnadjustedParRate");

  1029.         setstrMeasures.add ("UnadjustedPV");

  1030.         setstrMeasures.add ("UnadjustedRate");

  1031.         setstrMeasures.add ("UnadjustedUpfront");

  1032.         setstrMeasures.add ("Upfront");

  1033.         return setstrMeasures;
  1034.     }

  1035.     /**
  1036.      * Compute the PV for the specified Market Parameters
  1037.      *
  1038.      * @param valParams ValuationParams
  1039.      * @param pricerParams PricerParams
  1040.      * @param csqc Market Parameters
  1041.      * @param vcp Valuation Customization Parameters
  1042.      *
  1043.      * @return The PV
  1044.      *
  1045.      * @throws java.lang.Exception Thrown if the PV cannot be computed
  1046.      */

  1047.     public double pv (
  1048.         final org.drip.param.valuation.ValuationParams valParams,
  1049.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1050.         final org.drip.param.market.CurveSurfaceQuoteContainer csqc,
  1051.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  1052.         throws java.lang.Exception
  1053.     {
  1054.         if (null == valParams || null == csqc)
  1055.             throw new java.lang.Exception ("Stream::pv => Invalid Inputs");

  1056.         org.drip.state.discount.MergedDiscountForwardCurve dcFunding = csqc.fundingState (fundingLabel());

  1057.         if (null == dcFunding) throw new java.lang.Exception ("Stream::pv => Invalid Inputs");

  1058.         int iValueDate = valParams.valueDate();

  1059.         double dblCumulativeConvexityAdjustedDirtyPV = 0.;

  1060.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1061.             int iPeriodPayDate = period.payDate();

  1062.             if (iPeriodPayDate < iValueDate) continue;

  1063.             org.drip.analytics.output.CompositePeriodCouponMetrics cpcm = period.couponMetrics (iValueDate,
  1064.                 csqc);

  1065.             if (null == cpcm) throw new java.lang.Exception ("Stream::pv => Invalid Inputs");

  1066.             int iPeriodEndDate = period.endDate();

  1067.             dblCumulativeConvexityAdjustedDirtyPV += cpcm.dcf() * period.notional (iPeriodEndDate) *
  1068.                 period.couponFactor (iPeriodEndDate) * period.fx (csqc) * period.survival (csqc) *
  1069.                     period.df (csqc) * cpcm.cumulative() * cpcm.rate();
  1070.         }

  1071.         return dblCumulativeConvexityAdjustedDirtyPV / dcFunding.df (iValueDate);
  1072.     }

  1073.     /**
  1074.      * Generate the State Loading Constraints for the Forward Latent State
  1075.      *
  1076.      * @param valParams The Valuation Parameters
  1077.      * @param pricerParams The Pricer parameters
  1078.      * @param csqs The Market Parameters
  1079.      * @param vcp Valuation Customization Parameters
  1080.      * @param pqs The Product Calibration Quote Set
  1081.      *
  1082.      * @return The State Loading Constraints for the Forward Latent State
  1083.      */

  1084.     public org.drip.state.estimator.PredictorResponseWeightConstraint forwardPRWC (
  1085.         final org.drip.param.valuation.ValuationParams valParams,
  1086.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1087.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1088.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1089.         final org.drip.product.calib.ProductQuoteSet pqs)
  1090.     {
  1091.         if (null == valParams || null == pqs) return null;

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

  1093.         org.drip.state.identifier.ForwardLabel forwardLabel = null != floaterLabel && floaterLabel instanceof
  1094.             org.drip.state.identifier.ForwardLabel ? (org.drip.state.identifier.ForwardLabel) floaterLabel :
  1095.                 null;

  1096.         if ((null != forwardLabel && !(pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet)) ||
  1097.             (null == forwardLabel && !(pqs instanceof org.drip.product.calib.FixedStreamQuoteSet)))
  1098.             return null;

  1099.         int iValueDate = valParams.valueDate();

  1100.         if (iValueDate >= maturity().julian()) return null;

  1101.         double dblCleanPV = 0.;

  1102.         try {
  1103.             if (pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet) {
  1104.                 org.drip.product.calib.FloatingStreamQuoteSet fsqs =
  1105.                     (org.drip.product.calib.FloatingStreamQuoteSet) pqs;

  1106.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1107.             } else if (pqs instanceof org.drip.product.calib.FixedStreamQuoteSet) {
  1108.                 org.drip.product.calib.FixedStreamQuoteSet fsqs =
  1109.                     (org.drip.product.calib.FixedStreamQuoteSet) pqs;

  1110.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1111.             }
  1112.         } catch (java.lang.Exception e) {
  1113.             e.printStackTrace();

  1114.             return null;
  1115.         }

  1116.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1117.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1118.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1119.             int iPeriodEndDate = period.endDate();

  1120.             if (iPeriodEndDate < iValueDate) continue;

  1121.             org.drip.state.estimator.PredictorResponseWeightConstraint prwcPeriod = period.forwardPRWC
  1122.                 (iValueDate, csqs, pqs);

  1123.             if (null == prwcPeriod || !prwc.absorb (prwcPeriod)) return null;
  1124.         }

  1125.         if (!prwc.updateValue (dblCleanPV)) return null;

  1126.         if (!prwc.updateDValueDManifestMeasure ("PV", 1.)) return null;

  1127.         return prwc;
  1128.     }

  1129.     /**
  1130.      * Generate the State Loading Constraints for the Funding Latent State
  1131.      *
  1132.      * @param valParams The Valuation Parameters
  1133.      * @param pricerParams The Pricer parameters
  1134.      * @param csqs The Market Parameters
  1135.      * @param vcp Valuation Customization Parameters
  1136.      * @param pqs The Product Calibration Quote Set
  1137.      *
  1138.      * @return The State Loading Constraints for the Funding Latent State
  1139.      */

  1140.     public org.drip.state.estimator.PredictorResponseWeightConstraint fundingPRWC (
  1141.         final org.drip.param.valuation.ValuationParams valParams,
  1142.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1143.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1144.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1145.         final org.drip.product.calib.ProductQuoteSet pqs)
  1146.     {
  1147.         if (null == valParams || null == pqs) return null;

  1148.         org.drip.state.identifier.ForwardLabel forwardLabel = forwardLabel();

  1149.         if ((null != forwardLabel && !(pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet)) ||
  1150.             (null == forwardLabel && !(pqs instanceof org.drip.product.calib.FixedStreamQuoteSet)))
  1151.             return null;

  1152.         int iValueDate = valParams.valueDate();

  1153.         if (iValueDate >= maturity().julian()) return null;

  1154.         double dblCleanPV = 0.;

  1155.         try {
  1156.             if (pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet) {
  1157.                 org.drip.product.calib.FloatingStreamQuoteSet fsqs =
  1158.                     (org.drip.product.calib.FloatingStreamQuoteSet) pqs;

  1159.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1160.             } else if (pqs instanceof org.drip.product.calib.FixedStreamQuoteSet) {
  1161.                 org.drip.product.calib.FixedStreamQuoteSet fsqs =
  1162.                     (org.drip.product.calib.FixedStreamQuoteSet) pqs;

  1163.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1164.             }
  1165.         } catch (java.lang.Exception e) {
  1166.             e.printStackTrace();

  1167.             return null;
  1168.         }

  1169.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1170.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1171.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1172.             int iPeriodEndDate = period.endDate();

  1173.             if (iPeriodEndDate < iValueDate) continue;

  1174.             org.drip.state.estimator.PredictorResponseWeightConstraint prwcPeriod = period.fundingPRWC
  1175.                 (iValueDate, csqs, pqs);

  1176.             if (null == prwcPeriod || !prwc.absorb (prwcPeriod)) return null;
  1177.         }

  1178.         if (!prwc.updateValue (dblCleanPV)) return null;

  1179.         if (!prwc.updateDValueDManifestMeasure ("PV", 1.)) return null;

  1180.         return prwc;
  1181.     }

  1182.     /**
  1183.      * Generate the State Loading Constraints for the Merged Forward/Funding Latent State
  1184.      *
  1185.      * @param valParams The Valuation Parameters
  1186.      * @param pricerParams The Pricer parameters
  1187.      * @param csqs The Market Parameters
  1188.      * @param vcp Valuation Customization Parameters
  1189.      * @param pqs The Product Calibration Quote Set
  1190.      *
  1191.      * @return The State Loading Constraints for the Merged Forward/Funding Latent State
  1192.      */

  1193.     public org.drip.state.estimator.PredictorResponseWeightConstraint fundingForwardPRWC (
  1194.         final org.drip.param.valuation.ValuationParams valParams,
  1195.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1196.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1197.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1198.         final org.drip.product.calib.ProductQuoteSet pqs)
  1199.     {
  1200.         if (null == valParams || null == pqs) return null;

  1201.         org.drip.state.identifier.ForwardLabel forwardLabel = forwardLabel();

  1202.         if ((null != forwardLabel && !(pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet)) ||
  1203.             (null == forwardLabel && !(pqs instanceof org.drip.product.calib.FixedStreamQuoteSet)))
  1204.             return null;

  1205.         int iValueDate = valParams.valueDate();

  1206.         if (iValueDate >= maturity().julian()) return null;

  1207.         double dblCleanPV = 0.;

  1208.         try {
  1209.             if (pqs instanceof org.drip.product.calib.FloatingStreamQuoteSet) {
  1210.                 org.drip.product.calib.FloatingStreamQuoteSet fsqs =
  1211.                     (org.drip.product.calib.FloatingStreamQuoteSet) pqs;

  1212.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1213.             } else if (pqs instanceof org.drip.product.calib.FixedStreamQuoteSet) {
  1214.                 org.drip.product.calib.FixedStreamQuoteSet fsqs =
  1215.                     (org.drip.product.calib.FixedStreamQuoteSet) pqs;

  1216.                 if (fsqs.containsPV()) dblCleanPV = fsqs.pv();
  1217.             }
  1218.         } catch (java.lang.Exception e) {
  1219.             e.printStackTrace();

  1220.             return null;
  1221.         }

  1222.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1223.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1224.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1225.             int iPeriodEndDate = period.endDate();

  1226.             if (iPeriodEndDate < iValueDate) continue;

  1227.             org.drip.state.estimator.PredictorResponseWeightConstraint prwcPeriod = period.forwardFundingPRWC
  1228.                 (iValueDate, csqs, pqs);

  1229.             if (null == prwcPeriod || !prwc.absorb (prwcPeriod)) return null;
  1230.         }

  1231.         if (!prwc.updateValue (dblCleanPV)) return null;

  1232.         if (!prwc.updateDValueDManifestMeasure ("PV", 1.)) return null;

  1233.         return prwc;
  1234.     }

  1235.     /**
  1236.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged FX Curve
  1237.      *  FX Forward Latent State from the Component's Cash Flows. The Constraints here typically correspond to
  1238.      *  Date/Cash Flow pairs and the corresponding leading PV.
  1239.      *
  1240.      * @param valParams Valuation Parameters
  1241.      * @param pricerParams Pricer Parameters
  1242.      * @param csqs Component Market Parameters
  1243.      * @param vcp Valuation Customization Parameters
  1244.      * @param pqs Product Quote Set
  1245.      *
  1246.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  1247.      *  corresponding FX Forward)
  1248.      */

  1249.     public org.drip.state.estimator.PredictorResponseWeightConstraint fxPRWC (
  1250.         final org.drip.param.valuation.ValuationParams valParams,
  1251.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1252.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1253.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1254.         final org.drip.product.calib.ProductQuoteSet pqs)
  1255.     {
  1256.         if (null == valParams) return null;

  1257.         int iValueDate = valParams.valueDate();

  1258.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1259.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1260.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1261.             int iPeriodEndDate = period.endDate();

  1262.             if (iPeriodEndDate < iValueDate) continue;

  1263.             org.drip.state.estimator.PredictorResponseWeightConstraint prwcPeriod = period.fxPRWC
  1264.                 (iValueDate, csqs, pqs);

  1265.             if (null == prwcPeriod || !prwc.absorb (prwcPeriod)) return null;
  1266.         }

  1267.         return prwc;
  1268.     }

  1269.     /**
  1270.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged Govvie
  1271.      *  Curve Yield Latent State from the Component's Cash Flows. The Constraints here typically correspond
  1272.      *  to Date/Cash Flow pairs and the corresponding leading PV.
  1273.      *
  1274.      * @param valParams Valuation Parameters
  1275.      * @param pricerParams Pricer Parameters
  1276.      * @param csqs Component Market Parameters
  1277.      * @param vcp Valuation Customization Parameters
  1278.      * @param pqs Product Quote Set
  1279.      *
  1280.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  1281.      *  corresponding Yield)
  1282.      */

  1283.     public org.drip.state.estimator.PredictorResponseWeightConstraint govviePRWC (
  1284.         final org.drip.param.valuation.ValuationParams valParams,
  1285.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1286.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1287.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1288.         final org.drip.product.calib.ProductQuoteSet pqs)
  1289.     {
  1290.         return null;
  1291.     }

  1292.     /**
  1293.      * Generate the Calibratable Linearized Predictor/Response Constraint Weights for the Non-merged
  1294.      *  Volatility Curve Volatility Latent State from the Component's Cash Flows. The Constraints here
  1295.      *  typically correspond tovDate/Cash Flow pairs and the corresponding leading PV.
  1296.      *
  1297.      * @param valParams Valuation Parameters
  1298.      * @param pricerParams Pricer Parameters
  1299.      * @param csqs Component Market Parameters
  1300.      * @param vcp Valuation Customization Parameters
  1301.      * @param pqs Product Quote Set
  1302.      *
  1303.      * @return The Calibratable Linearized Predictor/Response Constraints (Date/Cash Flow pairs and the
  1304.      *  corresponding Volatility)
  1305.      */

  1306.     public org.drip.state.estimator.PredictorResponseWeightConstraint volatilityPRWC (
  1307.         final org.drip.param.valuation.ValuationParams valParams,
  1308.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1309.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1310.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  1311.         final org.drip.product.calib.ProductQuoteSet pqs)
  1312.     {
  1313.         if (null == valParams) return null;

  1314.         int iValueDate = valParams.valueDate();

  1315.         org.drip.state.estimator.PredictorResponseWeightConstraint prwc = new
  1316.             org.drip.state.estimator.PredictorResponseWeightConstraint();

  1317.         for (org.drip.analytics.cashflow.CompositePeriod period : _lsPeriod) {
  1318.             int iPeriodEndDate = period.endDate();

  1319.             if (iPeriodEndDate < iValueDate) continue;

  1320.             org.drip.state.estimator.PredictorResponseWeightConstraint prwcPeriod = period.volatilityPRWC
  1321.                 (iValueDate, csqs, pqs);

  1322.             if (null == prwcPeriod || !prwc.absorb (prwcPeriod)) return null;
  1323.         }

  1324.         return prwc;
  1325.     }

  1326.     /**
  1327.      * Generate the Jacobian of the Dirty PV to the Manifest Measure
  1328.      *
  1329.      * @param valParams The Valuation Parameters
  1330.      * @param pricerParams The Pricer parameters
  1331.      * @param csqs The Market Parameters
  1332.      * @param vcp Valuation Customization Parameters
  1333.      *
  1334.      * @return The Jacobian of the Dirty PV to the Manifest Measure
  1335.      */

  1336.     public org.drip.numerical.differentiation.WengertJacobian jackDDirtyPVDManifestMeasure (
  1337.         final org.drip.param.valuation.ValuationParams valParams,
  1338.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1339.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1340.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  1341.     {
  1342.         if (null == valParams || valParams.valueDate() >= maturity().julian() || null == csqs) return null;

  1343.         org.drip.state.discount.MergedDiscountForwardCurve dcFunding = csqs.fundingState (fundingLabel());

  1344.         if (null == dcFunding) return null;

  1345.         try {
  1346.             org.drip.numerical.differentiation.WengertJacobian jackDDirtyPVDManifestMeasure = null;

  1347.             for (org.drip.analytics.cashflow.CompositePeriod p : _lsPeriod) {
  1348.                 int iPeriodPayDate = p.payDate();

  1349.                 if (p.startDate() < valParams.valueDate()) continue;

  1350.                 org.drip.numerical.differentiation.WengertJacobian jackDDFDManifestMeasure =
  1351.                     dcFunding.jackDDFDManifestMeasure (iPeriodPayDate, "PV");

  1352.                 if (null == jackDDFDManifestMeasure) continue;

  1353.                 int iNumQuote = jackDDFDManifestMeasure.numParameters();

  1354.                 if (0 == iNumQuote) continue;

  1355.                 if (null == jackDDirtyPVDManifestMeasure)
  1356.                     jackDDirtyPVDManifestMeasure = new org.drip.numerical.differentiation.WengertJacobian (1,
  1357.                         iNumQuote);

  1358.                 double dblPeriodNotional = p.notional (p.startDate(), p.endDate()) * p.fx (csqs);

  1359.                 double dblPeriodDCF = p.couponMetrics (valParams.valueDate(), csqs).dcf();

  1360.                 for (int k = 0; k < iNumQuote; ++k) {
  1361.                     if (!jackDDirtyPVDManifestMeasure.accumulatePartialFirstDerivative (0, k,
  1362.                         dblPeriodNotional * dblPeriodDCF * jackDDFDManifestMeasure.firstDerivative (0, k)))
  1363.                         return null;
  1364.                 }
  1365.             }

  1366.             return jackDDirtyPVDManifestMeasure;
  1367.         } catch (java.lang.Exception e) {
  1368.             e.printStackTrace();
  1369.         }

  1370.         return null;
  1371.     }

  1372.     /**
  1373.      * Generate the micro-Jacobian of the Manifest Measure to the Discount Factor
  1374.      *
  1375.      * @param strManifestMeasure The Manifest Measure
  1376.      * @param valParams The Valuation Parameters
  1377.      * @param pricerParams The Pricer parameters
  1378.      * @param csqs The Market Parameters
  1379.      * @param vcp Valuation Customization Parameters
  1380.      *
  1381.      * @return The micro-Jacobian of the Manifest Measure to the Discount Factor
  1382.      */

  1383.     public org.drip.numerical.differentiation.WengertJacobian manifestMeasureDFMicroJack (
  1384.         final java.lang.String strManifestMeasure,
  1385.         final org.drip.param.valuation.ValuationParams valParams,
  1386.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  1387.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  1388.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  1389.     {
  1390.         if (null == valParams || valParams.valueDate() >= _lsPeriod.get (_lsPeriod.size() - 1).endDate() ||
  1391.             null == strManifestMeasure)
  1392.             return null;

  1393.         org.drip.state.discount.MergedDiscountForwardCurve dcFunding = csqs.fundingState
  1394.             (org.drip.state.identifier.FundingLabel.Standard (payCurrency()));

  1395.         if (null == dcFunding) return null;

  1396.         if ("Rate".equalsIgnoreCase (strManifestMeasure) || "SwapRate".equalsIgnoreCase (strManifestMeasure))
  1397.         {
  1398.             org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapMeasures = value
  1399.                 (valParams, pricerParams, csqs, vcp);

  1400.             if (null == mapMeasures) return null;

  1401.             double dblDirtyDV01 = mapMeasures.get ("DirtyDV01");

  1402.             double dblParSwapRate = mapMeasures.get ("SwapRate");

  1403.             try {
  1404.                 org.drip.numerical.differentiation.WengertJacobian wjSwapRateDFMicroJack = null;

  1405.                 for (org.drip.analytics.cashflow.CompositePeriod p : _lsPeriod) {
  1406.                     int iPeriodPayDate = p.payDate();

  1407.                     if (iPeriodPayDate < valParams.valueDate()) continue;

  1408.                     double dblPeriodDCF = p.couponMetrics (valParams.valueDate(), csqs).dcf();

  1409.                     org.drip.numerical.differentiation.WengertJacobian wjPeriodFwdRateDF =
  1410.                         dcFunding.jackDForwardDManifestMeasure (p.startDate(), p.endDate(), "Rate",
  1411.                             dblPeriodDCF);

  1412.                     org.drip.numerical.differentiation.WengertJacobian wjPeriodPayDFDF =
  1413.                         dcFunding.jackDDFDManifestMeasure (iPeriodPayDate, "Rate");

  1414.                     if (null == wjPeriodFwdRateDF || null == wjPeriodPayDFDF) continue;

  1415.                     double dblForwardRate = dcFunding.libor (p.startDate(), p.endDate());

  1416.                     double dblPeriodPayDF = dcFunding.df (iPeriodPayDate);

  1417.                     if (null == wjSwapRateDFMicroJack)
  1418.                         wjSwapRateDFMicroJack = new org.drip.numerical.differentiation.WengertJacobian (1,
  1419.                             wjPeriodFwdRateDF.numParameters());

  1420.                     double dblPeriodNotional = notional (p.startDate(), p.endDate());

  1421.                     for (int k = 0; k < wjPeriodFwdRateDF.numParameters(); ++k) {
  1422.                         double dblPeriodMicroJack = (dblForwardRate - dblParSwapRate) *
  1423.                             wjPeriodPayDFDF.firstDerivative (0, k) + dblPeriodPayDF *
  1424.                                 wjPeriodFwdRateDF.firstDerivative (0, k);

  1425.                         if (!wjSwapRateDFMicroJack.accumulatePartialFirstDerivative (0, k, dblPeriodNotional
  1426.                             * dblPeriodDCF * dblPeriodMicroJack / dblDirtyDV01))
  1427.                             return null;
  1428.                     }
  1429.                 }

  1430.                 return wjSwapRateDFMicroJack;
  1431.             } catch (java.lang.Exception e) {
  1432.                 e.printStackTrace();
  1433.             }
  1434.         }

  1435.         return null;
  1436.     }
  1437. }