ProductMultiMeasure.java

  1. package org.drip.param.quote;

  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 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>ProductMultiMeasure</i> holds the different types of quotes for a given component. It contains a single
  83.  * market field/quote pair, but multiple alternate named quotes (to accommodate quotes on different measure
  84.  * for the component).
  85.  *
  86.  *  <br><br>
  87.  *  <ul>
  88.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  89.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  90.  *      <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>
  91.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/param/quote/README.md">Multi-sided Multi-Measure Ticks Quotes</a></li>
  92.  *  </ul>
  93.  *  
  94.  * @author Lakshmi Krishnamurthy
  95.  */

  96. public class ProductMultiMeasure extends org.drip.param.definition.ProductQuote {
  97.     private java.lang.String _strMarketQuoteField = "";
  98.     private org.drip.param.definition.Quote _mktQuote = null;

  99.     org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.Quote> _mapQuote = new
  100.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.param.definition.Quote>();

  101.     /**
  102.      * Construct an empty instance of ProductMultiMeasure
  103.      */

  104.     public ProductMultiMeasure()
  105.     {
  106.     }

  107.     @Override public void addQuote (
  108.         final java.lang.String strQuoteField,
  109.         final org.drip.param.definition.Quote q,
  110.         final boolean bIsMarketQuote)
  111.     {
  112.         _mapQuote.put (strQuoteField, q);

  113.         if (bIsMarketQuote) {
  114.             _mktQuote = q;
  115.             _strMarketQuoteField = strQuoteField;
  116.         }
  117.     }

  118.     @Override public boolean setMarketQuote (
  119.         final java.lang.String strMarketQuoteField,
  120.         final org.drip.param.definition.Quote q)
  121.     {
  122.         if (null == strMarketQuoteField || strMarketQuoteField.isEmpty() || null == q) return false;

  123.         _strMarketQuoteField = strMarketQuoteField;
  124.         _mktQuote = q;
  125.         return true;
  126.     }

  127.     @Override public boolean removeMarketQuote()
  128.     {
  129.         _strMarketQuoteField = "";
  130.         _mktQuote = null;
  131.         return true;
  132.     }

  133.     @Override public org.drip.param.definition.Quote quote (
  134.         final java.lang.String strQuoteField)
  135.     {
  136.         return null == strQuoteField || strQuoteField.isEmpty() ? null : _mapQuote.get (strQuoteField);
  137.     }

  138.     @Override public org.drip.param.definition.Quote marketQuote()
  139.     {
  140.         return _mktQuote;
  141.     }

  142.     @Override public java.lang.String marketQuoteField()
  143.     {
  144.         return _strMarketQuoteField;
  145.     }

  146.     @Override public boolean removeQuote (
  147.         final java.lang.String strQuoteField)
  148.     {
  149.         if (null == strQuoteField || strQuoteField.isEmpty()) return false;

  150.         _mapQuote.remove (strQuoteField);

  151.         if (!_strMarketQuoteField.equalsIgnoreCase (strQuoteField)) return true;

  152.         return removeMarketQuote();
  153.     }

  154.     @Override public boolean containsQuote (
  155.         final java.lang.String strQuoteField)
  156.     {
  157.         if (null == strQuoteField || strQuoteField.isEmpty()) return false;

  158.         return _mapQuote.containsKey (strQuoteField) || (null != _strMarketQuoteField &&
  159.             _strMarketQuoteField.equalsIgnoreCase (strQuoteField));
  160.     }
  161. }