Ludhiana.java

  1. package org.drip.sample.bondmetrics;

  2. import org.drip.analytics.date.*;
  3. import org.drip.product.creator.BondBuilder;
  4. import org.drip.product.credit.BondComponent;
  5. import org.drip.product.params.EmbeddedOptionSchedule;
  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>Ludhiana</i> generates the Full Suite of Replication Metrics for Bond Ludhiana.
  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/bondmetrics/README.md">Bond Relative Value Replication Demonstration</a></li>
  91.  *  </ul>
  92.  * <br><br>
  93.  *
  94.  * @author Lakshmi Krishnamurthy
  95.  */

  96. public class Ludhiana {

  97.     private static final void SetEOS (
  98.         final BondComponent bond,
  99.         final EmbeddedOptionSchedule eosCall,
  100.         final EmbeddedOptionSchedule eosPut)
  101.         throws java.lang.Exception
  102.     {
  103.         if (null != eosPut) bond.setEmbeddedPutSchedule (eosPut);

  104.         if (null != eosCall) bond.setEmbeddedCallSchedule (eosCall);
  105.     }

  106.     public static final void main (
  107.         final String[] astArgs)
  108.         throws Exception
  109.     {
  110.         EnvManager.InitEnv (
  111.             "",
  112.             true
  113.         );

  114.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  115.             2017,
  116.             DateUtil.JULY,
  117.             10
  118.         );

  119.         String[] astrDepositTenor = new String[] {
  120.             "2D"
  121.         };

  122.         double[] adblDepositQuote = new double[] {
  123.             0.0130411 // 2D
  124.         };

  125.         double[] adblFuturesQuote = new double[] {
  126.             0.01345,    // 98.655
  127.             0.01470,    // 98.530
  128.             0.01575,    // 98.425
  129.             0.01660,    // 98.340
  130.             0.01745,    // 98.255
  131.             0.01845     // 98.155
  132.         };

  133.         String[] astrFixFloatTenor = new String[] {
  134.             "02Y",
  135.             "03Y",
  136.             "04Y",
  137.             "05Y",
  138.             "06Y",
  139.             "07Y",
  140.             "08Y",
  141.             "09Y",
  142.             "10Y",
  143.             "11Y",
  144.             "12Y",
  145.             "15Y",
  146.             "20Y",
  147.             "25Y",
  148.             "30Y",
  149.             "40Y",
  150.             "50Y"
  151.         };

  152.         String[] astrGovvieTenor = new String[] {
  153.             "1Y",
  154.             "2Y",
  155.             "3Y",
  156.             "5Y",
  157.             "7Y",
  158.             "10Y",
  159.             "20Y",
  160.             "30Y"
  161.         };

  162.         double[] adblFixFloatQuote = new double[] {
  163.             0.016410, //  2Y
  164.             0.017863, //  3Y
  165.             0.019030, //  4Y
  166.             0.020035, //  5Y
  167.             0.020902, //  6Y
  168.             0.021660, //  7Y
  169.             0.022307, //  8Y
  170.             0.022879, //  9Y
  171.             0.023363, // 10Y
  172.             0.023820, // 11Y
  173.             0.024172, // 12Y
  174.             0.024934, // 15Y
  175.             0.025581, // 20Y
  176.             0.025906, // 25Y
  177.             0.025973, // 30Y
  178.             0.025838, // 40Y
  179.             0.025560  // 50Y
  180.         };

  181.         double[] adblGovvieYield = new double[] {
  182.             0.01219, //  1Y
  183.             0.01391, //  2Y
  184.             0.01590, //  3Y
  185.             0.01937, //  5Y
  186.             0.02200, //  7Y
  187.             0.02378, // 10Y
  188.             0.02677, // 20Y
  189.             0.02927  // 30Y
  190.         };

  191.         String[] astrCreditTenor = new String[] {
  192.             "06M",
  193.             "01Y",
  194.             "02Y",
  195.             "03Y",
  196.             "04Y",
  197.             "05Y",
  198.             "07Y",
  199.             "10Y"
  200.         };

  201.         double[] adblCreditQuote = new double[] {
  202.              60.,   //  6M
  203.              68.,   //  1Y
  204.              88.,   //  2Y
  205.             102.,   //  3Y
  206.             121.,   //  4Y
  207.             138.,   //  5Y
  208.             168.,   //  7Y
  209.             188.    // 10Y
  210.         };

  211.         double dblFX = 1.;
  212.         int iSettleLag = 3;
  213.         int iCouponFreq = 2;
  214.         String strName = "Ludhiana";
  215.         double dblCleanPrice = 1.;
  216.         double dblIssuePrice = 1.;
  217.         String strCurrency = "USD";
  218.         double dblSpreadBump = 20.;
  219.         double dblCouponRate = 0.05125;
  220.         double dblIssueAmount = 8.00e8;
  221.         String strTreasuryCode = "UST";
  222.         String strCouponDayCount = "30/360";
  223.         double dblSpreadDurationMultiplier = 5.;

  224.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  225.             2012,
  226.             4,
  227.             5
  228.         );

  229.         JulianDate dtMaturity = DateUtil.CreateFromYMD (
  230.             2022,
  231.             4,
  232.             15
  233.         );

  234.         BondComponent bond = BondBuilder.CreateSimpleFixed (
  235.             strName,
  236.             strCurrency,
  237.             strName,
  238.             dblCouponRate,
  239.             iCouponFreq,
  240.             strCouponDayCount,
  241.             dtEffective,
  242.             dtMaturity,
  243.             null,
  244.             null
  245.         );

  246.         SetEOS (
  247.             bond,
  248.             null,
  249.             null
  250.         );

  251.         BondReplicator abr = BondReplicator.CorporateSenior (
  252.             dblCleanPrice,
  253.             dblIssuePrice,
  254.             dblIssueAmount,
  255.             dtSpot,
  256.             astrDepositTenor,
  257.             adblDepositQuote,
  258.             adblFuturesQuote,
  259.             astrFixFloatTenor,
  260.             adblFixFloatQuote,
  261.             dblSpreadBump,
  262.             dblSpreadDurationMultiplier,
  263.             strTreasuryCode,
  264.             astrGovvieTenor,
  265.             adblGovvieYield,
  266.             astrCreditTenor,
  267.             adblCreditQuote,
  268.             dblFX,
  269.             Double.NaN,
  270.             iSettleLag,
  271.             bond
  272.         );

  273.         BondReplicationRun abrr = abr.generateRun();

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

  275.         EnvManager.TerminateEnv();
  276.     }
  277. }