FXLabel.java

  1. package org.drip.state.identifier;

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

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

  79. /**
  80.  * <i>FXLabel</i> contains the Identifier Parameters referencing the Latent State of the named FX Curve.
  81.  * Currently it only contains the FX Code.
  82.  *
  83.  *  <br><br>
  84.  *  <ul>
  85.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  86.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  87.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></li>
  88.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/identifier/README.md">Latent State Identifier Labels</a></li>
  89.  *  </ul>
  90.  * <br><br>
  91.  *  
  92.  * @author Lakshmi Krishnamurthy
  93.  */

  94. public class FXLabel implements org.drip.state.identifier.LatentStateLabel {
  95.     private org.drip.product.params.CurrencyPair _cp = null;

  96.     /**
  97.      * Make a Standard FX Label from the Currency Pair Instance
  98.      *
  99.      * @param cp The Currency Pair Instance
  100.      *
  101.      * @return The FX Label
  102.      */

  103.     public static final FXLabel Standard (
  104.         final org.drip.product.params.CurrencyPair cp)
  105.     {
  106.         try {
  107.             return new FXLabel (cp);
  108.         } catch (java.lang.Exception e) {
  109.             e.printStackTrace();
  110.         }

  111.         return null;
  112.     }

  113.     /**
  114.      * Make a Standard FX Label from the Currency Pair Code
  115.      *
  116.      * @param strCode The FX Code
  117.      *
  118.      * @return The FX Label
  119.      */

  120.     public static final FXLabel Standard (
  121.         final java.lang.String strCode)
  122.     {
  123.         try {
  124.             return new FXLabel (org.drip.product.params.CurrencyPair.FromCode (strCode));
  125.         } catch (java.lang.Exception e) {
  126.             e.printStackTrace();
  127.         }

  128.         return null;
  129.     }

  130.     /**
  131.      * FXLabel constructor
  132.      *
  133.      * @param cp The Currency Pair
  134.      *
  135.      * @throws java.lang.Exception Thrown if the inputs are invalid
  136.      */

  137.     private FXLabel (
  138.         final org.drip.product.params.CurrencyPair cp)
  139.         throws java.lang.Exception
  140.     {
  141.         if (null == (_cp = cp)) throw new java.lang.Exception ("FXLabel ctr: Invalid Inputs");
  142.     }

  143.     @Override public java.lang.String fullyQualifiedName()
  144.     {
  145.         return _cp.code();
  146.     }

  147.     @Override public boolean match (
  148.         final org.drip.state.identifier.LatentStateLabel lslOther)
  149.     {
  150.         return null == lslOther || !(lslOther instanceof org.drip.state.identifier.FXLabel) ? false :
  151.             _cp.code().equalsIgnoreCase (lslOther.fullyQualifiedName());
  152.     }

  153.     /**
  154.      * Delegate the Inverse FX Label
  155.      *
  156.      * @return The Inverse FX Label
  157.      */

  158.     public FXLabel inverse()
  159.     {
  160.         try {
  161.             return new FXLabel (org.drip.product.params.CurrencyPair.FromCode (_cp.inverseCode()));
  162.         } catch (java.lang.Exception e) {
  163.             e.printStackTrace();
  164.         }

  165.         return null;
  166.     }

  167.     /**
  168.      * Retrieve the Currency Pair Instance
  169.      *
  170.      * @return The Underlying Currency Pair Instance
  171.      */

  172.     public org.drip.product.params.CurrencyPair currencyPair()
  173.     {
  174.         return _cp;
  175.     }
  176. }