Panipat.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.service.env.EnvManager;
  6. import org.drip.service.scenario.*;

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

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

  81. /**
  82.  * <i>Panipat</i> generates the Full Suite of Replication Metrics for Bond Panipat.
  83.  *  
  84.  * <br><br>
  85.  *  <ul>
  86.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  87.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  88.  *      <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>
  89.  *      <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>
  90.  *  </ul>
  91.  * <br><br>
  92.  *
  93.  * @author Lakshmi Krishnamurthy
  94.  */

  95. public class Panipat {

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

  104.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  105.             2018,
  106.             DateUtil.JANUARY,
  107.             5
  108.         );

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

  112.         double[] adblDepositQuote = new double[] {
  113.             0.0170393 // 2D
  114.         };

  115.         double[] adblFuturesQuote = new double[] {
  116.             0.01810,    // 98.190
  117.             0.01995,    // 98.005
  118.             0.02115,    // 97.885
  119.             0.02220,    // 97.780
  120.             0.02285,    // 97.715
  121.             0.02340     // 97.660
  122.         };

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

  142.         double[] adblFixFloatQuote = new double[] {
  143.             0.021489, //  2Y
  144.             0.022452, //  3Y
  145.             0.022964, //  4Y
  146.             0.023324, //  5Y
  147.             0.023628, //  6Y
  148.             0.029315, //  7Y
  149.             0.024195, //  8Y
  150.             0.024448, //  9Y
  151.             0.024701, // 10Y
  152.             0.024946, // 11Y
  153.             0.025155, // 12Y
  154.             0.025600, // 15Y
  155.             0.026034, // 20Y
  156.             0.026150, // 25Y
  157.             0.026107, // 30Y
  158.             0.025936, // 40Y
  159.             0.025636  // 50Y
  160.         };

  161.         String[] astrGovvieTenor = new String[] {
  162.             "1M",
  163.             "3M",
  164.             "6M",
  165.             "1Y",
  166.             "2Y",
  167.             "3Y",
  168.             "5Y",
  169.             "7Y",
  170.             "10Y",
  171.             "15Y",
  172.             "20Y",
  173.             "30Y"
  174.         };

  175.         double[] adblGovvieYield = new double[] {
  176.             0.01270, //  1M
  177.             0.01390, //  3M
  178.             0.01580, //  6M
  179.             0.01800, //  1Y
  180.             0.01960, //  2Y
  181.             0.02060, //  3Y
  182.             0.02290, //  5Y
  183.             0.02400, //  7Y
  184.             0.02470, // 10Y
  185.             0.02535, // 15Y
  186.             0.02640, // 20Y
  187.             0.02810  // 30Y
  188.         };

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

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

  209.         double dblFX = 1.;
  210.         int iSettleLag = 3;
  211.         int iCouponFreq = 4;
  212.         String strName = "Panipat";
  213.         double dblCleanPrice = 1.02059;
  214.         double dblIssuePrice = 1.;
  215.         String strCurrency = "USD";
  216.         double dblSpreadBump = 20.;
  217.         double dblIssueAmount = 2.60e7;
  218.         double dblFloatSpread = 0.0350;
  219.         String strTreasuryCode = "UST";
  220.         double dblFullFirstCoupon = 0.0485917;
  221.         String strCouponDayCount = "30/360";
  222.         double dblSpreadDurationMultiplier = 5.;

  223.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  224.             2016,
  225.             6,
  226.             27
  227.         );

  228.         JulianDate dtMaturity = DateUtil.CreateFromYMD (
  229.             2021,
  230.             7,
  231.             15
  232.         );

  233.         double dblResetRate = dblFullFirstCoupon - dblFloatSpread;
  234.         String strRateIndex = strCurrency + "-" + (12 / iCouponFreq) + "M";

  235.         BondComponent bond = BondBuilder.CreateSimpleFloater (
  236.             strName,
  237.             strCurrency,
  238.             strRateIndex,
  239.             strName,
  240.             dblFloatSpread,
  241.             iCouponFreq,
  242.             strCouponDayCount,
  243.             dtEffective,
  244.             dtMaturity,
  245.             null,
  246.             null
  247.         );

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

  270.         BondReplicationRun abrr = abr.generateRun();

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

  272.         EnvManager.TerminateEnv();
  273.     }
  274. }