TreasuryFuturesContractContainer.java

  1. package org.drip.market.exchange;

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

  77. /**
  78.  * <i>TreasuryFuturesContractContainer</i> holds the Details of some of the Common Treasury Futures Contracts.
  79.  *
  80.  *  <br><br>
  81.  *  <ul>
  82.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  83.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  84.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market">Static Market Fields - the Definitions, the OTC/Exchange Traded Products, and Treasury Settings</a></li>
  85.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market/exchange">Deliverable Swap, STIR, Treasury Futures</a></li>
  86.  *  </ul>
  87.  *
  88.  * @author Lakshmi Krishnamurthy
  89.  */

  90. public class TreasuryFuturesContractContainer {
  91.     private static
  92.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.market.exchange.TreasuryFuturesContract>
  93.             _mapNameContract = null;
  94.     private static
  95.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.market.exchange.TreasuryFuturesContract>
  96.             _mapCodeTenorContract = null;

  97.     private static final boolean AddContract (
  98.         final java.lang.String[] astrName,
  99.         final java.lang.String strID,
  100.         final java.lang.String strCode,
  101.         final java.lang.String strType,
  102.         final java.lang.String strTenor)
  103.     {
  104.         try {
  105.             org.drip.market.exchange.TreasuryFuturesContract tfc = new
  106.                 org.drip.market.exchange.TreasuryFuturesContract (strID, strCode, strType, strTenor);

  107.             for (java.lang.String strName : astrName)
  108.                 _mapNameContract.put (strName, tfc);

  109.             _mapCodeTenorContract.put (strCode + "::" + strTenor, tfc);

  110.             return true;
  111.         } catch (java.lang.Exception e) {
  112.             e.printStackTrace();
  113.         }

  114.         return false;
  115.     }

  116.     /**
  117.      * Initialize the Treasury Futures Contract Container with the Conventions
  118.      *
  119.      * @return TRUE - The Treasury Futures Contracts Container successfully initialized with the Contracts
  120.      */

  121.     public static final boolean Init()
  122.     {
  123.         if (null != _mapNameContract) return true;

  124.         _mapNameContract = new
  125.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.market.exchange.TreasuryFuturesContract>();

  126.         _mapCodeTenorContract = new
  127.             org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.market.exchange.TreasuryFuturesContract>();

  128.         /*
  129.          * Australian Treasury Futures
  130.          */

  131.         if (!AddContract (new java.lang.String[] {"YM1"}, "YM1", "AGB", "NOTE", "03Y")) return false;

  132.         if (!AddContract (new java.lang.String[] {"XM1"}, "XM1", "AGB", "NOTE", "10Y")) return false;

  133.         /*
  134.          * Canadian Treasury Futures
  135.          */

  136.         if (!AddContract (new java.lang.String[] {"CN1"}, "CN1", "CAN", "NOTE", "10Y")) return false;

  137.         /*
  138.          * Danish Treasury Futures
  139.          */

  140.         if (!AddContract (new java.lang.String[] {"DGB"}, "DGB", "DGB", "NOTE", "10Y")) return false;

  141.         /*
  142.          * French Treasury Futures
  143.          */

  144.         if (!AddContract (new java.lang.String[] {"OAT1"}, "OAT1", "FRTR", "NOTE", "10Y")) return false;

  145.         /*
  146.          * German Treasury Futures
  147.          */

  148.         if (!AddContract (new java.lang.String[] {"DU1", "SCHATZ"}, "DU1", "DBR", "NOTE", "02Y"))
  149.             return false;

  150.         if (!AddContract (new java.lang.String[] {"OE1", "BOBL"}, "OE1", "DBR", "NOTE", "05Y")) return false;

  151.         if (!AddContract (new java.lang.String[] {"RX1", "BUND"}, "RX1", "DBR", "NOTE", "10Y")) return false;

  152.         if (!AddContract (new java.lang.String[] {"UB1", "BUXL"}, "UB1", "DBR", "NOTE", "30Y")) return false;

  153.         /*
  154.          * Italian Treasury Futures
  155.          */

  156.         if (!AddContract (new java.lang.String[] {"IK1"}, "IK1", "BTPS", "NOTE", "10Y")) return false;

  157.         /*
  158.          * Japanese Treasury Futures
  159.          */

  160.         if (!AddContract (new java.lang.String[] {"JB1"}, "JB1", "JGB", "NOTE", "10Y")) return false;

  161.         /*
  162.          * Spanish Treasury Futures
  163.          */

  164.         if (!AddContract (new java.lang.String[] {"FBB1"}, "FBB1", "SPGB", "NOTE", "10Y")) return false;

  165.         /*
  166.          * Swiss Treasury Futures
  167.          */

  168.         if (!AddContract (new java.lang.String[] {"GSWISS"}, "GSWISS", "GSWISS", "NOTE", "10Y"))
  169.             return false;

  170.         /*
  171.          * UK Treasury Futures
  172.          */

  173.         if (!AddContract (new java.lang.String[] {"WB1"}, "WB1", "GILT", "NOTE", "02Y")) return false;

  174.         if (!AddContract (new java.lang.String[] {"G1"}, "G1", "GILT", "NOTE", "10Y")) return false;

  175.         /*
  176.          * US Treasury Futures
  177.          */

  178.         if (!AddContract (new java.lang.String[] {"TU1"}, "TU1", "UST", "NOTE", "02Y")) return false;

  179.         if (!AddContract (new java.lang.String[] {"FV1"}, "FV1", "UST", "NOTE", "05Y")) return false;

  180.         if (!AddContract (new java.lang.String[] {"TY1"}, "TY1", "UST", "NOTE", "10Y")) return false;

  181.         if (!AddContract (new java.lang.String[] {"US1"}, "US1", "UST", "NOTE", "20Y")) return false;

  182.         if (!AddContract (new java.lang.String[] {"WN1", "ULTRA"}, "WN1", "UST", "NOTE", "30Y"))
  183.             return false;

  184.         return true;
  185.     }

  186.     /**
  187.      * Retrieve the Treasury Futures Contract by Name
  188.      *
  189.      * @param strTreasuryFuturesName The Treasury Futures Name
  190.      *
  191.      * @return The Treasury Futures Contract
  192.      */

  193.     public static final org.drip.market.exchange.TreasuryFuturesContract TreasuryFuturesContract (
  194.         final java.lang.String strTreasuryFuturesName)
  195.     {
  196.         return !_mapNameContract.containsKey (strTreasuryFuturesName) ? null : _mapNameContract.get
  197.             (strTreasuryFuturesName);
  198.     }

  199.     /**
  200.      * Retrieve the Treasury Futures Contract by Code and Tenor
  201.      *
  202.      * @param strCode The Treasury Code
  203.      * @param strTenor The Futures Tenor
  204.      *
  205.      * @return The Treasury Futures Contract
  206.      */

  207.     public static final org.drip.market.exchange.TreasuryFuturesContract TreasuryFuturesContract (
  208.         final java.lang.String strCode,
  209.         final java.lang.String strTenor)
  210.     {
  211.         java.lang.String strCodeTenor = strCode + "::" + strTenor;

  212.         return !_mapNameContract.containsKey (strCodeTenor) ? null : _mapNameContract.get (strCodeTenor);
  213.     }
  214. }