Dehradun.java

  1. package org.drip.sample.bondsink;

  2. import org.drip.analytics.date.*;
  3. import org.drip.numerical.common.Array2D;
  4. import org.drip.product.creator.BondBuilder;
  5. import org.drip.product.credit.BondComponent;
  6. import org.drip.service.env.EnvManager;
  7. import org.drip.service.scenario.*;

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

  11. /*!
  12.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  13.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  14.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  15.  * Copyright (C) 2017 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 Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  29.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  30.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  31.  *
  32.  *  DROP Product Core implements libraries for the following:
  33.  *  - Fixed Income Analytics
  34.  *  - Loan Analytics
  35.  *  - Transaction Cost Analytics
  36.  *
  37.  *  DROP Portfolio Core implements libraries for the following:
  38.  *  - Asset Allocation Analytics
  39.  *  - Asset Liability Management Analytics
  40.  *  - Capital Estimation Analytics
  41.  *  - Exposure Analytics
  42.  *  - Margin Analytics
  43.  *  - XVA Analytics
  44.  *
  45.  *  DROP Computational Core implements libraries for the following:
  46.  *  - Algorithm Support
  47.  *  - Computation Support
  48.  *  - Function Analysis
  49.  *  - Model Validation
  50.  *  - Numerical Analysis
  51.  *  - Numerical Optimizer
  52.  *  - Spline Builder
  53.  *  - Statistical Learning
  54.  *
  55.  *  Documentation for DROP is Spread Over:
  56.  *
  57.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  58.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  59.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  60.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  61.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  62.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  63.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  64.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  65.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  66.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  67.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  68.  *
  69.  *  Licensed under the Apache License, Version 2.0 (the "License");
  70.  *      you may not use this file except in compliance with the License.
  71.  *  
  72.  *  You may obtain a copy of the License at
  73.  *      http://www.apache.org/licenses/LICENSE-2.0
  74.  *  
  75.  *  Unless required by applicable law or agreed to in writing, software
  76.  *      distributed under the License is distributed on an "AS IS" BASIS,
  77.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  78.  *  
  79.  *  See the License for the specific language governing permissions and
  80.  *      limitations under the License.
  81.  */

  82. /**
  83.  * <i>Dehradun</i> generates the Full Suite of Replication Metrics for the Sinker Bond Dehradun.
  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/sample/README.md">DROP API Construction and Usage</a></li>
  90.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/bondsink/README.md">Sinkable Amortizing Capitalizing Bond Analytics</a></li>
  91.  *  </ul>
  92.  * <br><br>
  93.  *
  94.  * @author Lakshmi Krishnamurthy
  95.  */

  96. public class Dehradun {

  97.     public static final void main (
  98.         final String[] astArgs)
  99.         throws Exception
  100.     {
  101.         EnvManager.InitEnv (
  102.             "",
  103.             true
  104.         );

  105.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  106.             2017,
  107.             DateUtil.MARCH,
  108.             10
  109.         );

  110.         String[] astrDepositTenor = new String[] {
  111.             "2D"
  112.         };

  113.         double[] adblDepositQuote = new double[] {
  114.             0.0130411 // 2D
  115.         };

  116.         double[] adblFuturesQuote = new double[] {
  117.             0.01345,    // 98.655
  118.             0.01470,    // 98.530
  119.             0.01575,    // 98.425
  120.             0.01660,    // 98.340
  121.             0.01745,    // 98.255
  122.             0.01845     // 98.155
  123.         };

  124.         String[] astrFixFloatTenor = new String[] {
  125.             "02Y",
  126.             "03Y",
  127.             "04Y",
  128.             "05Y",
  129.             "06Y",
  130.             "07Y",
  131.             "08Y",
  132.             "09Y",
  133.             "10Y",
  134.             "11Y",
  135.             "12Y",
  136.             "15Y",
  137.             "20Y",
  138.             "25Y",
  139.             "30Y",
  140.             "40Y",
  141.             "50Y"
  142.         };

  143.         String[] astrGovvieTenor = new String[] {
  144.             "1Y",
  145.             "2Y",
  146.             "3Y",
  147.             "5Y",
  148.             "7Y",
  149.             "10Y",
  150.             "20Y",
  151.             "30Y"
  152.         };

  153.         double[] adblFixFloatQuote = new double[] {
  154.             0.016410, //  2Y
  155.             0.017863, //  3Y
  156.             0.019030, //  4Y
  157.             0.020035, //  5Y
  158.             0.020902, //  6Y
  159.             0.021660, //  7Y
  160.             0.022307, //  8Y
  161.             0.022879, //  9Y
  162.             0.023363, // 10Y
  163.             0.023820, // 11Y
  164.             0.024172, // 12Y
  165.             0.024934, // 15Y
  166.             0.025581, // 20Y
  167.             0.025906, // 25Y
  168.             0.025973, // 30Y
  169.             0.025838, // 40Y
  170.             0.025560  // 50Y
  171.         };

  172.         double[] adblGovvieYield = new double[] {
  173.             0.01219, //  1Y
  174.             0.01391, //  2Y
  175.             0.01590, //  3Y
  176.             0.01937, //  5Y
  177.             0.02200, //  7Y
  178.             0.02378, // 10Y
  179.             0.02677, // 20Y
  180.             0.02927  // 30Y
  181.         };

  182.         String[] astrCreditTenor = new String[] {
  183.             "06M",
  184.             "01Y",
  185.             "02Y",
  186.             "03Y",
  187.             "04Y",
  188.             "05Y",
  189.             "07Y",
  190.             "10Y"
  191.         };

  192.         double[] adblCreditQuote = new double[] {
  193.              60.,   //  6M
  194.              68.,   //  1Y
  195.              88.,   //  2Y
  196.             102.,   //  3Y
  197.             121.,   //  4Y
  198.             138.,   //  5Y
  199.             168.,   //  7Y
  200.             188.    // 10Y
  201.         };

  202.         double dblFX = 1.;
  203.         int iSettleLag = 3;
  204.         int iCouponFreq = 2;
  205.         String strName = "Dehradun";
  206.         double dblCleanPrice = 0.9467973;
  207.         double dblIssuePrice = 1.0;
  208.         String strCurrency = "USD";
  209.         double dblSpreadBump = 20.;
  210.         double dblCouponRate = 0.04125;
  211.         double dblIssueAmount = 1.0e00;
  212.         String strTreasuryCode = "UST";
  213.         String strCouponDayCount = "30/360";
  214.         double dblSpreadDurationMultiplier = 5.;

  215.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  216.             2016,
  217.             DateUtil.JULY,
  218.             20
  219.         );

  220.         JulianDate dtMaturity = DateUtil.CreateFromYMD (
  221.             2038,
  222.             DateUtil.MARCH,
  223.             1
  224.         );

  225.         BondComponent bond = BondBuilder.CreateSimpleFixed (
  226.             strName,
  227.             strCurrency,
  228.             strName,
  229.             dblCouponRate,
  230.             iCouponFreq,
  231.             strCouponDayCount,
  232.             dtEffective,
  233.             dtMaturity,
  234.             Array2D.FromArray (
  235.                 new int[] {
  236.                     DateUtil.CreateFromYMD (2017,  9,  1).julian(),
  237.                     DateUtil.CreateFromYMD (2018,  3,  1).julian(),
  238.                     DateUtil.CreateFromYMD (2018,  9,  1).julian(),
  239.                     DateUtil.CreateFromYMD (2019,  3,  1).julian(),
  240.                     DateUtil.CreateFromYMD (2019,  9,  1).julian(),
  241.                     DateUtil.CreateFromYMD (2020,  3,  1).julian(),
  242.                     DateUtil.CreateFromYMD (2020,  9,  1).julian(),
  243.                     DateUtil.CreateFromYMD (2021,  3,  1).julian(),
  244.                     DateUtil.CreateFromYMD (2021,  9,  1).julian(),
  245.                     DateUtil.CreateFromYMD (2022,  3,  1).julian(),
  246.                     DateUtil.CreateFromYMD (2022,  9,  1).julian(),
  247.                     DateUtil.CreateFromYMD (2023,  3,  1).julian(),
  248.                     DateUtil.CreateFromYMD (2023,  9,  1).julian(),
  249.                     DateUtil.CreateFromYMD (2024,  3,  1).julian(),
  250.                     DateUtil.CreateFromYMD (2024,  9,  1).julian(),
  251.                     DateUtil.CreateFromYMD (2025,  3,  1).julian(),
  252.                     DateUtil.CreateFromYMD (2025,  9,  1).julian(),
  253.                     DateUtil.CreateFromYMD (2026,  3,  1).julian(),
  254.                     DateUtil.CreateFromYMD (2026,  9,  1).julian(),
  255.                     DateUtil.CreateFromYMD (2027,  3,  1).julian(),
  256.                     DateUtil.CreateFromYMD (2027,  9,  1).julian(),
  257.                     DateUtil.CreateFromYMD (2028,  3,  1).julian(),
  258.                     DateUtil.CreateFromYMD (2028,  9,  1).julian(),
  259.                     DateUtil.CreateFromYMD (2029,  3,  1).julian(),
  260.                     DateUtil.CreateFromYMD (2029,  9,  1).julian(),
  261.                     DateUtil.CreateFromYMD (2030,  3,  1).julian(),
  262.                     DateUtil.CreateFromYMD (2030,  9,  1).julian(),
  263.                     DateUtil.CreateFromYMD (2031,  3,  1).julian(),
  264.                     DateUtil.CreateFromYMD (2031,  9,  1).julian(),
  265.                     DateUtil.CreateFromYMD (2032,  3,  1).julian(),
  266.                     DateUtil.CreateFromYMD (2032,  9,  1).julian(),
  267.                     DateUtil.CreateFromYMD (2033,  3,  1).julian(),
  268.                     DateUtil.CreateFromYMD (2033,  9,  1).julian(),
  269.                     DateUtil.CreateFromYMD (2034,  3,  1).julian(),
  270.                     DateUtil.CreateFromYMD (2034,  9,  1).julian(),
  271.                     DateUtil.CreateFromYMD (2035,  3,  1).julian(),
  272.                     DateUtil.CreateFromYMD (2035,  9,  1).julian(),
  273.                     DateUtil.CreateFromYMD (2036,  3,  1).julian(),
  274.                     DateUtil.CreateFromYMD (2036,  9,  1).julian(),
  275.                     DateUtil.CreateFromYMD (2037,  3,  1).julian(),
  276.                     DateUtil.CreateFromYMD (2037,  9,  1).julian(),
  277.                 },
  278.                 new double[] {
  279.                     1.,
  280.                     1.,
  281.                     1.,
  282.                     1.,
  283.                     0.9863,
  284.                     0.9708,
  285.                     0.9544,
  286.                     0.9376,
  287.                     0.9198,
  288.                     0.9031,
  289.                     0.8839,
  290.                     0.8644,
  291.                     0.8441,
  292.                     0.8233,
  293.                     0.8013,
  294.                     0.7821,
  295.                     0.7593,
  296.                     0.7366,
  297.                     0.7135,
  298.                     0.6901,
  299.                     0.6659,
  300.                     0.6435,
  301.                     0.6185,
  302.                     0.5931,
  303.                     0.5668,
  304.                     0.5401,
  305.                     0.5124,
  306.                     0.4868,
  307.                     0.4577,
  308.                     0.4280,
  309.                     0.3970,
  310.                     0.3655,
  311.                     0.3327,
  312.                     0.3014,
  313.                     0.2666,
  314.                     0.2312,
  315.                     0.1945,
  316.                     0.1570,
  317.                     0.1179,
  318.                     0.0814,
  319.                     0.0402,
  320.                 }
  321.             ),
  322.             null
  323.         );

  324.         BondReplicator abr = BondReplicator.CorporateSenior (
  325.             dblCleanPrice,
  326.             dblIssuePrice,
  327.             dblIssueAmount,
  328.             dtSpot,
  329.             astrDepositTenor,
  330.             adblDepositQuote,
  331.             adblFuturesQuote,
  332.             astrFixFloatTenor,
  333.             adblFixFloatQuote,
  334.             dblSpreadBump,
  335.             dblSpreadDurationMultiplier,
  336.             strTreasuryCode,
  337.             astrGovvieTenor,
  338.             adblGovvieYield,
  339.             astrCreditTenor,
  340.             adblCreditQuote,
  341.             dblFX,
  342.             Double.NaN,
  343.             iSettleLag,
  344.             bond
  345.         );

  346.         BondReplicationRun abrr = abr.generateRun();

  347.         System.out.println (abrr.display());

  348.         EnvManager.TerminateEnv();
  349.     }
  350. }