BrokenDateGovvieSpot.java

  1. package org.drip.sample.intexfeed;

  2. import org.drip.analytics.date.*;
  3. import org.drip.numerical.common.FormatUtil;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.service.template.LatentMarketStateBuilder;
  6. import org.drip.state.govvie.GovvieCurve;

  7. /*
  8.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  9.  */

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

  71. /**
  72.  * <i>BrokenDateGovvieSpot</i> generates the Sequence of Govvie Yields with Monthly Increments in Maturity
  73.  * over 60 Years.
  74.  *  
  75.  * <br><br>
  76.  *  <ul>
  77.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  78.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  79.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  80.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/intexfeed/README.md">Intex Feed Inputs</a></li>
  81.  *  </ul>
  82.  * <br><br>
  83.  *
  84.  * @author Lakshmi Krishnamurthy
  85.  */

  86. public class BrokenDateGovvieSpot {

  87.     private static final GovvieCurve GovvieCurve (
  88.         final JulianDate dtSpot,
  89.         final String strCode)
  90.         throws Exception
  91.     {
  92.         return LatentMarketStateBuilder.GovvieCurve (
  93.             strCode,
  94.             dtSpot,
  95.             new JulianDate[] {
  96.                 dtSpot,
  97.                 dtSpot,
  98.                 dtSpot,
  99.                 dtSpot,
  100.                 dtSpot,
  101.                 dtSpot,
  102.                 dtSpot,
  103.                 dtSpot
  104.             },
  105.             new JulianDate[] {
  106.                 dtSpot.addTenor ("1Y"),
  107.                 dtSpot.addTenor ("2Y"),
  108.                 dtSpot.addTenor ("3Y"),
  109.                 dtSpot.addTenor ("5Y"),
  110.                 dtSpot.addTenor ("7Y"),
  111.                 dtSpot.addTenor ("10Y"),
  112.                 dtSpot.addTenor ("20Y"),
  113.                 dtSpot.addTenor ("30Y")
  114.             },
  115.             new double[] {
  116.                 0.01219, //  1Y
  117.                 0.01391, //  2Y
  118.                 0.01590, //  3Y
  119.                 0.01937, //  5Y
  120.                 0.02200, //  7Y
  121.                 0.02378, // 10Y
  122.                 0.02677, // 20Y
  123.                 0.02927  // 30Y
  124.             },
  125.             new double[] {
  126.                 0.01219, //  1Y
  127.                 0.01391, //  2Y
  128.                 0.01590, //  3Y
  129.                 0.01937, //  5Y
  130.                 0.02200, //  7Y
  131.                 0.02378, // 10Y
  132.                 0.02677, // 20Y
  133.                 0.02927  // 30Y
  134.             },
  135.             "Yield",
  136.             LatentMarketStateBuilder.SHAPE_PRESERVING
  137.         );
  138.     }

  139.     public static final void main (
  140.         final String[] astrArgs)
  141.         throws Exception
  142.     {
  143.         EnvManager.InitEnv ("");

  144.         String strCode = "UST";
  145.         int iNumMonthlyTenor = 720;

  146.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  147.             2017,
  148.             DateUtil.OCTOBER,
  149.             5
  150.         );

  151.         GovvieCurve gc = GovvieCurve (
  152.             dtSpot,
  153.             strCode
  154.         );

  155.         System.out.println ("SpotDate,MaturityTenor,MaturityDate,MaturityYield");

  156.         for (int i = 0; i < iNumMonthlyTenor; ++i) {
  157.             JulianDate dtMaturity = dtSpot.addMonths (i);

  158.             System.out.println (
  159.                 dtSpot + "," +
  160.                 i + "M," +
  161.                 dtMaturity + "," +
  162.                 FormatUtil.FormatDouble (gc.yield (dtMaturity), 1, 8, 100.) + "%"
  163.             );
  164.         }

  165.         EnvManager.TerminateEnv();
  166.     }
  167. }