Asansol.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>Asansol</i> demonstrates the Analytics Calculation/Reconciliation for the Bond Asansol.
  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 Asansol {

  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.             2017,
  106.             DateUtil.SEPTEMBER,
  107.             6
  108.         );

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

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

  115.         double[] adblFuturesQuote = new double[] {
  116.             0.01345,    // 98.655
  117.             0.01470,    // 98.530
  118.             0.01575,    // 98.425
  119.             0.01660,    // 98.340
  120.             0.01745,    // 98.255
  121.             0.01845     // 98.155
  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.         String[] astrGovvieTenor = new String[] {
  143.             "1Y",
  144.             "2Y",
  145.             "3Y",
  146.             "5Y",
  147.             "7Y",
  148.             "10Y",
  149.             "20Y",
  150.             "30Y"
  151.         };

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

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

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

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

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

  214.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  215.             2009,
  216.             2,
  217.             12
  218.         );

  219.         JulianDate dtMaturity = DateUtil.CreateFromYMD (
  220.             2019,
  221.             2,
  222.             15
  223.         );

  224.         BondComponent bond = BondBuilder.CreateSimpleFixed (
  225.             strName,
  226.             strCurrency,
  227.             strName,
  228.             dblCouponRate,
  229.             iCouponFreq,
  230.             strCouponDayCount,
  231.             dtEffective,
  232.             dtMaturity,
  233.             null,
  234.             null
  235.         );

  236.         BondReplicator abr = BondReplicator.CorporateSenior (
  237.             dblCleanPrice,
  238.             dblIssuePrice,
  239.             dblIssueAmount,
  240.             dtSpot,
  241.             astrDepositTenor,
  242.             adblDepositQuote,
  243.             adblFuturesQuote,
  244.             astrFixFloatTenor,
  245.             adblFixFloatQuote,
  246.             dblSpreadBump,
  247.             dblSpreadDurationMultiplier,
  248.             strTreasuryCode,
  249.             astrGovvieTenor,
  250.             adblGovvieYield,
  251.             astrCreditTenor,
  252.             adblCreditQuote,
  253.             dblFX,
  254.             Double.NaN,
  255.             iSettleLag,
  256.             bond
  257.         );

  258.         BondReplicationRun abrr = abr.generateRun();

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

  260.         EnvManager.TerminateEnv();
  261.     }
  262. }