BondReplicator.java

  1. package org.drip.service.scenario;

  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.  *
  11.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  12.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  13.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  14.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  15.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  16.  *      and computational support.
  17.  *  
  18.  *      https://lakshmidrip.github.io/DROP/
  19.  *  
  20.  *  DROP is composed of three modules:
  21.  *  
  22.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  23.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  24.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  25.  *
  26.  *  DROP Product Core implements libraries for the following:
  27.  *  - Fixed Income Analytics
  28.  *  - Loan Analytics
  29.  *  - Transaction Cost Analytics
  30.  *
  31.  *  DROP Portfolio Core implements libraries for the following:
  32.  *  - Asset Allocation Analytics
  33.  *  - Asset Liability Management Analytics
  34.  *  - Capital Estimation Analytics
  35.  *  - Exposure Analytics
  36.  *  - Margin Analytics
  37.  *  - XVA Analytics
  38.  *
  39.  *  DROP Computational Core implements libraries for the following:
  40.  *  - Algorithm Support
  41.  *  - Computation Support
  42.  *  - Function Analysis
  43.  *  - Model Validation
  44.  *  - Numerical Analysis
  45.  *  - Numerical Optimizer
  46.  *  - Spline Builder
  47.  *  - Statistical Learning
  48.  *
  49.  *  Documentation for DROP is Spread Over:
  50.  *
  51.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  52.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  53.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  54.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  55.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  56.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  57.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  58.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  59.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  60.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  61.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  62.  *
  63.  *  Licensed under the Apache License, Version 2.0 (the "License");
  64.  *      you may not use this file except in compliance with the License.
  65.  *  
  66.  *  You may obtain a copy of the License at
  67.  *      http://www.apache.org/licenses/LICENSE-2.0
  68.  *  
  69.  *  Unless required by applicable law or agreed to in writing, software
  70.  *      distributed under the License is distributed on an "AS IS" BASIS,
  71.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  72.  *  
  73.  *  See the License for the specific language governing permissions and
  74.  *      limitations under the License.
  75.  */

  76. /**
  77.  * <i>BondReplicator</i> generates a Target Set of Sensitivity and Relative Value Runs.
  78.  *
  79.  * <br><br>
  80.  *  <ul>
  81.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  82.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationSupportLibrary.md">Computation Support</a></li>
  83.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/README.md">Environment, Product/Definition Containers, and Scenario/State Manipulation APIs</a></li>
  84.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/scenario/README.md">Custom Scenario Service Metric Generator</a></li>
  85.  *  </ul>
  86.  * <br><br>
  87.  *
  88.  * @author Lakshmi Krishnamurthy
  89.  */

  90. public class BondReplicator
  91. {

  92.     /**
  93.      * Subordinate Corporate Recovery Rate
  94.      */

  95.     public static final double CORPORATE_SUBORDINATE_RECOVERY_RATE = 0.20;

  96.     /**
  97.      * Senior Corporate Recovery Rate
  98.      */

  99.     public static final double CORPORATE_SENIOR_RECOVERY_RATE = 0.40;

  100.     /**
  101.      * Loan Corporate Recovery Rate
  102.      */

  103.     public static final double CORPORATE_LOAN_RECOVERY_RATE = 0.70;

  104.     private int _iSettleLag = -1;
  105.     private double[] _adblGovvieQuote = null;
  106.     private double[] _adblCreditQuote = null;
  107.     private double[] _adblDepositQuote = null;
  108.     private double[] _adblFuturesQuote = null;
  109.     private double[] _adblFixFloatQuote = null;
  110.     private double _dblFX = java.lang.Double.NaN;
  111.     private java.lang.String _strGovvieCode = "";
  112.     private boolean _bMarketPriceCreditMetrics = false;
  113.     private java.lang.String[] _astrCreditTenor = null;
  114.     private java.lang.String[] _astrGovvieTenor = null;
  115.     private double _dblTenorBump = java.lang.Double.NaN;
  116.     private java.lang.String[] _astrDepositTenor = null;
  117.     private java.lang.String[] _astrFixFloatTenor = null;
  118.     private double _dblIssuePrice = java.lang.Double.NaN;
  119.     private double _dblIssueAmount = java.lang.Double.NaN;
  120.     private double _dblZSpreadBump = java.lang.Double.NaN;
  121.     private double _dblCurrentPrice = java.lang.Double.NaN;
  122.     private double _dblRecoveryRate = java.lang.Double.NaN;
  123.     private double _dblCustomYieldBump = java.lang.Double.NaN;
  124.     private org.drip.analytics.date.JulianDate _dtValue = null;
  125.     private org.drip.product.credit.BondComponent _bond = null;
  126.     private double _dblCustomCreditBasisBump = java.lang.Double.NaN;
  127.     private double _dblSpreadDurationMultiplier = java.lang.Double.NaN;

  128.     private double _dblLogNormalVolatility = 0.1;
  129.     private double _dblResetRate = java.lang.Double.NaN;
  130.     private int _iResetDate = java.lang.Integer.MIN_VALUE;
  131.     private org.drip.analytics.date.JulianDate _dtSettle = null;
  132.     private org.drip.param.valuation.ValuationParams _valParams = null;
  133.     private org.drip.service.scenario.EOSMetricsReplicator _emr = null;
  134.     private org.drip.param.market.CurveSurfaceQuoteContainer _csqcCreditBase = null;
  135.     private org.drip.param.market.CurveSurfaceQuoteContainer _csqcCredit01Up = null;
  136.     private org.drip.param.market.CurveSurfaceQuoteContainer _csqcFundingBase = null;
  137.     private org.drip.param.market.CurveSurfaceQuoteContainer _csqcFunding01Up = null;
  138.     private org.drip.param.market.CurveSurfaceQuoteContainer _csqcFundingEuroDollar = null;
  139.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  140.         _mapCSQCCredit = null;

  141.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  142.         _mapCSQCGovvieUp = new
  143.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  144.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  145.         _mapCSQCGovvieDown = new
  146.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  147.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  148.         _mapCSQCFundingUp = new
  149.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  150.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  151.         _mapCSQCFundingDown = new
  152.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  153.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  154.         _mapCSQCForwardFundingUp = new
  155.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  156.     private java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  157.         _mapCSQCForwardFundingDown = new
  158.             org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  159.     /**
  160.      * Generate a Standard Subordinate Corporate BondReplicator Instance
  161.      *
  162.      * @param dblCurrentPrice Current Price
  163.      * @param dblIssuePrice Issue Price
  164.      * @param dblIssueAmount Issue Amount
  165.      * @param dtSpot Spot Date
  166.      * @param astrDepositTenor Array of Deposit Tenors
  167.      * @param adblDepositQuote Array of Deposit Quotes
  168.      * @param adblFuturesQuote Array of Futures Quotes
  169.      * @param astrFixFloatTenor Array of Fix-Float Tenors
  170.      * @param adblFixFloatQuote Array of Fix-Float Quotes
  171.      * @param dblSpreadBump Yield/Spread Bump
  172.      * @param dblSpreadDurationMultiplier Spread Duration Multiplier
  173.      * @param strGovvieCode Govvie Code
  174.      * @param astrGovvieTenor Array of Govvie Tenor
  175.      * @param adblGovvieQuote Array of Govvie Quotes
  176.      * @param astrCreditTenor Array of Credit Tenors
  177.      * @param adblCreditQuote Array of Credit Quotes
  178.      * @param dblFX FX Rate Applicable
  179.      * @param dblResetRate Reset Rate Applicable
  180.      * @param iSettleLag Settlement Lag
  181.      * @param bond Bond Component Instance
  182.      *
  183.      * @return The Standard Subordinate BondReplicator Instance
  184.      */

  185.     public static final BondReplicator CorporateSubordinate (
  186.         final double dblCurrentPrice,
  187.         final double dblIssuePrice,
  188.         final double dblIssueAmount,
  189.         final org.drip.analytics.date.JulianDate dtSpot,
  190.         final java.lang.String[] astrDepositTenor,
  191.         final double[] adblDepositQuote,
  192.         final double[] adblFuturesQuote,
  193.         final java.lang.String[] astrFixFloatTenor,
  194.         final double[] adblFixFloatQuote,
  195.         final double dblSpreadBump,
  196.         final double dblSpreadDurationMultiplier,
  197.         final java.lang.String strGovvieCode,
  198.         final java.lang.String[] astrGovvieTenor,
  199.         final double[] adblGovvieQuote,
  200.         final java.lang.String[] astrCreditTenor,
  201.         final double[] adblCreditQuote,
  202.         final double dblFX,
  203.         final double dblResetRate,
  204.         final int iSettleLag,
  205.         final org.drip.product.credit.BondComponent bond)
  206.     {
  207.         try {
  208.             return new BondReplicator (
  209.                 dblCurrentPrice,
  210.                 dblIssuePrice,
  211.                 dblIssueAmount,
  212.                 dtSpot,
  213.                 astrDepositTenor,
  214.                 adblDepositQuote,
  215.                 adblFuturesQuote,
  216.                 astrFixFloatTenor,
  217.                 adblFixFloatQuote,
  218.                 dblSpreadBump,
  219.                 dblSpreadBump,
  220.                 dblSpreadBump,
  221.                 dblSpreadBump,
  222.                 dblSpreadDurationMultiplier,
  223.                 strGovvieCode,
  224.                 astrGovvieTenor,
  225.                 adblGovvieQuote,
  226.                 true,
  227.                 astrCreditTenor,
  228.                 adblCreditQuote,
  229.                 dblFX,
  230.                 dblResetRate,
  231.                 iSettleLag,
  232.                 CORPORATE_SUBORDINATE_RECOVERY_RATE,
  233.                 bond
  234.             );
  235.         } catch (java.lang.Exception e) {
  236.             e.printStackTrace();
  237.         }

  238.         return null;
  239.     }

  240.     /**
  241.      * Generate a Standard Senior Corporate BondReplicator Instance
  242.      *
  243.      * @param dblCurrentPrice Current Price
  244.      * @param dblIssuePrice Issue Price
  245.      * @param dblIssueAmount Issue Amount
  246.      * @param dtSpot Spot Date
  247.      * @param astrDepositTenor Array of Deposit Tenors
  248.      * @param adblDepositQuote Array of Deposit Quotes
  249.      * @param adblFuturesQuote Array of Futures Quotes
  250.      * @param astrFixFloatTenor Array of Fix-Float Tenors
  251.      * @param adblFixFloatQuote Array of Fix-Float Quotes
  252.      * @param dblSpreadBump Yield/Spread Bump
  253.      * @param dblSpreadDurationMultiplier Spread Duration Multiplier
  254.      * @param strGovvieCode Govvie Code
  255.      * @param astrGovvieTenor Array of Govvie Tenor
  256.      * @param adblGovvieQuote Array of Govvie Quotes
  257.      * @param astrCreditTenor Array of Credit Tenors
  258.      * @param adblCreditQuote Array of Credit Quotes
  259.      * @param dblFX FX Rate Applicable
  260.      * @param dblResetRate Reset Rate Applicable
  261.      * @param iSettleLag Settlement Lag
  262.      * @param bond Bond Component Instance
  263.      *
  264.      * @return The Standard Senior BondReplicator Instance
  265.      */

  266.     public static final BondReplicator CorporateSenior (
  267.         final double dblCurrentPrice,
  268.         final double dblIssuePrice,
  269.         final double dblIssueAmount,
  270.         final org.drip.analytics.date.JulianDate dtSpot,
  271.         final java.lang.String[] astrDepositTenor,
  272.         final double[] adblDepositQuote,
  273.         final double[] adblFuturesQuote,
  274.         final java.lang.String[] astrFixFloatTenor,
  275.         final double[] adblFixFloatQuote,
  276.         final double dblSpreadBump,
  277.         final double dblSpreadDurationMultiplier,
  278.         final java.lang.String strGovvieCode,
  279.         final java.lang.String[] astrGovvieTenor,
  280.         final double[] adblGovvieQuote,
  281.         final java.lang.String[] astrCreditTenor,
  282.         final double[] adblCreditQuote,
  283.         final double dblFX,
  284.         final double dblResetRate,
  285.         final int iSettleLag,
  286.         final org.drip.product.credit.BondComponent bond)
  287.     {
  288.         try {
  289.             return new BondReplicator (
  290.                 dblCurrentPrice,
  291.                 dblIssuePrice,
  292.                 dblIssueAmount,
  293.                 dtSpot,
  294.                 astrDepositTenor,
  295.                 adblDepositQuote,
  296.                 adblFuturesQuote,
  297.                 astrFixFloatTenor,
  298.                 adblFixFloatQuote,
  299.                 dblSpreadBump,
  300.                 dblSpreadBump,
  301.                 dblSpreadBump,
  302.                 dblSpreadBump,
  303.                 dblSpreadDurationMultiplier,
  304.                 strGovvieCode,
  305.                 astrGovvieTenor,
  306.                 adblGovvieQuote,
  307.                 true,
  308.                 astrCreditTenor,
  309.                 adblCreditQuote,
  310.                 dblFX,
  311.                 dblResetRate,
  312.                 iSettleLag,
  313.                 CORPORATE_SENIOR_RECOVERY_RATE,
  314.                 bond
  315.             );
  316.         } catch (java.lang.Exception e) {
  317.             e.printStackTrace();
  318.         }

  319.         return null;
  320.     }

  321.     /**
  322.      * Generate a Standard Corporate Loan BondReplicator Instance
  323.      *
  324.      * @param dblCurrentPrice Current Price
  325.      * @param dblIssuePrice Issue Price
  326.      * @param dblIssueAmount Issue Amount
  327.      * @param dtSpot Spot Date
  328.      * @param astrDepositTenor Array of Deposit Tenors
  329.      * @param adblDepositQuote Array of Deposit Quotes
  330.      * @param adblFuturesQuote Array of Futures Quotes
  331.      * @param astrFixFloatTenor Array of Fix-Float Tenors
  332.      * @param adblFixFloatQuote Array of Fix-Float Quotes
  333.      * @param dblSpreadBump Yield/Spread Bump
  334.      * @param dblSpreadDurationMultiplier Spread Duration Multiplier
  335.      * @param strGovvieCode Govvie Code
  336.      * @param astrGovvieTenor Array of Govvie Tenor
  337.      * @param adblGovvieQuote Array of Govvie Quotes
  338.      * @param astrCreditTenor Array of Credit Tenors
  339.      * @param adblCreditQuote Array of Credit Quotes
  340.      * @param dblFX FX Rate Applicable
  341.      * @param dblResetRate Reset Rate Applicable
  342.      * @param iSettleLag Settlement Lag
  343.      * @param bond Bond Component Instance
  344.      *
  345.      * @return The Standard Senior BondReplicator Instance
  346.      */

  347.     public static final BondReplicator CorporateLoan (
  348.         final double dblCurrentPrice,
  349.         final double dblIssuePrice,
  350.         final double dblIssueAmount,
  351.         final org.drip.analytics.date.JulianDate dtSpot,
  352.         final java.lang.String[] astrDepositTenor,
  353.         final double[] adblDepositQuote,
  354.         final double[] adblFuturesQuote,
  355.         final java.lang.String[] astrFixFloatTenor,
  356.         final double[] adblFixFloatQuote,
  357.         final double dblSpreadBump,
  358.         final double dblSpreadDurationMultiplier,
  359.         final java.lang.String strGovvieCode,
  360.         final java.lang.String[] astrGovvieTenor,
  361.         final double[] adblGovvieQuote,
  362.         final java.lang.String[] astrCreditTenor,
  363.         final double[] adblCreditQuote,
  364.         final double dblFX,
  365.         final double dblResetRate,
  366.         final int iSettleLag,
  367.         final org.drip.product.credit.BondComponent bond)
  368.     {
  369.         try {
  370.             return new BondReplicator (
  371.                 dblCurrentPrice,
  372.                 dblIssuePrice,
  373.                 dblIssueAmount,
  374.                 dtSpot,
  375.                 astrDepositTenor,
  376.                 adblDepositQuote,
  377.                 adblFuturesQuote,
  378.                 astrFixFloatTenor,
  379.                 adblFixFloatQuote,
  380.                 dblSpreadBump,
  381.                 dblSpreadBump,
  382.                 dblSpreadBump,
  383.                 dblSpreadBump,
  384.                 dblSpreadDurationMultiplier,
  385.                 strGovvieCode,
  386.                 astrGovvieTenor,
  387.                 adblGovvieQuote,
  388.                 true,
  389.                 astrCreditTenor,
  390.                 adblCreditQuote,
  391.                 dblFX,
  392.                 dblResetRate,
  393.                 iSettleLag,
  394.                 CORPORATE_LOAN_RECOVERY_RATE,
  395.                 bond
  396.             );
  397.         } catch (java.lang.Exception e) {
  398.             e.printStackTrace();
  399.         }

  400.         return null;
  401.     }

  402.     /**
  403.      * BondReplicator Constructor
  404.      *
  405.      * @param dblCurrentPrice Current Price
  406.      * @param dblIssuePrice Issue Price
  407.      * @param dblIssueAmount Issue Amount
  408.      * @param dtValue Value Date
  409.      * @param astrDepositTenor Array of Deposit Tenors
  410.      * @param adblDepositQuote Array of Deposit Quotes
  411.      * @param adblFuturesQuote Array of Futures Quotes
  412.      * @param astrFixFloatTenor Array of Fix-Float Tenors
  413.      * @param adblFixFloatQuote Array of Fix-Float Quotes
  414.      * @param dblCustomYieldBump Custom Yield Bump
  415.      * @param dblCustomCreditBasisBump Custom Credit Basis Bump
  416.      * @param dblZSpreadBump Z Spread Bump
  417.      * @param dblTenorBump Tenor Bump
  418.      * @param dblSpreadDurationMultiplier Spread Duration Multiplier
  419.      * @param strGovvieCode Govvie Code
  420.      * @param astrGovvieTenor Array of Govvie Tenor
  421.      * @param adblGovvieQuote Array of Govvie Quotes
  422.      * @param bMarketPriceCreditMetrics Generate the Credit Metrics from the Market Price
  423.      * @param astrCreditTenor Array of Credit Tenors
  424.      * @param adblCreditQuote Array of Credit Quotes
  425.      * @param dblFX FX Rate Applicable
  426.      * @param dblResetRate Reset Rate Applicable
  427.      * @param iSettleLag Settlement Lag
  428.      * @param dblRecoveryRate Recovery Rate
  429.      * @param bond Bond Component Instance
  430.      *
  431.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  432.      */

  433.     public BondReplicator (
  434.         final double dblCurrentPrice,
  435.         final double dblIssuePrice,
  436.         final double dblIssueAmount,
  437.         final org.drip.analytics.date.JulianDate dtValue,
  438.         final java.lang.String[] astrDepositTenor,
  439.         final double[] adblDepositQuote,
  440.         final double[] adblFuturesQuote,
  441.         final java.lang.String[] astrFixFloatTenor,
  442.         final double[] adblFixFloatQuote,
  443.         final double dblCustomYieldBump,
  444.         final double dblCustomCreditBasisBump,
  445.         final double dblZSpreadBump,
  446.         final double dblTenorBump,
  447.         final double dblSpreadDurationMultiplier,
  448.         final java.lang.String strGovvieCode,
  449.         final java.lang.String[] astrGovvieTenor,
  450.         final double[] adblGovvieQuote,
  451.         final boolean bMarketPriceCreditMetrics,
  452.         final java.lang.String[] astrCreditTenor,
  453.         final double[] adblCreditQuote,
  454.         final double dblFX,
  455.         final double dblResetRate,
  456.         final int iSettleLag,
  457.         final double dblRecoveryRate,
  458.         final org.drip.product.credit.BondComponent bond)
  459.         throws java.lang.Exception
  460.     {
  461.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblCurrentPrice = dblCurrentPrice) ||
  462.             !org.drip.numerical.common.NumberUtil.IsValid (_dblIssuePrice = dblIssuePrice) ||
  463.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblIssueAmount = dblIssueAmount) || null ==
  464.                     (_dtValue = dtValue) || !org.drip.numerical.common.NumberUtil.IsValid (_dblFX = dblFX) || 0.
  465.                         >= _dblFX || 0 > (_iSettleLag = iSettleLag) ||
  466.                             !org.drip.numerical.common.NumberUtil.IsValid (_dblRecoveryRate = dblRecoveryRate) ||
  467.                                 0. >= _dblRecoveryRate || null == (_bond = bond))
  468.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  469.         _dblResetRate = dblResetRate;
  470.         _dblTenorBump = dblTenorBump;
  471.         _strGovvieCode = strGovvieCode;
  472.         _dblZSpreadBump = dblZSpreadBump;
  473.         _adblCreditQuote = adblCreditQuote;
  474.         _astrCreditTenor = astrCreditTenor;
  475.         _adblGovvieQuote = adblGovvieQuote;
  476.         _astrGovvieTenor = astrGovvieTenor;
  477.         _adblDepositQuote = adblDepositQuote;
  478.         _astrDepositTenor = astrDepositTenor;
  479.         _adblFuturesQuote = adblFuturesQuote;
  480.         _adblFixFloatQuote = adblFixFloatQuote;
  481.         _astrFixFloatTenor = astrFixFloatTenor;
  482.         _dblCustomYieldBump = dblCustomYieldBump;
  483.         _dblCustomCreditBasisBump = dblCustomCreditBasisBump;
  484.         _bMarketPriceCreditMetrics = bMarketPriceCreditMetrics;
  485.         _dblSpreadDurationMultiplier = dblSpreadDurationMultiplier;

  486.         java.lang.String strCurrency = _bond.currency();

  487.         if (null == (_dtSettle = _dtValue.addBusDays (_iSettleLag, strCurrency)))
  488.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  489.         _valParams = new org.drip.param.valuation.ValuationParams (_dtValue, _dtSettle, strCurrency);

  490.         org.drip.analytics.date.JulianDate dtSpot = dtValue;

  491.         org.drip.state.discount.MergedDiscountForwardCurve mdfc =
  492.             org.drip.service.template.LatentMarketStateBuilder.SmoothFundingCurve (dtSpot,
  493.                 strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate", _adblFuturesQuote,
  494.                     "ForwardRate", _astrFixFloatTenor, _adblFixFloatQuote, "SwapRate");

  495.         if (null == mdfc) throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  496.         org.drip.analytics.date.JulianDate[] adtSpot = org.drip.analytics.support.Helper.SpotDateArray
  497.             (dtSpot, null == _astrGovvieTenor ? 0 : _astrGovvieTenor.length);

  498.         org.drip.analytics.date.JulianDate[] adtMaturity = org.drip.analytics.support.Helper.FromTenor
  499.             (dtSpot, _astrGovvieTenor);

  500.         org.drip.state.govvie.GovvieCurve gc = org.drip.service.template.LatentMarketStateBuilder.GovvieCurve
  501.             (_strGovvieCode, dtSpot, adtSpot, adtMaturity, _adblGovvieQuote, _adblGovvieQuote, "Yield",
  502.                 org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING);

  503.         if (null == gc) throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  504.         if (_bond.isFloater()) {
  505.             org.drip.analytics.cashflow.CompositePeriod cp = _bond.stream().containingPeriod
  506.                 (dtSpot.julian());

  507.             if (null != cp && cp instanceof org.drip.analytics.cashflow.CompositeFloatingPeriod) {
  508.                 org.drip.analytics.cashflow.CompositeFloatingPeriod cfp =
  509.                     (org.drip.analytics.cashflow.CompositeFloatingPeriod) cp;

  510.                 _iResetDate = ((org.drip.analytics.cashflow.ComposableUnitFloatingPeriod) (cfp.periods().get
  511.                     (0))).referenceIndexPeriod().fixingDate();
  512.             }
  513.         }

  514.         if (null == (_csqcFundingBase = org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc, null,
  515.             null, null, null, null)))
  516.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  517.         org.drip.state.identifier.FloaterLabel fl = _bond.isFloater() ? _bond.floaterSetting().fri() : null;

  518.         if (_bond.isFloater() && java.lang.Integer.MIN_VALUE != _iResetDate) {
  519.             if (fl instanceof org.drip.state.identifier.ForwardLabel) {
  520.                 if (!_csqcFundingBase.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel) fl,
  521.                     _dblResetRate))
  522.                     throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  523.             } else if (fl instanceof org.drip.state.identifier.OTCFixFloatLabel) {
  524.             if (!_csqcFundingBase.setFixing (_iResetDate, (org.drip.state.identifier.OTCFixFloatLabel) fl,
  525.                 _dblResetRate))
  526.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  527.             }
  528.         }

  529.         if (null == (_csqcFunding01Up = org.drip.param.creator.MarketParamsBuilder.Create
  530.             (org.drip.service.template.LatentMarketStateBuilder.SmoothFundingCurve (dtSpot,
  531.                 strCurrency, _astrDepositTenor, org.drip.analytics.support.Helper.ParallelNodeBump
  532.                     (_adblDepositQuote, 0.0001), "ForwardRate",
  533.                         org.drip.analytics.support.Helper.ParallelNodeBump (_adblFuturesQuote, 0.0001),
  534.                             "ForwardRate", _astrFixFloatTenor,
  535.                                 org.drip.analytics.support.Helper.ParallelNodeBump (_adblFixFloatQuote,
  536.                                     0.0001), "SwapRate"), gc, null, null, null, null, null)))
  537.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  538.         if (_bond.isFloater() && java.lang.Integer.MIN_VALUE != _iResetDate) {
  539.             if (fl instanceof org.drip.state.identifier.ForwardLabel) {
  540.                 if (!_csqcFunding01Up.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel) fl,
  541.                     _dblResetRate /* + 0.0001 */))
  542.                     throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  543.             } else if (fl instanceof org.drip.state.identifier.OTCFixFloatLabel) {
  544.             if (!_csqcFunding01Up.setFixing (_iResetDate, (org.drip.state.identifier.OTCFixFloatLabel) fl,
  545.                 _dblResetRate /* + 0.0001 */))
  546.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  547.             }
  548.         }

  549.         if (null == (_csqcFundingEuroDollar = org.drip.param.creator.MarketParamsBuilder.Create
  550.             (org.drip.service.template.LatentMarketStateBuilder.SmoothFundingCurve (dtSpot,
  551.                 strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate", _adblFuturesQuote,
  552.                     "ForwardRate", null, null, "SwapRate"), gc, null, null, null, null, null)))
  553.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  554.         if (_bond.isFloater() && java.lang.Integer.MIN_VALUE != _iResetDate) {
  555.             if (fl instanceof org.drip.state.identifier.ForwardLabel) {
  556.                 if (!_csqcFundingEuroDollar.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel) fl,
  557.                     _dblResetRate))
  558.                     throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  559.             } else if (fl instanceof org.drip.state.identifier.OTCFixFloatLabel) {
  560.             if (!_csqcFundingEuroDollar.setFixing (_iResetDate, (org.drip.state.identifier.OTCFixFloatLabel) fl,
  561.                 _dblResetRate))
  562.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  563.             }
  564.         }

  565.         java.util.Map<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  566.             mapTenorForwardFundingUp =
  567.                 org.drip.service.template.LatentMarketStateBuilder.BumpedForwardFundingCurve (dtSpot,
  568.                     strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate", _adblFuturesQuote,
  569.                         "ForwardRate", _astrFixFloatTenor, _adblFixFloatQuote, "SwapRate",
  570.                             org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING, 0.0001 *
  571.                                 _dblTenorBump, false);

  572.         java.util.Map<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  573.             mapTenorForwardFundingDown =
  574.                 org.drip.service.template.LatentMarketStateBuilder.BumpedForwardFundingCurve (dtSpot,
  575.                     strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate", _adblFuturesQuote,
  576.                         "ForwardRate", _astrFixFloatTenor, _adblFixFloatQuote, "SwapRate",
  577.                             org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING, -0.0001 *
  578.                                 _dblTenorBump, false);

  579.         if (null == mapTenorForwardFundingUp || null == mapTenorForwardFundingDown)
  580.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  581.         for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  582.             meTenorForwardFundingUp : mapTenorForwardFundingUp.entrySet()) {
  583.             java.lang.String strKey = meTenorForwardFundingUp.getKey();

  584.             org.drip.param.market.CurveSurfaceQuoteContainer csqcForwardFundingTenorUp =
  585.                 org.drip.param.creator.MarketParamsBuilder.Create (meTenorForwardFundingUp.getValue(), gc,
  586.                     null, null, null, null, null);

  587.             org.drip.param.market.CurveSurfaceQuoteContainer csqcForwardFundingTenorDown =
  588.                 org.drip.param.creator.MarketParamsBuilder.Create (mapTenorForwardFundingDown.get (strKey),
  589.                     gc, null, null, null, null, null);

  590.             if (null == csqcForwardFundingTenorUp || null == csqcForwardFundingTenorDown)
  591.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  592.             _mapCSQCForwardFundingUp.put (strKey, csqcForwardFundingTenorUp);

  593.             _mapCSQCForwardFundingDown.put (strKey, csqcForwardFundingTenorDown);
  594.         }

  595.         java.util.Map<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  596.             mapTenorFundingUp = org.drip.service.template.LatentMarketStateBuilder.BumpedFundingCurve
  597.                 (dtSpot, strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate",
  598.                     _adblFuturesQuote, "ForwardRate", _astrFixFloatTenor, _adblFixFloatQuote, "SwapRate",
  599.                         org.drip.service.template.LatentMarketStateBuilder.SMOOTH, 0.0001 *
  600.                             _dblTenorBump, false);

  601.         java.util.Map<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  602.             mapTenorFundingDown = org.drip.service.template.LatentMarketStateBuilder.BumpedFundingCurve
  603.                 (dtSpot, strCurrency, _astrDepositTenor, _adblDepositQuote, "ForwardRate",
  604.                     _adblFuturesQuote, "ForwardRate", _astrFixFloatTenor, _adblFixFloatQuote, "SwapRate",
  605.                         org.drip.service.template.LatentMarketStateBuilder.SMOOTH, -0.0001 *
  606.                             _dblTenorBump, false);

  607.         if (null == mapTenorFundingUp || null == mapTenorFundingDown)
  608.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  609.         for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  610.             meTenorFundingUp : mapTenorFundingUp.entrySet()) {
  611.             java.lang.String strKey = meTenorFundingUp.getKey();

  612.             org.drip.param.market.CurveSurfaceQuoteContainer csqcFundingTenorUp =
  613.                 org.drip.param.creator.MarketParamsBuilder.Create (meTenorFundingUp.getValue(), gc, null,
  614.                     null, null, null, null);

  615.             org.drip.param.market.CurveSurfaceQuoteContainer csqcFundingTenorDown =
  616.                 org.drip.param.creator.MarketParamsBuilder.Create (mapTenorFundingDown.get (strKey), gc,
  617.                     null, null, null, null, null);

  618.             if (null == csqcFundingTenorUp || null == csqcFundingTenorDown)
  619.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  620.             if (_bond.isFloater() && java.lang.Integer.MIN_VALUE != _iResetDate) {
  621.                 if (fl instanceof org.drip.state.identifier.ForwardLabel) {
  622.                     if (!csqcFundingTenorUp.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel)
  623.                         fl, _dblResetRate /* + 0.0001 * _dblTenorBump */))
  624.                         throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  625.                     if (!csqcFundingTenorDown.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel)
  626.                         fl, _dblResetRate /* - 0.0001 * _dblTenorBump */))
  627.                         throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  628.                 } else if (fl instanceof org.drip.state.identifier.OTCFixFloatLabel) {
  629.                     if (!csqcFundingTenorUp.setFixing (_iResetDate,
  630.                         (org.drip.state.identifier.OTCFixFloatLabel) fl, _dblResetRate + 0.0001 *
  631.                             _dblTenorBump))
  632.                         throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  633.                     if (!csqcFundingTenorDown.setFixing (_iResetDate,
  634.                         (org.drip.state.identifier.OTCFixFloatLabel) fl, _dblResetRate - 0.0001 *
  635.                         _dblTenorBump))
  636.                         throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  637.                 }
  638.             }

  639.             _mapCSQCFundingUp.put (strKey, csqcFundingTenorUp);

  640.             _mapCSQCFundingDown.put (strKey, csqcFundingTenorDown);
  641.         }

  642.         java.util.Map<java.lang.String, org.drip.state.govvie.GovvieCurve> mapTenorGovvieUp =
  643.             org.drip.service.template.LatentMarketStateBuilder.BumpedGovvieCurve (_strGovvieCode, dtSpot,
  644.                 adtSpot, adtMaturity,_adblGovvieQuote, _adblGovvieQuote, "Yield",
  645.                     org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING, 0.0001 *
  646.                         _dblTenorBump, false);

  647.         java.util.Map<java.lang.String, org.drip.state.govvie.GovvieCurve> mapTenorGovvieDown =
  648.             org.drip.service.template.LatentMarketStateBuilder.BumpedGovvieCurve (_strGovvieCode, dtSpot,
  649.                 adtSpot, adtMaturity,_adblGovvieQuote, _adblGovvieQuote, "Yield",
  650.                     org.drip.service.template.LatentMarketStateBuilder.SHAPE_PRESERVING, -0.0001 *
  651.                         _dblTenorBump, false);

  652.         if (null == mapTenorGovvieUp || null == mapTenorGovvieDown)
  653.             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  654.         for (java.util.Map.Entry<java.lang.String, org.drip.state.govvie.GovvieCurve> meTenorGovvieUp :
  655.             mapTenorGovvieUp.entrySet()) {
  656.             java.lang.String strKey = meTenorGovvieUp.getKey();

  657.             org.drip.param.market.CurveSurfaceQuoteContainer csqcGovvieTenorUp =
  658.                 org.drip.param.creator.MarketParamsBuilder.Create (mdfc, meTenorGovvieUp.getValue(), null,
  659.                     null, null, null, null);

  660.             org.drip.param.market.CurveSurfaceQuoteContainer csqcGovvieTenorDown =
  661.                 org.drip.param.creator.MarketParamsBuilder.Create (mdfc, mapTenorGovvieDown.get (strKey),
  662.                     null, null, null, null, null);

  663.             if (null == csqcGovvieTenorUp || null == csqcGovvieTenorDown)
  664.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  665.             _mapCSQCGovvieUp.put (strKey, csqcGovvieTenorUp);

  666.             _mapCSQCGovvieDown.put (strKey, csqcGovvieTenorDown);

  667.             if ((_bond.isFloater() && java.lang.Integer.MIN_VALUE != _iResetDate) &&
  668.                 (!csqcGovvieTenorUp.setFixing (_iResetDate, fl, _dblResetRate) ||
  669.                     !csqcGovvieTenorDown.setFixing (_iResetDate, fl, _dblResetRate)))
  670.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  671.         }

  672.         org.drip.state.identifier.EntityCDSLabel cl = _bond.creditLabel();

  673.         java.lang.String strReferenceEntity = null != cl ? cl.referenceEntity() : null;

  674.         if (null == strReferenceEntity) return;

  675.         if (!_bMarketPriceCreditMetrics) {
  676.             if (null == (_csqcCreditBase = org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc,
  677.                 org.drip.service.template.LatentMarketStateBuilder.CreditCurve (dtSpot, strReferenceEntity,
  678.                     _astrCreditTenor, _adblCreditQuote, _adblCreditQuote, "FairPremium", mdfc), null, null,
  679.                         null, null)))
  680.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  681.             if (_bond.isFloater() && !_csqcCreditBase.setFixing (_iResetDate,
  682.                 (org.drip.state.identifier.ForwardLabel) fl, _dblResetRate))
  683.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  684.             if (null == (_csqcCredit01Up = org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc,
  685.                 org.drip.service.template.LatentMarketStateBuilder.CreditCurve (dtSpot, strReferenceEntity,
  686.                     _astrCreditTenor, _adblCreditQuote, org.drip.analytics.support.Helper.ParallelNodeBump
  687.                         (_adblCreditQuote, _dblTenorBump), "FairPremium", mdfc), null, null, null, null)))
  688.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  689.             if (_bond.isFloater() && !_csqcCredit01Up.setFixing (_iResetDate, fl, _dblResetRate))
  690.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  691.             java.util.Map<java.lang.String, org.drip.state.credit.CreditCurve> mapTenorCredit =
  692.                 org.drip.service.template.LatentMarketStateBuilder.BumpedCreditCurve (dtSpot,
  693.                     strReferenceEntity, _astrCreditTenor, _adblCreditQuote, _adblCreditQuote, "FairPremium",
  694.                         mdfc, _dblTenorBump, false);

  695.             if (null == mapTenorCredit)
  696.                 throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  697.             _mapCSQCCredit = new
  698.                 org.drip.analytics.support.CaseInsensitiveHashMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  699.             for (java.util.Map.Entry<java.lang.String, org.drip.state.credit.CreditCurve> meTenorCredit :
  700.                 mapTenorCredit.entrySet()) {
  701.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcCreditTenor =
  702.                     org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc, meTenorCredit.getValue(),
  703.                         null, null, null, null);

  704.                 if (null == csqcCreditTenor)
  705.                     throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");

  706.                 _mapCSQCCredit.put (meTenorCredit.getKey(), csqcCreditTenor);

  707.                 if (_bond.isFloater() && !csqcCreditTenor.setFixing (_iResetDate, fl, _dblResetRate))
  708.                     throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  709.             }
  710.         } else {
  711.             org.drip.state.credit.CreditCurve ccBase =
  712.                 org.drip.state.creator.ScenarioCreditCurveBuilder.Custom (strReferenceEntity, dtSpot, new
  713.                     org.drip.product.definition.CalibratableComponent[] {bond}, mdfc, new double[]
  714.                         {_dblCurrentPrice}, new java.lang.String[] {"Price"}, _dblRecoveryRate, false, new
  715.                             org.drip.param.definition.CalibrationParams ("Price", 0,
  716.                                 _bond.exerciseYieldFromPrice (_valParams, _csqcFundingBase, null,
  717.                                     _dblCurrentPrice)));

  718.             if (null == ccBase || null == (_csqcCreditBase =
  719.                 org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc, ccBase, null, null, null,
  720.                     null)))
  721.                 return;

  722.             if (_bond.isFloater())
  723.             {
  724.                 if (null != fl && org.drip.numerical.common.NumberUtil.IsValid (_dblResetRate))
  725.                 {
  726.                     if (fl instanceof org.drip.state.identifier.ForwardLabel)
  727.                     {
  728.                         if (!_csqcCreditBase.setFixing (_iResetDate, (org.drip.state.identifier.ForwardLabel)
  729.                             fl, _dblResetRate))
  730.                         {
  731.                             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  732.                         }
  733.                     } else if (fl instanceof org.drip.state.identifier.OTCFixFloatLabel)
  734.                     {
  735.                         if (!_csqcCreditBase.setFixing (_iResetDate,
  736.                             (org.drip.state.identifier.OTCFixFloatLabel) fl, _dblResetRate))
  737.                         {
  738.                             throw new java.lang.Exception ("BondReplicator Constructor => Invalid Inputs");
  739.                         }
  740.                     }
  741.                 }
  742.             }

  743.             _csqcCredit01Up = org.drip.param.creator.MarketParamsBuilder.Create (mdfc, gc,
  744.                 org.drip.state.creator.ScenarioCreditCurveBuilder.FlatHazard (dtSpot.julian(),
  745.                     strReferenceEntity, strCurrency, ccBase.hazard (bond.maturityDate()) + 0.0001,
  746.                         _dblRecoveryRate), null, null, null, null);
  747.         }

  748.         _emr = !_bond.callable() && _bond.putable() ? null :
  749.             org.drip.service.scenario.EOSMetricsReplicator.Standard (
  750.                 _bond,
  751.                 _valParams,
  752.                 _csqcFundingBase,
  753.                 new org.drip.state.sequence.GovvieBuilderSettings (
  754.                     dtSpot,
  755.                     _strGovvieCode,
  756.                     _astrGovvieTenor,
  757.                     _adblGovvieQuote,
  758.                     _adblGovvieQuote
  759.                 ),
  760.                 _dblLogNormalVolatility,
  761.                 _dblCurrentPrice
  762.             );
  763.     }

  764.     /**
  765.      * Retrieve the Bond Current Market Price
  766.      *
  767.      * @return The Bond Current Market Price
  768.      */

  769.     public double currentPrice()
  770.     {
  771.         return _dblCurrentPrice;
  772.     }

  773.     /**
  774.      * Retrieve the Bond Issue Price
  775.      *
  776.      * @return The Bond Issue Price
  777.      */

  778.     public double issuePrice()
  779.     {
  780.         return _dblIssuePrice;
  781.     }

  782.     /**
  783.      * Retrieve the Bond Issue Amount
  784.      *
  785.      * @return The Bond Issue Amount
  786.      */

  787.     public double issueAmount()
  788.     {
  789.         return _dblIssueAmount;
  790.     }

  791.     /**
  792.      * Retrieve the Value Date
  793.      *
  794.      * @return The Value Date
  795.      */

  796.     public org.drip.analytics.date.JulianDate valueDate()
  797.     {
  798.         return _dtValue;
  799.     }

  800.     /**
  801.      * Retrieve the Array of Deposit Instrument Maturity Tenors
  802.      *
  803.      * @return The Array of Deposit Instrument Maturity Tenors
  804.      */

  805.     public java.lang.String[] depositTenor()
  806.     {
  807.         return _astrDepositTenor;
  808.     }

  809.     /**
  810.      * Retrieve the Array of Deposit Instrument Quotes
  811.      *
  812.      * @return The Array of Deposit Instrument Quotes
  813.      */

  814.     public double[] depositQuote()
  815.     {
  816.         return _adblDepositQuote;
  817.     }

  818.     /**
  819.      * Retrieve the Array of Futures Instrument Quotes
  820.      *
  821.      * @return The Array of Futures Instrument Quotes
  822.      */

  823.     public double[] futuresQuote()
  824.     {
  825.         return _adblFuturesQuote;
  826.     }

  827.     /**
  828.      * Retrieve the Array of Fix-Float IRS Instrument Maturity Tenors
  829.      *
  830.      * @return The Array of Fix-Float IRS Instrument Maturity Tenors
  831.      */

  832.     public java.lang.String[] fixFloatTenor()
  833.     {
  834.         return _astrFixFloatTenor;
  835.     }

  836.     /**
  837.      * Retrieve the Array of Fix-Float IRS Instrument Quotes
  838.      *
  839.      * @return The Array of Fix-Float IRS Instrument Quotes
  840.      */

  841.     public double[] fixFloatQuote()
  842.     {
  843.         return _adblFixFloatQuote;
  844.     }

  845.     /**
  846.      * Retrieve the Recovery Rate
  847.      *
  848.      * @return The Recovery Rate
  849.      */

  850.     public double recoveryRate()
  851.     {
  852.         return _dblRecoveryRate;
  853.     }

  854.     /**
  855.      * Retrieve the Custom Yield Bump
  856.      *
  857.      * @return The Custom Yield Bump
  858.      */

  859.     public double customYieldBump()
  860.     {
  861.         return _dblCustomYieldBump;
  862.     }

  863.     /**
  864.      * Retrieve the Custom Credit Basis Bump
  865.      *
  866.      * @return The Custom Credit Basis Bump
  867.      */

  868.     public double customCreditBasisBump()
  869.     {
  870.         return _dblCustomCreditBasisBump;
  871.     }

  872.     /**
  873.      * Retrieve the Z Spread Bump
  874.      *
  875.      * @return The Z Spread Bump
  876.      */

  877.     public double zSpreadBump()
  878.     {
  879.         return _dblZSpreadBump;
  880.     }

  881.     /**
  882.      * Retrieve the Tenor Quote Bump
  883.      *
  884.      * @return The Tenor Quote Bump
  885.      */

  886.     public double tenorBump()
  887.     {
  888.         return _dblTenorBump;
  889.     }

  890.     /**
  891.      * Retrieve the Spread Duration Multiplier
  892.      *
  893.      * @return The Spread Duration Multiplier
  894.      */

  895.     public double spreadDurationMultiplier()
  896.     {
  897.         return _dblSpreadDurationMultiplier;
  898.     }

  899.     /**
  900.      * Retrieve the Govvie Code
  901.      *
  902.      * @return The Govvie Code
  903.      */

  904.     public java.lang.String govvieCode()
  905.     {
  906.         return _strGovvieCode;
  907.     }

  908.     /**
  909.      * Retrieve the Array of Govvie Instrument Maturity Tenors
  910.      *
  911.      * @return The Array of Govvie Instrument Maturity Tenors
  912.      */

  913.     public java.lang.String[] govvieTenor()
  914.     {
  915.         return _astrGovvieTenor;
  916.     }

  917.     /**
  918.      * Retrieve the Array of Govvie Yield Quotes
  919.      *
  920.      * @return The Array of Govvie Yield Quotes
  921.      */

  922.     public double[] govvieQuote()
  923.     {
  924.         return _adblGovvieQuote;
  925.     }

  926.     /**
  927.      * Retrieve the Flag that indicates the Generation the Credit Metrics from the Market Price
  928.      *
  929.      * @return TRUE - Generate the Credit Metrics from the Market Price
  930.      */

  931.     public boolean creditMetricsFromMarketPrice()
  932.     {
  933.         return _bMarketPriceCreditMetrics;
  934.     }

  935.     /**
  936.      * Retrieve the Array of CDS Instrument Maturity Tenors
  937.      *
  938.      * @return The Array of CDS Instrument Maturity Tenors
  939.      */

  940.     public java.lang.String[] creditTenor()
  941.     {
  942.         return _astrCreditTenor;
  943.     }

  944.     /**
  945.      * Retrieve the Array of CDS Quotes
  946.      *
  947.      * @return The Array of CDS Quotes
  948.      */

  949.     public double[] creditQuote()
  950.     {
  951.         return _adblCreditQuote;
  952.     }

  953.     /**
  954.      * Retrieve the FX Rate
  955.      *
  956.      * @return The FX Rate
  957.      */

  958.     public double fx()
  959.     {
  960.         return _dblFX;
  961.     }

  962.     /**
  963.      * Retrieve the Settle Lag
  964.      *
  965.      * @return The Settle Lag
  966.      */

  967.     public double settleLag()
  968.     {
  969.         return _iSettleLag;
  970.     }

  971.     /**
  972.      * Retrieve the Bond Component Instance
  973.      *
  974.      * @return The Bond Component Instance
  975.      */

  976.     public org.drip.product.credit.BondComponent bond()
  977.     {
  978.         return _bond;
  979.     }

  980.     /**
  981.      * Retrieve the Settle Date
  982.      *
  983.      * @return The Settle Date
  984.      */

  985.     public org.drip.analytics.date.JulianDate settleDate()
  986.     {
  987.         return _dtSettle;
  988.     }

  989.     /**
  990.      * Retrieve the Valuation Parameters
  991.      *
  992.      * @return The Valuation Parameters
  993.      */

  994.     public org.drip.param.valuation.ValuationParams valuationParameters()
  995.     {
  996.         return _valParams;
  997.     }

  998.     /**
  999.      * Retrieve the Map of the Tenor Bumped Up Instances of the Funding Curve CSQC
  1000.      *
  1001.      * @return The Map of the Tenor Bumped Up Instances of the Funding Curve CSQC
  1002.      */

  1003.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1004.         fundingTenorCSQCUp()
  1005.     {
  1006.         return _mapCSQCFundingUp;
  1007.     }

  1008.     /**
  1009.      * Retrieve the Map of the Tenor Bumped Down Instances of the Funding Curve CSQC
  1010.      *
  1011.      * @return The Map of the Tenor Bumped Down Instances of the Funding Curve CSQC
  1012.      */

  1013.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1014.         fundingTenorCSQCDown()
  1015.     {
  1016.         return _mapCSQCFundingDown;
  1017.     }

  1018.     /**
  1019.      * Retrieve the Map of the Tenor Bumped Up Instances of the Forward Funding Curve CSQC
  1020.      *
  1021.      * @return The Map of the Tenor Bumped Up Instances of the Forward Funding Curve CSQC
  1022.      */

  1023.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1024.         forwardFundingTenorCSQCUp()
  1025.     {
  1026.         return _mapCSQCForwardFundingUp;
  1027.     }

  1028.     /**
  1029.      * Retrieve the Map of the Tenor Bumped Down Instances of the Forward Funding Curve CSQC
  1030.      *
  1031.      * @return The Map of the Tenor Bumped Down Instances of the Forward Funding Curve CSQC
  1032.      */

  1033.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1034.         forwardFundingTenorCSQCDown()
  1035.     {
  1036.         return _mapCSQCForwardFundingDown;
  1037.     }

  1038.     /**
  1039.      * Retrieve the Map of the Tenor Bumped Up Instances of the Govvie Curve CSQC
  1040.      *
  1041.      * @return The Map of the Tenor Bumped Up Instances of the Govvie Curve CSQC
  1042.      */

  1043.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1044.         govvieTenorCSQCUp()
  1045.     {
  1046.         return _mapCSQCGovvieUp;
  1047.     }

  1048.     /**
  1049.      * Retrieve the Map of the Tenor Bumped Down Instances of the Govvie Curve CSQC
  1050.      *
  1051.      * @return The Map of the Tenor Bumped Down Instances of the Govvie Curve CSQC
  1052.      */

  1053.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1054.         govvieTenorCSQCDown()
  1055.     {
  1056.         return _mapCSQCGovvieDown;
  1057.     }

  1058.     /**
  1059.      * Retrieve the Map of the Tenor Bumped Instances of the Credit Curve CSQC
  1060.      *
  1061.      * @return The Map of the Tenor Bumped Instances of the Credit Curve CSQC
  1062.      */

  1063.     public java.util.Map<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1064.         creditTenorCSQC()
  1065.     {
  1066.         return _mapCSQCCredit;
  1067.     }

  1068.     /**
  1069.      * Retrieve the CSQC built out of the Base Funding Curve
  1070.      *
  1071.      * @return The CSQC built out of the Base Funding Curve
  1072.      */

  1073.     public org.drip.param.market.CurveSurfaceQuoteContainer fundingBaseCSQC()
  1074.     {
  1075.         return _csqcFundingBase;
  1076.     }

  1077.     /**
  1078.      * Retrieve the CSQC built out of the Base Euro Dollar Curve
  1079.      *
  1080.      * @return The CSQC built out of the Base Euro Dollar Curve
  1081.      */

  1082.     public org.drip.param.market.CurveSurfaceQuoteContainer fundingEuroDollarCSQC()
  1083.     {
  1084.         return _csqcFundingEuroDollar;
  1085.     }

  1086.     /**
  1087.      * Retrieve the CSQC built out of the Base Credit Curve
  1088.      *
  1089.      * @return The CSQC built out of the Base Credit Curve
  1090.      */

  1091.     public org.drip.param.market.CurveSurfaceQuoteContainer creditBaseCSQC()
  1092.     {
  1093.         return _csqcCreditBase;
  1094.     }

  1095.     /**
  1096.      * Retrieve the CSQC built out of the Funding Curve Flat Bumped 1 bp
  1097.      *
  1098.      * @return The CSQC built out of the Funding Curve Flat Bumped 1 bp
  1099.      */

  1100.     public org.drip.param.market.CurveSurfaceQuoteContainer funding01UpCSQC()
  1101.     {
  1102.         return _csqcFunding01Up;
  1103.     }

  1104.     /**
  1105.      * Retrieve the CSQC built out of the Credit Curve Flat Bumped 1 bp
  1106.      *
  1107.      * @return The CSQC built out of the Credit Curve Flat Bumped 1 bp
  1108.      */

  1109.     public org.drip.param.market.CurveSurfaceQuoteContainer credit01UpCSQC()
  1110.     {
  1111.         return _csqcCredit01Up;
  1112.     }

  1113.     /**
  1114.      * Retrieve the Reset Date
  1115.      *
  1116.      * @return The Reset Date
  1117.      */

  1118.     public int resetDate()
  1119.     {
  1120.         return _iResetDate;
  1121.     }

  1122.     /**
  1123.      * Retrieve the Reset Rate
  1124.      *
  1125.      * @return The Reset Rate
  1126.      */

  1127.     public double resetRate()
  1128.     {
  1129.         return _dblResetRate;
  1130.     }

  1131.     /**
  1132.      * Retrieve the EOS Metrics Replicator
  1133.      *
  1134.      * @return The EOS Metrics Replicator
  1135.      */

  1136.     public org.drip.service.scenario.EOSMetricsReplicator eosMetricsReplicator()
  1137.     {
  1138.         return _emr;
  1139.     }

  1140.     /**
  1141.      * Generate an Instance of a Replication Run
  1142.      *
  1143.      * @return Instance of a Replication Run
  1144.      */

  1145.     public org.drip.service.scenario.BondReplicationRun generateRun()
  1146.     {
  1147.         int iMaturityDate = _bond.maturityDate().julian();

  1148.         double dblNextPutFactor = 1.;
  1149.         double dblNextCallFactor = 1.;
  1150.         int iNextPutDate = iMaturityDate;
  1151.         int iNextCallDate = iMaturityDate;
  1152.         double dblCV01 = java.lang.Double.NaN;
  1153.         double dblAccrued = java.lang.Double.NaN;
  1154.         double dblYield01 = java.lang.Double.NaN;
  1155.         double dblNominalYield = java.lang.Double.NaN;
  1156.         double dblBEYToMaturity = java.lang.Double.NaN;
  1157.         double dblOASToExercise = java.lang.Double.NaN;
  1158.         double dblOASToMaturity = java.lang.Double.NaN;
  1159.         double dblSpreadDuration = java.lang.Double.NaN;
  1160.         double dblYieldToMaturity = java.lang.Double.NaN;
  1161.         double dblParOASToExercise = java.lang.Double.NaN;
  1162.         double dblESpreadToExercise = java.lang.Double.NaN;
  1163.         double dblISpreadToExercise = java.lang.Double.NaN;
  1164.         double dblJSpreadToExercise = java.lang.Double.NaN;
  1165.         double dblNSpreadToExercise = java.lang.Double.NaN;
  1166.         double dblZSpreadToExercise = java.lang.Double.NaN;
  1167.         double dblZSpreadToMaturity = java.lang.Double.NaN;
  1168.         double dblBondBasisToExercise = java.lang.Double.NaN;
  1169.         double dblBondBasisToMaturity = java.lang.Double.NaN;
  1170.         double dblConvexityToExercise = java.lang.Double.NaN;
  1171.         double dblWALCreditToExercise = java.lang.Double.NaN;
  1172.         double dblParZSpreadToExercise = java.lang.Double.NaN;
  1173.         double dblCreditBasisToExercise = java.lang.Double.NaN;
  1174.         double dblWALLossOnlyToExercise = java.lang.Double.NaN;
  1175.         double dblYieldFromPriceNextPut = java.lang.Double.NaN;
  1176.         double dblYieldFromPriceNextCall = java.lang.Double.NaN;
  1177.         double dblWALCouponOnlyToExercise = java.lang.Double.NaN;
  1178.         double dblDiscountMarginToExercise = java.lang.Double.NaN;
  1179.         double dblParCreditBasisToExercise = java.lang.Double.NaN;
  1180.         double dblYieldToMaturityFwdCoupon = java.lang.Double.NaN;
  1181.         double dblEffectiveDurationAdjusted = java.lang.Double.NaN;
  1182.         double dblMacaulayDurationToMaturity = java.lang.Double.NaN;
  1183.         double dblModifiedDurationToExercise = java.lang.Double.NaN;
  1184.         double dblModifiedDurationToMaturity = java.lang.Double.NaN;
  1185.         double dblWALPrincipalOnlyToExercise = java.lang.Double.NaN;
  1186.         double dblWALPrincipalOnlyToMaturity = java.lang.Double.NaN;
  1187.         java.util.Map<java.lang.String, java.lang.Double> mapCreditKRD = null;
  1188.         java.util.Map<java.lang.String, java.lang.Double> mapCreditKPRD = null;

  1189.         int iValueDate = _dtValue.julian();

  1190.         java.lang.String strCurrency = _bond.currency();

  1191.         org.drip.product.params.EmbeddedOptionSchedule eosPut = _bond.putSchedule();

  1192.         org.drip.product.params.EmbeddedOptionSchedule eosCall = _bond.callSchedule();

  1193.         org.drip.service.scenario.BondReplicationRun arr = new
  1194.             org.drip.service.scenario.BondReplicationRun();

  1195.         org.drip.param.valuation.WorkoutInfo wi = _bond.exerciseYieldFromPrice (_valParams, _csqcFundingBase,
  1196.             null, _dblCurrentPrice);

  1197.         if (null == wi) return null;

  1198.         int iWorkoutDate = wi.date();

  1199.         double dblWorkoutFactor = wi.factor();

  1200.         double dblYieldToExercise = wi.yield();

  1201.         java.util.Map<java.lang.String, java.lang.Double> mapLIBORKRD = new
  1202.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1203.         java.util.Map<java.lang.String, java.lang.Double> mapLIBORKPRD = new
  1204.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1205.         java.util.Map<java.lang.String, java.lang.Double> mapFundingKRD = new
  1206.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1207.         java.util.Map<java.lang.String, java.lang.Double> mapFundingKPRD = new
  1208.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1209.         java.util.Map<java.lang.String, java.lang.Double> mapGovvieKRD = new
  1210.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1211.         java.util.Map<java.lang.String, java.lang.Double> mapGovvieKPRD = new
  1212.             org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1213.         try {
  1214.             if (null != eosCall) {
  1215.                 iNextCallDate = eosCall.nextDate (iValueDate);

  1216.                 dblNextCallFactor = eosCall.nextFactor (iValueDate);
  1217.             }

  1218.             if (null != eosPut) {
  1219.                 iNextPutDate = eosPut.nextDate (iValueDate);

  1220.                 dblNextPutFactor = eosPut.nextFactor (iValueDate);
  1221.             }
  1222.         } catch (java.lang.Exception e) {
  1223.             e.printStackTrace();

  1224.             return null;
  1225.         }

  1226.         try {
  1227.             dblAccrued = _bond.accrued (_dtSettle.julian(), _csqcFundingBase);
  1228.         } catch (java.lang.Exception e) {
  1229.             e.printStackTrace();

  1230.             return null;
  1231.         }

  1232.         try {
  1233.             dblYieldToMaturity = _bond.yieldFromPrice (_valParams, _csqcFundingBase, null, _dblCurrentPrice);
  1234.         } catch (java.lang.Exception e) {
  1235.             e.printStackTrace();

  1236.             return null;
  1237.         }

  1238.         try {
  1239.             dblBEYToMaturity = _bond.yieldFromPrice (_valParams, _csqcFundingBase,
  1240.                 org.drip.param.valuation.ValuationCustomizationParams.BondEquivalent (strCurrency),
  1241.                     _dblCurrentPrice);
  1242.         } catch (java.lang.Exception e) {
  1243.             e.printStackTrace();

  1244.             return null;
  1245.         }

  1246.         try {
  1247.             dblYieldToMaturityFwdCoupon = _bond.yieldFromPrice (_valParams, _csqcFundingBase, new
  1248.                 org.drip.param.valuation.ValuationCustomizationParams (_bond.couponDC(), _bond.freq(), false,
  1249.                     null, strCurrency, false, true), _dblCurrentPrice);
  1250.         } catch (java.lang.Exception e) {
  1251.             e.printStackTrace();

  1252.             return null;
  1253.         }

  1254.         try {
  1255.             dblYieldFromPriceNextCall = _bond.yieldFromPrice (_valParams, _csqcFundingBase, null,
  1256.                 iNextCallDate, dblNextCallFactor, _dblCurrentPrice);
  1257.         } catch (java.lang.Exception e) {
  1258.             e.printStackTrace();

  1259.             return null;
  1260.         }

  1261.         try {
  1262.             dblYieldFromPriceNextPut = _bond.yieldFromPrice (_valParams, _csqcFundingBase, null,
  1263.                 iNextPutDate, dblNextPutFactor, _dblCurrentPrice);
  1264.         } catch (java.lang.Exception e) {
  1265.             e.printStackTrace();

  1266.             return null;
  1267.         }

  1268.         try {
  1269.             dblNominalYield = _bond.yieldFromPrice (_valParams, _csqcFundingBase, null, _dblIssuePrice);
  1270.         } catch (java.lang.Exception e) {
  1271.             e.printStackTrace();

  1272.             return null;
  1273.         }

  1274.         try {
  1275.             dblOASToMaturity = _bond.oasFromPrice (_valParams, _csqcFundingBase, null, _dblCurrentPrice);
  1276.         } catch (java.lang.Exception e) {
  1277.             e.printStackTrace();
  1278.         }

  1279.         try {
  1280.             dblZSpreadToMaturity = _bond.isFloater() ? _bond.discountMarginFromPrice (_valParams,
  1281.                 _csqcFundingBase, null, _dblCurrentPrice) : _bond.zSpreadFromPrice (_valParams,
  1282.                     _csqcFundingBase, null, _dblCurrentPrice);
  1283.         } catch (java.lang.Exception e) {
  1284.             e.printStackTrace();
  1285.         }

  1286.         try {
  1287.              dblZSpreadToExercise = _bond.isFloater() ? _bond.discountMarginFromPrice (_valParams,
  1288.                 _csqcFundingBase, null, iWorkoutDate, dblWorkoutFactor, _dblCurrentPrice) :
  1289.                     _bond.zSpreadFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1290.                         dblWorkoutFactor, _dblCurrentPrice);
  1291.         } catch (java.lang.Exception e) {
  1292.             e.printStackTrace();
  1293.         }

  1294.         try {
  1295.              dblParZSpreadToExercise = _bond.isFloater() ? _bond.discountMarginFromPrice (_valParams,
  1296.                 _csqcFundingBase, null, iWorkoutDate, dblWorkoutFactor, _dblIssuePrice) :
  1297.                     _bond.zSpreadFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1298.                         dblWorkoutFactor, _dblIssuePrice);
  1299.         } catch (java.lang.Exception e) {
  1300.             e.printStackTrace();
  1301.         }

  1302.         try {
  1303.             dblBondBasisToMaturity = _bond.bondBasisFromPrice (_valParams, _csqcFundingBase, null,
  1304.                 _dblCurrentPrice);
  1305.         } catch (java.lang.Exception e) {
  1306.             e.printStackTrace();
  1307.         }

  1308.         try {
  1309.             dblBondBasisToExercise = _bond.bondBasisFromPrice (_valParams, _csqcFundingBase, null,
  1310.                 iWorkoutDate, dblWorkoutFactor, _dblCurrentPrice);
  1311.         } catch (java.lang.Exception e) {
  1312.             e.printStackTrace();
  1313.         }

  1314.         try {
  1315.             dblModifiedDurationToMaturity = (_dblCurrentPrice - _bond.priceFromBondBasis (_valParams,
  1316.                 _csqcFunding01Up, null, dblBondBasisToMaturity)) / _dblCurrentPrice;
  1317.         } catch (java.lang.Exception e) {
  1318.             e.printStackTrace();
  1319.         }

  1320.         try {
  1321.             dblMacaulayDurationToMaturity = _bond.macaulayDurationFromPrice (_valParams, _csqcFundingBase,
  1322.                 null, _dblCurrentPrice);
  1323.         } catch (java.lang.Exception e) {
  1324.             e.printStackTrace();
  1325.         }

  1326.         try {
  1327.             dblModifiedDurationToExercise = (_dblCurrentPrice - _bond.priceFromBondBasis (_valParams,
  1328.                 _csqcFunding01Up, null, iWorkoutDate, dblWorkoutFactor, dblBondBasisToExercise)) /
  1329.                     _dblCurrentPrice;
  1330.         } catch (java.lang.Exception e) {
  1331.             e.printStackTrace();
  1332.         }

  1333.         try {
  1334.             dblYield01 = 0.5 * (_bond.priceFromYield (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1335.                 dblWorkoutFactor, dblYieldToExercise - 0.0001 * _dblCustomYieldBump) - _bond.priceFromYield
  1336.                     (_valParams, _csqcFundingBase, null, iWorkoutDate, dblWorkoutFactor, dblYieldToExercise +
  1337.                         0.0001 * _dblCustomYieldBump)) / _dblCustomYieldBump;
  1338.         } catch (java.lang.Exception e) {
  1339.             e.printStackTrace();
  1340.         }

  1341.         try {
  1342.             if (null != _csqcCreditBase)
  1343.                 dblCreditBasisToExercise = _bMarketPriceCreditMetrics ? 0. : _bond.creditBasisFromPrice
  1344.                     (_valParams, _csqcCreditBase, null, iWorkoutDate, dblWorkoutFactor, _dblCurrentPrice);
  1345.         } catch (java.lang.Exception e) {
  1346.             e.printStackTrace();
  1347.         }

  1348.         try {
  1349.             if (null != _csqcCreditBase)
  1350.                 dblParCreditBasisToExercise = _bond.creditBasisFromPrice (_valParams, _csqcCreditBase, null,
  1351.                     iWorkoutDate, dblWorkoutFactor, _dblIssuePrice);
  1352.         } catch (java.lang.Exception e) {
  1353.             e.printStackTrace();
  1354.         }

  1355.         try {
  1356.             if (null != _csqcCreditBase) {
  1357.                 if (!_bMarketPriceCreditMetrics)
  1358.                     dblEffectiveDurationAdjusted = (_dblCurrentPrice - _bond.priceFromCreditBasis
  1359.                         (_valParams, _csqcCreditBase, null, iWorkoutDate, dblWorkoutFactor,
  1360.                             dblCreditBasisToExercise + 0.0001 * _dblCustomCreditBasisBump)) /
  1361.                                 _dblCurrentPrice / _dblCustomCreditBasisBump;
  1362.                 else {
  1363.                     org.drip.state.identifier.EntityCDSLabel cl = _bond.creditLabel();

  1364.                     org.drip.state.credit.CreditCurve ccBase = _csqcCreditBase.creditState (cl);

  1365.                     org.drip.state.credit.CreditCurve ccAdj =
  1366.                         org.drip.state.creator.ScenarioCreditCurveBuilder.FlatHazard (_dtValue.julian(),
  1367.                             cl.referenceEntity(), strCurrency, ccBase.hazard (_bond.maturityDate()) + 0.0001
  1368.                                 * _dblCustomCreditBasisBump, _dblRecoveryRate);

  1369.                     if (null != ccAdj)
  1370.                         dblEffectiveDurationAdjusted = (_dblCurrentPrice - _bond.priceFromCreditBasis
  1371.                             (_valParams, org.drip.param.creator.MarketParamsBuilder.Create
  1372.                                 (_csqcCreditBase.fundingState (_bond.fundingLabel()),
  1373.                                     _csqcCreditBase.govvieState (_bond.govvieLabel()), ccAdj, "", null, null,
  1374.                                         _csqcCreditBase.fixings()), null, iWorkoutDate, dblWorkoutFactor,
  1375.                                             0.)) / _dblCurrentPrice / _dblCustomCreditBasisBump;
  1376.                 }
  1377.             }
  1378.         } catch (java.lang.Exception e) {
  1379.             e.printStackTrace();
  1380.         }

  1381.         try {
  1382.             dblSpreadDuration = _dblSpreadDurationMultiplier * (_dblCurrentPrice - (_bond.isFloater() ?
  1383.                 _bond.priceFromDiscountMargin (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1384.                     dblWorkoutFactor, dblZSpreadToExercise + 0.0001 * _dblZSpreadBump) :
  1385.                         _bond.priceFromZSpread (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1386.                             dblWorkoutFactor, dblZSpreadToExercise + 0.0001 * _dblZSpreadBump))) /
  1387.                                 _dblCurrentPrice;
  1388.         } catch (java.lang.Exception e) {
  1389.             e.printStackTrace();
  1390.         }

  1391.         try {
  1392.             if (null != _csqcCredit01Up)
  1393.                 dblCV01 = _dblCurrentPrice - _bond.priceFromCreditBasis (_valParams, _csqcCredit01Up, null,
  1394.                     iWorkoutDate, dblWorkoutFactor, dblCreditBasisToExercise);
  1395.         } catch (java.lang.Exception e) {
  1396.             e.printStackTrace();
  1397.         }

  1398.         try {
  1399.             dblConvexityToExercise = _bond.convexityFromPrice (_valParams, _csqcFundingBase, null,
  1400.                 iWorkoutDate, dblWorkoutFactor, _dblCurrentPrice);
  1401.         } catch (java.lang.Exception e) {
  1402.             e.printStackTrace();
  1403.         }

  1404.         try {
  1405.             dblDiscountMarginToExercise = dblYieldToExercise - _csqcFundingBase.fundingState
  1406.                 (_bond.fundingLabel()).libor (_valParams.valueDate(), "1M");
  1407.         } catch (java.lang.Exception e) {
  1408.             e.printStackTrace();
  1409.         }

  1410.         try {
  1411.             dblESpreadToExercise = _bond.isFloater() ? _bond.discountMarginFromPrice (_valParams,
  1412.                 _csqcFundingEuroDollar, null, iWorkoutDate, dblWorkoutFactor, _dblCurrentPrice) :
  1413.                     _bond.zSpreadFromPrice (_valParams, _csqcFundingEuroDollar, null, iWorkoutDate,
  1414.                         dblWorkoutFactor, _dblCurrentPrice);
  1415.         } catch (java.lang.Exception e) {
  1416.             e.printStackTrace();
  1417.         }

  1418.         try {
  1419.             dblISpreadToExercise = _bond.iSpreadFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1420.                 dblWorkoutFactor, _dblCurrentPrice);
  1421.         } catch (java.lang.Exception e) {
  1422.             e.printStackTrace();
  1423.         }

  1424.         try {
  1425.             dblJSpreadToExercise = _bond.jSpreadFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1426.                 dblWorkoutFactor, _dblCurrentPrice);
  1427.         } catch (java.lang.Exception e) {
  1428.             e.printStackTrace();
  1429.         }

  1430.         try {
  1431.             dblNSpreadToExercise = _bond.nSpreadFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1432.                 dblWorkoutFactor, _dblCurrentPrice);
  1433.         } catch (java.lang.Exception e) {
  1434.             e.printStackTrace();
  1435.         }

  1436.         try {
  1437.             dblWALPrincipalOnlyToExercise = _bond.weightedAverageLifePrincipalOnly (_valParams,
  1438.                 _csqcFundingBase, iWorkoutDate, dblWorkoutFactor);
  1439.         } catch (java.lang.Exception e) {
  1440.             e.printStackTrace();
  1441.         }

  1442.         try {
  1443.             dblWALPrincipalOnlyToMaturity = _bond.weightedAverageLifePrincipalOnly (_valParams,
  1444.                 _csqcFundingBase, iMaturityDate, 1.);
  1445.         } catch (java.lang.Exception e) {
  1446.             e.printStackTrace();
  1447.         }

  1448.         try {
  1449.             if (null != _csqcCreditBase)
  1450.                 dblWALLossOnlyToExercise = _bond.weightedAverageLifeLossOnly (_valParams, _csqcCreditBase,
  1451.                     iWorkoutDate, dblWorkoutFactor);
  1452.         } catch (java.lang.Exception e) {
  1453.             e.printStackTrace();
  1454.         }

  1455.         try {
  1456.             dblWALCouponOnlyToExercise = _bond.weightedAverageLifeCouponOnly (_valParams, _csqcFundingBase,
  1457.                 iWorkoutDate, dblWorkoutFactor);
  1458.         } catch (java.lang.Exception e) {
  1459.             e.printStackTrace();
  1460.         }

  1461.         try {
  1462.             if (null != _csqcCreditBase)
  1463.                 dblWALCreditToExercise = _bond.weightedAverageLifeCredit (_valParams, _csqcCreditBase,
  1464.                     iWorkoutDate, dblWorkoutFactor);
  1465.         } catch (java.lang.Exception e) {
  1466.             e.printStackTrace();
  1467.         }

  1468.         try {
  1469.             dblOASToExercise = _bond.oasFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1470.                 dblWorkoutFactor, _dblCurrentPrice);
  1471.         } catch (java.lang.Exception e) {
  1472.             e.printStackTrace();
  1473.         }

  1474.         try {
  1475.             dblParOASToExercise = _bond.oasFromPrice (_valParams, _csqcFundingBase, null, iWorkoutDate,
  1476.                 dblWorkoutFactor, _dblIssuePrice);
  1477.         } catch (java.lang.Exception e) {
  1478.             e.printStackTrace();
  1479.         }

  1480.         double dblEffectiveDuration = dblYield01 / _dblCurrentPrice;

  1481.         try {
  1482.             for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1483.                 meCSQCUp : _mapCSQCFundingUp.entrySet()) {
  1484.                 java.lang.String strKey = meCSQCUp.getKey();

  1485.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorUp = meCSQCUp.getValue();

  1486.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorDown = _mapCSQCFundingDown.get
  1487.                     (strKey);

  1488.                 double dblTenorFundingUpPrice = _bond.isFloater() ? _bond.priceFromFundingCurve (_valParams,
  1489.                     csqcTenorUp, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread (_valParams,
  1490.                         csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor, dblZSpreadToExercise);

  1491.                 double dblTenorFundingUpParPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1492.                     (_valParams, csqcTenorUp, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1493.                         (_valParams, csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor,
  1494.                             dblParZSpreadToExercise);

  1495.                 double dblTenorFundingDownPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1496.                     (_valParams, csqcTenorDown, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1497.                         (_valParams, csqcTenorDown, null, iWorkoutDate, dblWorkoutFactor,
  1498.                             dblZSpreadToExercise);

  1499.                 double dblTenorFundingDownParPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1500.                     (_valParams, csqcTenorDown, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1501.                         (_valParams, csqcTenorDown, null, iWorkoutDate, dblWorkoutFactor,
  1502.                             dblParZSpreadToExercise);

  1503.                 double dblBaseFloaterPrice = 0.5 * (dblTenorFundingDownPrice + dblTenorFundingUpPrice);

  1504.                 mapFundingKRD.put (strKey, 0.5 * (dblTenorFundingDownPrice - dblTenorFundingUpPrice) /
  1505.                     (_bond.isFloater() ? dblBaseFloaterPrice : _dblCurrentPrice) / _dblTenorBump);

  1506.                 mapFundingKPRD.put (strKey, 0.5 * (dblTenorFundingDownParPrice - dblTenorFundingUpParPrice) /
  1507.                     (_bond.isFloater() ? dblBaseFloaterPrice : _dblIssuePrice) / _dblTenorBump);
  1508.             }

  1509.             for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1510.                 meCSQCUp : _mapCSQCForwardFundingUp.entrySet()) {
  1511.                 java.lang.String strKey = meCSQCUp.getKey();

  1512.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorUp = meCSQCUp.getValue();

  1513.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorDown =
  1514.                     _mapCSQCForwardFundingDown.get (strKey);

  1515.                 double dblTenorForwardUpPrice = _bond.isFloater() ? _bond.priceFromFundingCurve (_valParams,
  1516.                     csqcTenorUp, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread (_valParams,
  1517.                         csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor, dblZSpreadToExercise);

  1518.                 double dblTenorForwardUpParPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1519.                     (_valParams, csqcTenorUp, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1520.                         (_valParams, csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor,
  1521.                             dblParZSpreadToExercise);

  1522.                 double dblTenorForwardDownPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1523.                     (_valParams, csqcTenorDown, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1524.                         (_valParams, csqcTenorDown, null, iWorkoutDate, dblWorkoutFactor,
  1525.                             dblZSpreadToExercise);

  1526.                 double dblTenorForwardDownParPrice = _bond.isFloater() ? _bond.priceFromFundingCurve
  1527.                     (_valParams, csqcTenorDown, iWorkoutDate, dblWorkoutFactor, 0.) : _bond.priceFromZSpread
  1528.                         (_valParams, csqcTenorDown, null, iWorkoutDate, dblWorkoutFactor,
  1529.                             dblParZSpreadToExercise);

  1530.                 double dblBaseFloaterPrice = 0.5 * (dblTenorForwardDownPrice + dblTenorForwardUpPrice);

  1531.                 mapLIBORKRD.put (strKey, 0.5 * (dblTenorForwardDownPrice - dblTenorForwardUpPrice) /
  1532.                     (_bond.isFloater() ? dblBaseFloaterPrice : _dblCurrentPrice) / _dblTenorBump);

  1533.                 mapLIBORKPRD.put (strKey, 0.5 * (dblTenorForwardDownParPrice - dblTenorForwardUpParPrice) /
  1534.                     (_bond.isFloater() ? dblBaseFloaterPrice : _dblIssuePrice) / _dblTenorBump);
  1535.             }

  1536.             for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1537.                 meCSQCUp : _mapCSQCGovvieUp.entrySet()) {
  1538.                 java.lang.String strKey = meCSQCUp.getKey();

  1539.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorUp = meCSQCUp.getValue();

  1540.                 org.drip.param.market.CurveSurfaceQuoteContainer csqcTenorDown = _mapCSQCGovvieDown.get
  1541.                     (strKey);

  1542.                 mapGovvieKRD.put (strKey, 0.5 * (_bond.priceFromOAS (_valParams, csqcTenorDown, null,
  1543.                     iWorkoutDate, dblWorkoutFactor, dblOASToExercise) - _bond.priceFromOAS (_valParams,
  1544.                         csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor, dblOASToExercise)) /
  1545.                             _dblCurrentPrice / _dblTenorBump);

  1546.                 mapGovvieKPRD.put (strKey, 0.5 * (_bond.priceFromOAS (_valParams, csqcTenorDown, null,
  1547.                     iWorkoutDate, dblWorkoutFactor, dblParOASToExercise) - _bond.priceFromOAS (_valParams,
  1548.                         csqcTenorUp, null, iWorkoutDate, dblWorkoutFactor, dblParOASToExercise)) /
  1549.                             _dblIssuePrice / _dblTenorBump);
  1550.             }

  1551.             if (null != _mapCSQCCredit) {
  1552.                 mapCreditKRD = new org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1553.                 mapCreditKPRD = new org.drip.analytics.support.CaseInsensitiveHashMap<java.lang.Double>();

  1554.                 for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CurveSurfaceQuoteContainer>
  1555.                     meCSQC : _mapCSQCCredit.entrySet()) {
  1556.                     java.lang.String strKey = meCSQC.getKey();

  1557.                     org.drip.param.market.CurveSurfaceQuoteContainer csqcTenor = meCSQC.getValue();

  1558.                     mapCreditKRD.put (strKey, (_dblCurrentPrice - _bond.priceFromCreditBasis (_valParams,
  1559.                         csqcTenor, null, iWorkoutDate, dblWorkoutFactor, dblCreditBasisToExercise)) /
  1560.                             _dblCurrentPrice);

  1561.                     mapCreditKPRD.put (strKey, (_dblIssuePrice - _bond.priceFromCreditBasis (_valParams,
  1562.                         csqcTenor, null, iWorkoutDate, dblWorkoutFactor, dblParCreditBasisToExercise)) /
  1563.                             _dblIssuePrice);
  1564.                 }
  1565.             }

  1566.             org.drip.analytics.output.BondEOSMetrics bem = null == _emr ? null : _emr.generateRun();

  1567.             if (null != bem)
  1568.             {
  1569.                 if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MCOAS", bem.oas())))
  1570.                     return null;

  1571.                 if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MCDuration",
  1572.                     bem.oasDuration())))
  1573.                     return null;

  1574.                 if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MCConvexity",
  1575.                     bem.oasConvexity())))
  1576.                     return null;
  1577.             }

  1578.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Price", _dblCurrentPrice)))
  1579.                 return null;

  1580.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Market Value",
  1581.                 _dblCurrentPrice * _dblIssueAmount)))
  1582.                 return null;

  1583.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Accrued", dblAccrued)))
  1584.                 return null;

  1585.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Accrued$", dblAccrued *
  1586.                 _dblIssueAmount)))
  1587.                 return null;

  1588.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Accrued Interest Factor",
  1589.                 dblAccrued * _dblFX)))
  1590.                 return null;

  1591.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Yield To Maturity",
  1592.                 dblYieldToMaturity)))
  1593.                 return null;

  1594.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Yield To Maturity CBE",
  1595.                 dblBEYToMaturity)))
  1596.                 return null;

  1597.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("YTM fwdCpn",
  1598.                 dblYieldToMaturityFwdCoupon)))
  1599.                 return null;

  1600.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Yield To Worst",
  1601.                 dblYieldToExercise)))
  1602.                 return null;

  1603.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("YIELD TO CALL",
  1604.                 dblYieldFromPriceNextCall)))
  1605.                 return null;

  1606.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("YIELD TO PUT",
  1607.                 dblYieldFromPriceNextPut)))
  1608.                 return null;

  1609.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Nominal Yield",
  1610.                 dblNominalYield)))
  1611.                 return null;

  1612.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Z_Spread", dblOASToExercise)))
  1613.                 return null;

  1614.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Z_Vol_OAS",
  1615.                 dblZSpreadToExercise)))
  1616.                 return null;

  1617.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("OAS", dblZSpreadToMaturity)))
  1618.                 return null;

  1619.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("TSY OAS", dblOASToMaturity)))
  1620.                 return null;

  1621.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MOD DUR",
  1622.                 dblModifiedDurationToMaturity)))
  1623.                 return null;

  1624.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MACAULAY DURATION",
  1625.                 dblMacaulayDurationToMaturity)))
  1626.                 return null;

  1627.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("MOD DUR TO WORST",
  1628.                 dblModifiedDurationToExercise)))
  1629.                 return null;

  1630.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Funding DURATION",
  1631.                 mapFundingKRD.get ("bump"))))
  1632.                 return null;

  1633.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("LIBOR DURATION",
  1634.                 mapLIBORKRD.get ("bump"))))
  1635.                 return null;

  1636.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("TREASURY DURATION",
  1637.                 mapGovvieKRD.get ("bump"))))
  1638.                 return null;

  1639.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("EFFECTIVE DURATION",
  1640.                 dblEffectiveDuration)))
  1641.                 return null;

  1642.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("EFFECTIVE DURATION ADJ",
  1643.                 dblEffectiveDurationAdjusted)))
  1644.                 return null;

  1645.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("OAD MULT",
  1646.                 dblEffectiveDurationAdjusted / dblEffectiveDuration)))
  1647.                 return null;

  1648.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Spread Dur",
  1649.                 dblSpreadDuration)))
  1650.                 return null;

  1651.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Spread Dur $",
  1652.                 dblSpreadDuration * _dblIssueAmount)))
  1653.                 return null;

  1654.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("DV01", dblYield01)))
  1655.                 return null;

  1656.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("CV01", dblCV01))) return null;

  1657.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Convexity",
  1658.                 dblConvexityToExercise)))
  1659.                 return null;

  1660.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("Modified Convexity",
  1661.                 dblConvexityToExercise)))
  1662.                 return null;

  1663.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("DISCOUNT MARGIN",
  1664.                 dblDiscountMarginToExercise)))
  1665.                 return null;

  1666.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("E-Spread",
  1667.                 dblESpreadToExercise)))
  1668.                 return null;

  1669.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("I-Spread",
  1670.                 dblISpreadToExercise)))
  1671.                 return null;

  1672.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("J-Spread",
  1673.                 dblJSpreadToExercise)))
  1674.                 return null;

  1675.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("N-Spread",
  1676.                 dblNSpreadToExercise)))
  1677.                 return null;

  1678.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL To Worst",
  1679.                 dblWALPrincipalOnlyToExercise)))
  1680.                 return null;

  1681.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL",
  1682.                 dblWALPrincipalOnlyToMaturity)))
  1683.                 return null;

  1684.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL2",
  1685.                 dblWALLossOnlyToExercise)))
  1686.                 return null;

  1687.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL3",
  1688.                 !org.drip.numerical.common.NumberUtil.IsValid (dblWALCouponOnlyToExercise) ? 0. :
  1689.                     dblWALCouponOnlyToExercise)))
  1690.                 return null;

  1691.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL4",
  1692.                 dblWALPrincipalOnlyToMaturity)))
  1693.                 return null;

  1694.             if (!arr.addNamedField (new org.drip.service.scenario.NamedField ("WAL_Adj",
  1695.                 dblWALCreditToExercise)))
  1696.                 return null;

  1697.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Funding KRD",
  1698.                 mapFundingKRD)))
  1699.                 return null;

  1700.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Funding KPRD",
  1701.                 mapFundingKPRD)))
  1702.                 return null;

  1703.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("LIBOR KRD",
  1704.                 mapLIBORKRD)))
  1705.                 return null;

  1706.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("LIBOR KPRD",
  1707.                 mapLIBORKPRD)))
  1708.                 return null;

  1709.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Govvie KRD",
  1710.                 mapGovvieKRD)))
  1711.                 return null;

  1712.             if (!arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Govvie KPRD",
  1713.                 mapGovvieKPRD)))
  1714.                 return null;
  1715.         } catch (java.lang.Exception e) {
  1716.             e.printStackTrace();

  1717.             return null;
  1718.         }

  1719.         try {
  1720.             if (null != mapCreditKRD)
  1721.                 arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Credit KRD",
  1722.                     mapCreditKRD));

  1723.             if (null != mapCreditKPRD)
  1724.                 arr.addNamedFieldMap (new org.drip.service.scenario.NamedFieldMap ("Credit KPRD",
  1725.                     mapCreditKPRD));
  1726.         } catch (java.lang.Exception e) {
  1727.             e.printStackTrace();
  1728.         }

  1729.         System.out.println ("Workout        : " + new org.drip.analytics.date.JulianDate (iWorkoutDate));

  1730.         System.out.println ("Next Call Date : " + new org.drip.analytics.date.JulianDate (iNextCallDate) +
  1731.             " | " + dblNextCallFactor);

  1732.         System.out.println ("Maturity Date  : " + new org.drip.analytics.date.JulianDate (iMaturityDate) +
  1733.             " | 1.0");

  1734.         return arr;
  1735.     }
  1736. }