CurveSurfaceScenarioContainer.java

  1. package org.drip.param.market;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

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

  82. /**
  83.  * <i>CurveSurfaceScenarioContainer</i> extends MarketParams abstract class, and is the place holder for the
  84.  * comprehensive suite of the market set of curves for the given date. It exports the following
  85.  * functionality:
  86.  *
  87.  * <br><br>
  88.  *  <ul>
  89.  *      <li>
  90.  *          Add/remove/retrieve scenario discount curve
  91.  *      </li>
  92.  *      <li>
  93.  *          Add/remove/retrieve scenario Forward curve
  94.  *      </li>
  95.  *      <li>
  96.  *          Add/remove/retrieve scenario zero curve
  97.  *      </li>
  98.  *      <li>
  99.  *          Add/remove/retrieve scenario credit curve
  100.  *      </li>
  101.  *      <li>
  102.  *          Add/remove/retrieve scenario recovery curve
  103.  *      </li>
  104.  *      <li>
  105.  *          Add/remove/retrieve scenario FXForward curve
  106.  *      </li>
  107.  *      <li>
  108.  *          Add/remove/retrieve scenario FXBasis curve
  109.  *      </li>
  110.  *      <li>
  111.  *          Add/remove/retrieve scenario fixings
  112.  *      </li>
  113.  *      <li>
  114.  *          Add/remove/retrieve Treasury/component quotes
  115.  *      </li>
  116.  *      <li>
  117.  *          Retrieve scenario Market Parameters
  118.  *      </li>
  119.  *      <li>
  120.  *          Retrieve map of flat rates/credit/recovery Market Parameters
  121.  *      </li>
  122.  *      <li>
  123.  *          Retrieve double map of tenor rates/credit/recovery Market Parameters
  124.  *      </li>
  125.  *      <li>
  126.  *          Retrieve rates/credit scenario generator
  127.  *      </li>
  128.  *  </ul>
  129.  *
  130.  *  <br><br>
  131.  *  <ul>
  132.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  133.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  134.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/README.md">Product Cash Flow, Valuation, Market, Pricing, and Quoting Parameters</a></li>
  135.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/market/README.md">Curves Surfaces Quotes Fixings Container</a></li>
  136.  *  </ul>
  137.  *
  138.  * @author Lakshmi Krishnamurthy
  139.  */

  140. public class CurveSurfaceScenarioContainer extends org.drip.param.definition.ScenarioMarketParams {
  141.     private static final int BASE = 0;
  142.     private static final int BUMP_UP = 1;
  143.     private static final int BUMP_DN = 2;
  144.     private static final int RR_BUMP_UP = 4;
  145.     private static final int RR_BUMP_DN = 8;

  146.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  147.         _mapTSYQuote = null;

  148.     private org.drip.param.market.LatentStateFixingsContainer _lsfc = new
  149.         org.drip.param.market.LatentStateFixingsContainer();

  150.     private
  151.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.DiscountCurveScenarioContainer>
  152.         _mapScenarioDiscountCurve = new
  153.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.DiscountCurveScenarioContainer>();

  154.     private
  155.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CreditCurveScenarioContainer>
  156.         _mapScenarioCreditCurve = new
  157.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CreditCurveScenarioContainer>();

  158.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  159.         _mapQuote = new
  160.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>();

  161.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  162.         _mapScenarioMarketParams = new
  163.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  164.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve> dcSet (
  165.         final int iBumpType)
  166.     {
  167.         if (null == _mapScenarioDiscountCurve.entrySet()) return null;

  168.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve> mapDC =
  169.             new org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>();

  170.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.DiscountCurveScenarioContainer>
  171.             meSDC : _mapScenarioDiscountCurve.entrySet()) {
  172.             java.lang.String strKey = meSDC.getKey();

  173.             org.drip.param.market.DiscountCurveScenarioContainer sdc = meSDC.getValue();

  174.             if (null == strKey || strKey.isEmpty() || null == sdc) continue;

  175.             if (BASE == iBumpType)
  176.                 mapDC.put (strKey, sdc.base());
  177.             else if (BUMP_UP == iBumpType)
  178.                 mapDC.put (strKey, sdc.bumpUp());
  179.             else if (BUMP_DN == iBumpType)
  180.                 mapDC.put (strKey, sdc.bumpDown());
  181.             }

  182.         return mapDC;
  183.     }

  184.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  185.         ccSet (
  186.             final int iBumpType)
  187.     {
  188.         if (null == _mapScenarioCreditCurve.entrySet()) return null;

  189.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve> mapCC =
  190.             new org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>();

  191.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CreditCurveScenarioContainer> meSCC
  192.             : _mapScenarioCreditCurve.entrySet()) {
  193.             java.lang.String strKey = meSCC.getKey();

  194.             org.drip.param.market.CreditCurveScenarioContainer scc = meSCC.getValue();

  195.             if (null == strKey || strKey.isEmpty() || null == scc) continue;

  196.             if (BASE == iBumpType)
  197.                 mapCC.put (strKey, scc.base());
  198.             else if (BUMP_UP == iBumpType)
  199.                 mapCC.put (strKey, scc.bumpUp());
  200.             else if (BUMP_DN == iBumpType)
  201.                 mapCC.put (strKey, scc.bumpDown());
  202.             }

  203.         return mapCC;
  204.     }

  205.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>
  206.         specificIRFlatBumpDCSet (
  207.             final java.lang.String strIRCurve,
  208.             final boolean bBumpUp)
  209.     {
  210.         if (null == strIRCurve || strIRCurve.isEmpty() || null == _mapScenarioDiscountCurve.get (strIRCurve))
  211.             return null;

  212.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve> mapDC =
  213.             dcSet (BASE);

  214.         if (null == mapDC) return null;

  215.         org.drip.param.market.DiscountCurveScenarioContainer dcsc = _mapScenarioDiscountCurve.get (strIRCurve);

  216.         if (null == dcsc) return null;

  217.         mapDC.put (strIRCurve, bBumpUp ? dcsc.bumpUp() : dcsc.bumpDown());

  218.         return mapDC;
  219.     }

  220.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  221.         specificCreditFlatBumpCCSet (
  222.             final java.lang.String strCreditCurve,
  223.             final boolean bBumpUp)
  224.     {
  225.         if (null == strCreditCurve || strCreditCurve.isEmpty() || null == _mapScenarioCreditCurve.get
  226.             (strCreditCurve))
  227.             return null;

  228.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve> mapCC =
  229.             ccSet (BASE);

  230.         if (null == mapCC) return null;

  231.         org.drip.param.market.CreditCurveScenarioContainer scc = _mapScenarioCreditCurve.get
  232.             (strCreditCurve);

  233.         if (null == scc) return null;

  234.         mapCC.put (strCreditCurve, bBumpUp ? scc.bumpUp() : scc.bumpDown());

  235.         return mapCC;
  236.     }

  237.     private org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  238.         specificCreditFlatBumpRRSet (
  239.             final java.lang.String strCreditCurve,
  240.             final boolean bBumpUp)
  241.     {
  242.         if (null == strCreditCurve || strCreditCurve.isEmpty() || null == _mapScenarioCreditCurve.get
  243.             (strCreditCurve))
  244.             return null;

  245.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve> mapCC =
  246.             ccSet (BASE);

  247.         org.drip.param.market.CreditCurveScenarioContainer scc = _mapScenarioCreditCurve.get
  248.             (strCreditCurve);

  249.         if (null == scc) return null;

  250.         mapCC.put (strCreditCurve, bBumpUp ? scc.bumpRecoveryUp() : scc.bumpRecoveryDown());

  251.         return mapCC;
  252.     }

  253.     private org.drip.param.market.CurveSurfaceQuoteContainer customMarketParams (
  254.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>
  255.             mapDC,
  256.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.forward.ForwardCurve> mapFC,
  257.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  258.             mapCC)
  259.     {
  260.         org.drip.param.market.CurveSurfaceQuoteContainer csqs = new org.drip.param.market.CurveSurfaceQuoteContainer();

  261.         if (null != mapDC && 0 != mapDC.size()) {
  262.             for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve>
  263.                 meDC : mapDC.entrySet()) {
  264.                 if (null == meDC) continue;

  265.                 org.drip.state.discount.MergedDiscountForwardCurve dcFunding = meDC.getValue();

  266.                 if (null != dcFunding && !csqs.setFundingState (dcFunding)) return null;
  267.             }
  268.         }

  269.         if (null != mapFC && 0 != mapFC.size()) {
  270.             for (java.util.Map.Entry<java.lang.String, org.drip.state.forward.ForwardCurve>
  271.                 meFC : mapFC.entrySet()) {
  272.                 if (null == meFC) continue;

  273.                 org.drip.state.forward.ForwardCurve fc = meFC.getValue();

  274.                 if (null != fc && !csqs.setForwardState (fc)) return null;
  275.             }
  276.         }

  277.         if (null != mapCC && 0 != mapCC.size()) {
  278.             for (java.util.Map.Entry<java.lang.String, org.drip.state.credit.CreditCurve>
  279.                 meCC : mapCC.entrySet()) {
  280.                 if (null == meCC) continue;

  281.                 org.drip.state.credit.CreditCurve cc = meCC.getValue();

  282.                 if (null != cc && !csqs.setCreditState (cc)) return null;
  283.             }
  284.         }

  285.         return csqs.setFixings (_lsfc) ? csqs : null;
  286.     }

  287.     /**
  288.      * Construct an empty MarketParamsContainer instance
  289.      */

  290.     public CurveSurfaceScenarioContainer()
  291.     {
  292.     }

  293.     @Override public boolean addScenarioDiscountCurve (
  294.         final java.lang.String strName,
  295.         final org.drip.param.market.DiscountCurveScenarioContainer sdc)
  296.     {
  297.         if (null != strName && !strName.isEmpty() && null != sdc) {
  298.             _mapScenarioDiscountCurve.put (strName, sdc);

  299.             return true;
  300.         }

  301.         return false;
  302.     }

  303.     @Override public boolean removeScenarioDiscountCurve (
  304.         final java.lang.String strName)
  305.     {
  306.         if (null != strName && !strName.isEmpty()) {
  307.             _mapScenarioDiscountCurve.remove (strName);

  308.             return true;
  309.         }

  310.         return false;
  311.     }

  312.     @Override public boolean addScenarioCreditCurve (
  313.         final java.lang.String strName,
  314.         final org.drip.param.market.CreditCurveScenarioContainer scc)
  315.     {
  316.         if (null != strName && !strName.isEmpty() && null != scc) {
  317.             _mapScenarioCreditCurve.put (strName, scc);

  318.             return true;
  319.         }

  320.         return false;
  321.     }

  322.     @Override public boolean removeScenarioCreditCurve (
  323.         final java.lang.String strName)
  324.     {
  325.         if (null != strName && !strName.isEmpty()) {
  326.             _mapScenarioCreditCurve.remove (strName);

  327.             return true;
  328.         }

  329.         return false;
  330.     }

  331.     @Override public boolean addTSYQuote (
  332.         final java.lang.String strBenchmark,
  333.         final org.drip.param.definition.ProductQuote pqTSY)
  334.     {
  335.         if (null == strBenchmark || strBenchmark.isEmpty() || null == pqTSY) return false;

  336.         if (null == _mapTSYQuote)
  337.             _mapTSYQuote = new
  338.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>();

  339.         _mapTSYQuote.put (strBenchmark, pqTSY);

  340.         return true;
  341.     }

  342.     @Override public boolean removeTSYQuote (
  343.         final java.lang.String strBenchmark)
  344.     {
  345.         if (null == strBenchmark || strBenchmark.isEmpty()) return false;

  346.         if (null == _mapTSYQuote) return true;

  347.         _mapTSYQuote.remove (strBenchmark);

  348.         return true;
  349.     }

  350.     @Override public boolean setTSYQuotes (
  351.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote> mapCQTSY)
  352.     {
  353.         _mapTSYQuote = mapCQTSY;
  354.         return true;
  355.     }

  356.     @Override public org.drip.param.definition.ProductQuote tsyQuote (
  357.         final java.lang.String strBenchmark)
  358.     {
  359.         if (null == _mapTSYQuote || null == strBenchmark || strBenchmark.isEmpty()) return null;

  360.         return _mapTSYQuote.get (strBenchmark);
  361.     }

  362.     @Override public
  363.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  364.             tsyQuotes()
  365.     {
  366.         return _mapTSYQuote;
  367.     }

  368.     @Override public boolean addFixing (
  369.         final org.drip.analytics.date.JulianDate dtFix,
  370.         final org.drip.state.identifier.LatentStateLabel lsl,
  371.         final double dblFixing)
  372.     {
  373.         return _lsfc.add (dtFix, lsl, dblFixing);
  374.     }

  375.     @Override public boolean removeFixing (
  376.         final org.drip.analytics.date.JulianDate dtFix,
  377.         final org.drip.state.identifier.LatentStateLabel lsl)
  378.     {
  379.         return _lsfc.remove (dtFix, lsl);
  380.     }

  381.     @Override public org.drip.param.market.LatentStateFixingsContainer fixings()
  382.     {
  383.         return _lsfc;
  384.     }

  385.     @Override public boolean addComponentQuote (
  386.         final java.lang.String strComponentID,
  387.         final org.drip.param.definition.ProductQuote cqComponent)
  388.     {
  389.         if (null == strComponentID || strComponentID.isEmpty() || null == cqComponent) return false;

  390.         if (null == _mapQuote)
  391.             _mapQuote = new
  392.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>();

  393.         _mapQuote.put (strComponentID, cqComponent);

  394.         return true;
  395.     }

  396.     @Override public boolean removeComponentQuote (
  397.         final java.lang.String strComponentID)
  398.     {
  399.         if (null == strComponentID || strComponentID.isEmpty()) return false;

  400.         if (null == _mapQuote) return true;

  401.         _mapQuote.remove (strComponentID);

  402.         return true;
  403.     }

  404.     @Override public boolean addComponentQuote (
  405.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  406.             mapComponentQuote)
  407.     {
  408.         _mapQuote = mapComponentQuote;
  409.         return true;
  410.     }

  411.     @Override public org.drip.param.definition.ProductQuote componentQuote (
  412.         final java.lang.String strComponentID)
  413.     {
  414.         if (null == _mapQuote || null == strComponentID || strComponentID.isEmpty()) return null;

  415.         return _mapQuote.get (strComponentID);
  416.     }

  417.     @Override public
  418.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  419.             componentQuotes()
  420.     {
  421.         return _mapQuote;
  422.     }

  423.     @Override public boolean addScenarioMarketParams (
  424.         final java.lang.String strScenarioName,
  425.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs)
  426.     {
  427.         if (null == strScenarioName || strScenarioName.isEmpty() || null == csqs) return false;

  428.         _mapScenarioMarketParams.put (strScenarioName, csqs);

  429.         return true;
  430.     }

  431.     @Override public org.drip.param.market.CurveSurfaceQuoteContainer scenarioMarketParams (
  432.         final java.lang.String strScenarioName)
  433.     {
  434.         return null == strScenarioName || strScenarioName.isEmpty() ? null : _mapScenarioMarketParams.get
  435.             (strScenarioName);
  436.     }

  437.     @Override public org.drip.param.market.CurveSurfaceQuoteContainer scenarioMarketParams (
  438.         final org.drip.product.definition.Component comp,
  439.         final java.lang.String strScenario)
  440.     {
  441.         if (null == comp || null == strScenario || strScenario.isEmpty()) return null;

  442.         org.drip.state.forward.ForwardCurve fc = null;
  443.         org.drip.state.discount.MergedDiscountForwardCurve dc = null;
  444.         org.drip.state.credit.CreditCurve cc = null;

  445.         java.lang.String strPayCurrency = comp.payCurrency();

  446.         org.drip.param.market.DiscountCurveScenarioContainer sdc = _mapScenarioDiscountCurve.get
  447.             (strPayCurrency);

  448.         if (null != sdc) {
  449.             dc = sdc.base();

  450.             if ("FlatIRBumpUp".equalsIgnoreCase (strScenario))
  451.                 dc = sdc.bumpUp();
  452.             else if ("FlatIRBumpDn".equalsIgnoreCase (strScenario))
  453.                 dc = sdc.bumpDown();
  454.         }

  455.         org.drip.state.identifier.EntityCDSLabel creditLabel = comp.creditLabel();

  456.         org.drip.param.market.CreditCurveScenarioContainer scc = null == creditLabel ? null :
  457.             _mapScenarioCreditCurve.get (creditLabel.fullyQualifiedName());

  458.         if (null != scc) {
  459.             if ("FlatCreditBumpUp".equalsIgnoreCase (strScenario))
  460.                 cc = scc.bumpUp();
  461.             else if ("FlatCreditBumpDn".equalsIgnoreCase (strScenario))
  462.                 cc = scc.bumpDown();
  463.             else
  464.                 cc = scc.base();
  465.         }

  466.         return org.drip.param.creator.MarketParamsBuilder.Create (dc, fc, null, cc, comp.name(),
  467.             _mapQuote.get (comp.name()), _mapTSYQuote, _lsfc);
  468.     }

  469.     @Override public
  470.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  471.             fundingTenorMarketParams (
  472.                 final org.drip.product.definition.Component comp,
  473.                 final boolean bBumpUp)
  474.     {
  475.         if (null == comp) return null;

  476.         java.lang.String strPayCurrency = comp.payCurrency();

  477.         org.drip.param.market.DiscountCurveScenarioContainer sdc = _mapScenarioDiscountCurve.get
  478.             (strPayCurrency);

  479.         if (null == sdc) return null;

  480.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve> mapDCBumpUp
  481.             = sdc.tenorBumpUp();

  482.         if (bBumpUp && (null == mapDCBumpUp || 0 == mapDCBumpUp.size())) return null;

  483.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>
  484.             mapDCBumpDown = sdc.tenorBumpDown();

  485.         if (!bBumpUp && (null == mapDCBumpDown || 0 == mapDCBumpDown.size())) return null;

  486.         org.drip.state.identifier.EntityCDSLabel creditLabel = comp.creditLabel();

  487.         org.drip.param.market.CreditCurveScenarioContainer scc = null == creditLabel ? null :
  488.             _mapScenarioCreditCurve.get (creditLabel.fullyQualifiedName());

  489.         org.drip.state.credit.CreditCurve cc = null == scc ? null : scc.base();

  490.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer> mapCSQS
  491.             = new
  492.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  493.         java.lang.String strComponentName = comp.name();

  494.         if (bBumpUp) {
  495.             for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve> meDC :
  496.                 mapDCBumpUp.entrySet()) {
  497.                 if (null == meDC) continue;

  498.                 java.lang.String strKey = meDC.getKey();

  499.                 org.drip.state.discount.MergedDiscountForwardCurve dc = meDC.getValue();

  500.                 if (null == dc || null == strKey || strKey.isEmpty()) continue;

  501.                 mapCSQS.put (strKey, org.drip.param.creator.MarketParamsBuilder.Create (dc, null, null, cc,
  502.                     strComponentName, _mapQuote.get (strComponentName), _mapTSYQuote, _lsfc));
  503.             }
  504.         } else {
  505.             for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve> meDC :
  506.                 mapDCBumpDown.entrySet()) {
  507.                 if (null == meDC) continue;

  508.                 java.lang.String strKey = meDC.getKey();

  509.                 org.drip.state.discount.MergedDiscountForwardCurve dc = meDC.getValue();

  510.                 if (null == dc || null == strKey || strKey.isEmpty()) continue;

  511.                 mapCSQS.put (strKey, org.drip.param.creator.MarketParamsBuilder.Create (dc, null, null, cc,
  512.                     strComponentName, _mapQuote.get (strComponentName), _mapTSYQuote, _lsfc));
  513.             }
  514.         }

  515.         return mapCSQS;
  516.     }

  517.     @Override public
  518.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  519.             creditTenorMarketParams (
  520.                 final org.drip.product.definition.Component comp,
  521.                 final boolean bBumpUp)
  522.     {
  523.         if (null == comp) return null;

  524.         org.drip.state.identifier.EntityCDSLabel creditLabel = comp.creditLabel();

  525.         if (null == creditLabel) return null;

  526.         org.drip.param.market.CreditCurveScenarioContainer scc = _mapScenarioCreditCurve.get
  527.             (creditLabel.fullyQualifiedName());

  528.         if (null == scc) return null;

  529.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  530.             mapCCBumpUp = scc.tenorBumpUp();

  531.         if (bBumpUp && (null == mapCCBumpUp || 0 == mapCCBumpUp.size())) return null;

  532.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  533.             mapCCBumpDown = scc.tenorBumpDown();

  534.         if (!bBumpUp && (null == mapCCBumpDown || 0 == mapCCBumpDown.size())) return null;

  535.         java.lang.String strPayCurrency = comp.payCurrency();

  536.         org.drip.param.market.DiscountCurveScenarioContainer sdc = _mapScenarioDiscountCurve.get
  537.             (strPayCurrency);

  538.         if (null == sdc) return null;

  539.         org.drip.state.discount.MergedDiscountForwardCurve dc = sdc.base();

  540.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  541.             mapCSQS = new
  542.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  543.         java.lang.String strComponentName = comp.name();

  544.         if (bBumpUp) {
  545.             for (java.util.Map.Entry<java.lang.String, org.drip.state.credit.CreditCurve> meCC :
  546.                 mapCCBumpUp.entrySet()) {
  547.                 if (null == meCC) continue;

  548.                 java.lang.String strKey = meCC.getKey();

  549.                 org.drip.state.credit.CreditCurve cc = meCC.getValue();

  550.                 if (null == strKey || strKey.isEmpty()) continue;

  551.                 mapCSQS.put (strKey, org.drip.param.creator.MarketParamsBuilder.Create (dc, null, null, cc,
  552.                     strComponentName, _mapQuote.get (strComponentName), _mapTSYQuote, _lsfc));
  553.             }
  554.         } else {
  555.             for (java.util.Map.Entry<java.lang.String, org.drip.state.credit.CreditCurve> meCC :
  556.                 mapCCBumpDown.entrySet()) {
  557.                 if (null == meCC) continue;

  558.                 java.lang.String strKey = meCC.getKey();

  559.                 org.drip.state.credit.CreditCurve cc = meCC.getValue();

  560.                 if (null == strKey || strKey.isEmpty()) continue;

  561.                 mapCSQS.put (strKey, org.drip.param.creator.MarketParamsBuilder.Create (dc, null, null, cc,
  562.                     strComponentName, _mapQuote.get (strComponentName), _mapTSYQuote, _lsfc));
  563.             }
  564.         }

  565.         return mapCSQS;
  566.     }

  567.     @Override public org.drip.param.market.CurveSurfaceQuoteContainer scenarioMarketParams (
  568.         final org.drip.product.definition.BasketProduct bp,
  569.         final java.lang.String strScenario)
  570.     {
  571.         if (null == strScenario || strScenario.isEmpty()) return null;

  572.         if ("Base".equalsIgnoreCase (strScenario))
  573.             return customMarketParams (dcSet (BASE), null, ccSet (BASE));

  574.         if ("FlatIRBumpUp".equalsIgnoreCase (strScenario))
  575.             return customMarketParams (dcSet (BUMP_UP), null, ccSet (BASE));

  576.         if ("FlatIRBumpDn".equalsIgnoreCase (strScenario))
  577.             return customMarketParams (dcSet (BUMP_DN), null, ccSet (BASE));

  578.         if ("FlatForwardBumpUp".equalsIgnoreCase (strScenario))
  579.             return customMarketParams (dcSet (BASE), null, ccSet (BASE));

  580.         if ("FlatForwardBumpDn".equalsIgnoreCase (strScenario))
  581.             return customMarketParams (dcSet (BASE), null, ccSet (BASE));

  582.         if ("FlatCreditBumpUp".equalsIgnoreCase (strScenario))
  583.             return customMarketParams (dcSet (BASE), null, ccSet (BUMP_UP));

  584.         if ("FlatCreditBumpDn".equalsIgnoreCase (strScenario))
  585.             return customMarketParams (dcSet (BASE), null, ccSet (BUMP_DN));

  586.         if ("FlatRRBumpUp".equalsIgnoreCase (strScenario))
  587.             return customMarketParams (dcSet (BASE), null, ccSet (RR_BUMP_UP));

  588.         if ("FlatRRBumpDn".equalsIgnoreCase (strScenario))
  589.             return customMarketParams (dcSet (BASE), null, ccSet (RR_BUMP_DN));

  590.         return null;
  591.     }

  592.     @Override public
  593.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  594.             fundingFlatBump (
  595.                 final org.drip.product.definition.BasketProduct bp,
  596.                 final boolean bBump)
  597.     {
  598.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  599.             mapCSQS = new
  600.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  601.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.DiscountCurveScenarioContainer>
  602.             meSDC : _mapScenarioDiscountCurve.entrySet()) {
  603.             if (null != meSDC) {
  604.                 java.lang.String strKey = meSDC.getKey();

  605.                 if (null != strKey && !strKey.isEmpty())
  606.                     mapCSQS.put (strKey, customMarketParams (specificIRFlatBumpDCSet (strKey, bBump), null,
  607.                         ccSet (BASE)));
  608.             }
  609.         }

  610.         return mapCSQS;
  611.     }

  612.     @Override public
  613.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  614.             creditFlatBump (
  615.                 final org.drip.product.definition.BasketProduct bp,
  616.                 final boolean bBump)
  617.     {
  618.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  619.             mapCSQS = new
  620.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  621.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CreditCurveScenarioContainer> meSCC
  622.             : _mapScenarioCreditCurve.entrySet()) {
  623.             if (null != meSCC) {
  624.                 java.lang.String strKey = meSCC.getKey();

  625.                 if (null != strKey && !strKey.isEmpty())
  626.                     mapCSQS.put (strKey, customMarketParams (dcSet (BASE), null, specificCreditFlatBumpCCSet
  627.                         (strKey, bBump)));
  628.             }
  629.         }

  630.         return mapCSQS;
  631.     }

  632.     @Override public
  633.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  634.             recoveryFlatBump (
  635.                 final org.drip.product.definition.BasketProduct bp,
  636.                 final boolean bBump)
  637.     {
  638.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  639.             mapCSQS = new
  640.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  641.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CreditCurveScenarioContainer> meSCC
  642.             : _mapScenarioCreditCurve.entrySet()) {
  643.             if (null != meSCC) {
  644.                 java.lang.String strKey = meSCC.getKey();

  645.                 if (null != strKey && !strKey.isEmpty())
  646.                     mapCSQS.put (strKey, customMarketParams (dcSet (BASE), null, specificCreditFlatBumpRRSet
  647.                         (strKey, bBump)));
  648.             }
  649.         }

  650.         return mapCSQS;
  651.     }

  652.     @Override public
  653.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>
  654.             fundingTenorBump (
  655.                 final org.drip.product.definition.BasketProduct bp,
  656.                 final boolean bBump)
  657.     {
  658.         if (null == bp) return null;

  659.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>
  660.             mmFundingTenorCSQS = new
  661.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>();

  662.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.DiscountCurveScenarioContainer>
  663.             meSDC : _mapScenarioDiscountCurve.entrySet()) {
  664.             if (null == meSDC) continue;

  665.             java.lang.String strOuterKey = meSDC.getKey();

  666.             org.drip.param.market.DiscountCurveScenarioContainer sdc = meSDC.getValue();

  667.             if (null == sdc || null == strOuterKey || strOuterKey.isEmpty()) continue;

  668.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>
  669.                 mapDCBumpUp = sdc.tenorBumpUp();

  670.             if (bBump && (null == mapDCBumpUp || 0 == mapDCBumpUp.size())) return null;

  671.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.discount.MergedDiscountForwardCurve>
  672.                 mapDCBumpDown = sdc.tenorBumpDown();

  673.             if (!bBump && (null == mapDCBumpDown || 0 == mapDCBumpDown.size())) return null;

  674.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  675.                 mapTenorCSQS = new
  676.                     org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  677.             for (java.util.Map.Entry<java.lang.String, org.drip.state.discount.MergedDiscountForwardCurve> meDC : (bBump
  678.                 ? mapDCBumpUp.entrySet() : mapDCBumpDown.entrySet())) {
  679.                 if (null == meDC) continue;

  680.                 java.lang.String strInnerKey = meDC.getKey();

  681.                 org.drip.state.discount.MergedDiscountForwardCurve dc = meDC.getValue();

  682.                 if (null == dc || null == strInnerKey || strInnerKey.isEmpty()) continue;

  683.                 org.drip.param.market.CurveSurfaceQuoteContainer csqs = scenarioMarketParams (bp, "Base");

  684.                 if (null == csqs || !csqs.setFundingState (dc)) continue;

  685.                 mapTenorCSQS.put (strInnerKey, csqs);
  686.             }

  687.             mmFundingTenorCSQS.put (strOuterKey, mapTenorCSQS);
  688.         }

  689.         return mmFundingTenorCSQS;
  690.     }

  691.     @Override public
  692.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>
  693.             creditTenorBump (
  694.                 final org.drip.product.definition.BasketProduct bp,
  695.                 final boolean bBump)
  696.     {
  697.         if (null == bp) return null;

  698.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>
  699.             mmCreditTenorCSQS = new
  700.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>>();

  701.         for (java.util.Map.Entry<java.lang.String, org.drip.param.market.CreditCurveScenarioContainer> meSCC
  702.             : _mapScenarioCreditCurve.entrySet()) {
  703.             if (null == meSCC) continue;

  704.             java.lang.String strOuterKey = meSCC.getKey();

  705.             org.drip.param.market.CreditCurveScenarioContainer scc = meSCC.getValue();

  706.             if (null == scc || null == strOuterKey || strOuterKey.isEmpty()) continue;

  707.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  708.                 mapCCBumpUp = scc.tenorBumpUp();

  709.             if (bBump && (null == mapCCBumpUp || 0 == mapCCBumpUp.size())) return null;

  710.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.credit.CreditCurve>
  711.                 mapCCBumpDown = scc.tenorBumpDown();

  712.             if (!bBump && (null == mapCCBumpDown || 0 == mapCCBumpDown.size())) return null;

  713.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>
  714.                 mapTenorCSQS = new
  715.                     org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CurveSurfaceQuoteContainer>();

  716.             for (java.util.Map.Entry<java.lang.String, org.drip.state.credit.CreditCurve> meCC :
  717.                 (bBump ? mapCCBumpUp.entrySet() : mapCCBumpDown.entrySet())) {
  718.                 if (null == meCC) continue;

  719.                 java.lang.String strInnerKey = meCC.getKey();

  720.                 org.drip.state.credit.CreditCurve cc = meCC.getValue();

  721.                 if (null == cc || null == strInnerKey || strInnerKey.isEmpty()) continue;

  722.                 org.drip.param.market.CurveSurfaceQuoteContainer csqs = scenarioMarketParams (bp, "Base");

  723.                 if (null == csqs || !csqs.setCreditState (cc)) continue;

  724.                 mapTenorCSQS.put (strInnerKey, csqs);
  725.             }

  726.             mmCreditTenorCSQS.put (strOuterKey, mapTenorCSQS);
  727.         }

  728.         return mmCreditTenorCSQS;
  729.     }

  730.     @Override public
  731.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.DiscountCurveScenarioContainer>
  732.             scenarioDiscountCurveMap()
  733.     {
  734.         return _mapScenarioDiscountCurve;
  735.     }

  736.     @Override public
  737.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.market.CreditCurveScenarioContainer>
  738.             scenarioCreditCurveMap()
  739.     {
  740.         return _mapScenarioCreditCurve;
  741.     }
  742. }