MarketParamsBuilder.java

  1. package org.drip.param.creator;

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

  81. /**
  82.  * <i>MarketParamsBuilder</i> implements the various ways of constructing, de-serializing, and building the
  83.  * Market Parameters.
  84.  *
  85.  *  <br><br>
  86.  *  <ul>
  87.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  88.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  89.  *      <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>
  90.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/creator">Market Curves Surfaces Quotes Builder</a></li>
  91.  *  </ul>
  92.  *
  93.  * @author Lakshmi Krishnamurthy
  94.  */

  95. public class MarketParamsBuilder {

  96.     /**
  97.      * Create a Market Parameters instance with the funding discount curve, the forward discount curve, the
  98.      *  govvie curve, the credit curve, the component quote, the map of treasury benchmark quotes, and the
  99.      *  Latent State Fixings Instance.
  100.      *
  101.      * @param dcFunding Funding Curve
  102.      * @param fc Forward Curve
  103.      * @param gc Govvie Curve
  104.      * @param cc Credit Curve
  105.      * @param strComponentCode Component Code
  106.      * @param compQuote Component quote
  107.      * @param mTSYQuotes Map of Treasury Benchmark Quotes
  108.      * @param lsfc The Latent State Fixings Instance
  109.      *
  110.      * @return Market Parameters Instance
  111.      */

  112.     public static final org.drip.param.market.CurveSurfaceQuoteContainer Create (
  113.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding,
  114.         final org.drip.state.forward.ForwardCurve fc,
  115.         final org.drip.state.govvie.GovvieCurve gc,
  116.         final org.drip.state.credit.CreditCurve cc,
  117.         final java.lang.String strComponentCode,
  118.         final org.drip.param.definition.ProductQuote compQuote,
  119.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  120.             mTSYQuotes,
  121.         final org.drip.param.market.LatentStateFixingsContainer lsfc)
  122.     {
  123.         org.drip.param.market.CurveSurfaceQuoteContainer csqs = new
  124.             org.drip.param.market.CurveSurfaceQuoteContainer();

  125.         if (null != cc && !csqs.setCreditState (cc)) return null;

  126.         if (null != gc && !csqs.setGovvieState (gc)) return null;

  127.         if (null != lsfc && !csqs.setFixings (lsfc)) return null;

  128.         if (null != dcFunding && !csqs.setFundingState (dcFunding)) return null;

  129.         if (null != mTSYQuotes && !csqs.setQuoteMap (mTSYQuotes)) return null;

  130.         if (null != compQuote && null != strComponentCode && !strComponentCode.isEmpty() &&
  131.             !csqs.setProductQuote (strComponentCode, compQuote))
  132.             return null;

  133.         if (null != fc && !csqs.setForwardState (fc)) return null;

  134.         return csqs;
  135.     }

  136.     /**
  137.      * Create a Market Parameters instance with the Funding Curve alone
  138.      *
  139.      * @param dcFunding Funding Curve
  140.      *
  141.      * @return Market Parameters instance
  142.      */

  143.     public static final org.drip.param.market.CurveSurfaceQuoteContainer Discount (
  144.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding)
  145.     {
  146.         return Create (dcFunding, null, null, null, "", null, null, null);
  147.     }

  148.     /**
  149.      * Create a Market Parameters instance with the Funding Curve and the forward Curve
  150.      *
  151.      * @param dcFunding Funding Curve
  152.      * @param fc Forward Curve
  153.      *
  154.      * @return Market Parameters instance
  155.      */

  156.     public static final org.drip.param.market.CurveSurfaceQuoteContainer DiscountForward (
  157.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding,
  158.         final org.drip.state.forward.ForwardCurve fc)
  159.     {
  160.         return Create (dcFunding, fc, null, null, "", null, null, null);
  161.     }

  162.     /**
  163.      * Create a Market Parameters instance with the rates discount curve and the treasury discount curve alone
  164.      *
  165.      * @param dcFunding Funding Curve
  166.      * @param gc Govvie Curve
  167.      *
  168.      * @return Market Parameters instance
  169.      */

  170.     public static final org.drip.param.market.CurveSurfaceQuoteContainer Govvie (
  171.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding,
  172.         final org.drip.state.govvie.GovvieCurve gc)
  173.     {
  174.         return Create (dcFunding, null, gc, null, "", null, null, null);
  175.     }

  176.     /**
  177.      * Create a Market Parameters Instance with the Funding Curve and the credit curve
  178.      *
  179.      * @param dcFunding Funding Curve
  180.      * @param cc Credit Curve
  181.      *
  182.      * @return The Market Parameters Instance
  183.      */

  184.     public static final org.drip.param.market.CurveSurfaceQuoteContainer Credit (
  185.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding,
  186.         final org.drip.state.credit.CreditCurve cc)
  187.     {
  188.         return Create (dcFunding, null, null, cc, "", null, null, null);
  189.     }

  190.     /**
  191.      * Create a Market Parameters Instance with the Funding Curve, the Govvie Curve, the Credit Curve, the
  192.      *  component quote, the map of treasury benchmark quotes, and the Latent State Fixings Container
  193.      *
  194.      * @param dcFunding Funding Curve
  195.      * @param gc Govvie Curve
  196.      * @param cc Credit Curve
  197.      * @param strComponentCode Component Code
  198.      * @param compQuote Component quote
  199.      * @param mTSYQuotes Map of Treasury Benchmark Quotes
  200.      * @param lsfc Latent State Fixings Container
  201.      *
  202.      * @return Market Parameters Instance
  203.      */

  204.     public static final org.drip.param.market.CurveSurfaceQuoteContainer Create (
  205.         final org.drip.state.discount.MergedDiscountForwardCurve dcFunding,
  206.         final org.drip.state.govvie.GovvieCurve gc,
  207.         final org.drip.state.credit.CreditCurve cc,
  208.         final java.lang.String strComponentCode,
  209.         final org.drip.param.definition.ProductQuote compQuote,
  210.         final org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.ProductQuote>
  211.             mTSYQuotes,
  212.         final org.drip.param.market.LatentStateFixingsContainer lsfc)
  213.     {
  214.         return Create (dcFunding, null, gc, cc, strComponentCode, compQuote, mTSYQuotes, lsfc);
  215.     }

  216.     /**
  217.      * Create MarketParams from the array of calibration instruments
  218.      *
  219.      * @return MarketParams object
  220.      */

  221.     public static final org.drip.param.definition.ScenarioMarketParams CreateMarketParams()
  222.     {
  223.         try {
  224.             return new org.drip.param.market.CurveSurfaceScenarioContainer();
  225.         } catch (java.lang.Exception e) {
  226.             e.printStackTrace();
  227.         }

  228.         return null;
  229.     }
  230. }