Ahmednagar.java

  1. package org.drip.sample.securitysuite;

  2. import org.drip.analytics.date.*;
  3. import org.drip.analytics.daycount.*;
  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) 2018 Lakshmi Krishnamurthy
  13.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  14.  *
  15.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  16.  *      libraries targeting analysts and developers
  17.  *      https://lakshmidrip.github.io/DRIP/
  18.  *  
  19.  *  DRIP is composed of four main libraries:
  20.  *  
  21.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  22.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  23.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  24.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  25.  *
  26.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  27.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  28.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  29.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  30.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  31.  *
  32.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  33.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  34.  *
  35.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  36.  *
  37.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  38.  *
  39.  *  Licensed under the Apache License, Version 2.0 (the "License");
  40.  *      you may not use this file except in compliance with the License.
  41.  *  
  42.  *  You may obtain a copy of the License at
  43.  *      http://www.apache.org/licenses/LICENSE-2.0
  44.  *  
  45.  *  Unless required by applicable law or agreed to in writing, software
  46.  *      distributed under the License is distributed on an "AS IS" BASIS,
  47.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  48.  *  
  49.  *  See the License for the specific language governing permissions and
  50.  *      limitations under the License.
  51.  */

  52. /**
  53.  * Ahmednagar generates the Full Suite of Replication Metrics for Bond Ahmednagar.
  54.  *
  55.  * @author Lakshmi Krishnamurthy
  56.  */

  57. public class Ahmednagar {

  58.     public static final void main (
  59.         final String[] astArgs)
  60.         throws Exception
  61.     {
  62.         EnvManager.InitEnv ("");

  63.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  64.             2017,
  65.             DateUtil.JULY,
  66.             10
  67.         );

  68.         String[] astrDepositTenor = new String[] {
  69.             "2D"
  70.         };

  71.         double[] adblDepositQuote = new double[] {
  72.             0.0130411 // 2D
  73.         };

  74.         double[] adblFuturesQuote = new double[] {
  75.             0.01345,    // 98.655
  76.             0.01470,    // 98.530
  77.             0.01575,    // 98.425
  78.             0.01660,    // 98.340
  79.             0.01745,    // 98.255
  80.             0.01845     // 98.155
  81.         };

  82.         String[] astrFixFloatTenor = new String[] {
  83.             "02Y",
  84.             "03Y",
  85.             "04Y",
  86.             "05Y",
  87.             "06Y",
  88.             "07Y",
  89.             "08Y",
  90.             "09Y",
  91.             "10Y",
  92.             "11Y",
  93.             "12Y",
  94.             "15Y",
  95.             "20Y",
  96.             "25Y",
  97.             "30Y",
  98.             "40Y",
  99.             "50Y"
  100.         };

  101.         String[] astrGovvieTenor = new String[] {
  102.             "1Y",
  103.             "2Y",
  104.             "3Y",
  105.             "5Y",
  106.             "7Y",
  107.             "10Y",
  108.             "20Y",
  109.             "30Y"
  110.         };

  111.         double[] adblFixFloatQuote = new double[] {
  112.             0.016410, //  2Y
  113.             0.017863, //  3Y
  114.             0.019030, //  4Y
  115.             0.020035, //  5Y
  116.             0.020902, //  6Y
  117.             0.021660, //  7Y
  118.             0.022307, //  8Y
  119.             0.022879, //  9Y
  120.             0.023363, // 10Y
  121.             0.023820, // 11Y
  122.             0.024172, // 12Y
  123.             0.024934, // 15Y
  124.             0.025581, // 20Y
  125.             0.025906, // 25Y
  126.             0.025973, // 30Y
  127.             0.025838, // 40Y
  128.             0.025560  // 50Y
  129.         };

  130.         double[] adblGovvieYield = new double[] {
  131.             0.01219, //  1Y
  132.             0.01391, //  2Y
  133.             0.01590, //  3Y
  134.             0.01937, //  5Y
  135.             0.02200, //  7Y
  136.             0.02378, // 10Y
  137.             0.02677, // 20Y
  138.             0.02927  // 30Y
  139.         };

  140.         String[] astrCreditTenor = new String[] {
  141.             "06M",
  142.             "01Y",
  143.             "02Y",
  144.             "03Y",
  145.             "04Y",
  146.             "05Y",
  147.             "07Y",
  148.             "10Y"
  149.         };

  150.         double[] adblCreditQuote = new double[] {
  151.              60.,   //  6M
  152.              68.,   //  1Y
  153.              88.,   //  2Y
  154.             102.,   //  3Y
  155.             121.,   //  4Y
  156.             138.,   //  5Y
  157.             168.,   //  7Y
  158.             188.    // 10Y
  159.         };

  160.         double dblFX = 1.;
  161.         int iSettleLag = 3;
  162.         int iFixedFreq = 2;
  163.         int iFloatFreq = 4;
  164.         String strName = "Ahmednagar";
  165.         double dblCleanPrice = 1.;
  166.         double dblIssuePrice = 1.;
  167.         String strCurrency = "USD";
  168.         double dblSpreadBump = 20.;
  169.         double dblFixedCoupon = 0.0625;
  170.         double dblIssueAmount = 3.6e08;
  171.         String strTreasuryCode = "UST";
  172.         String strFloatIndex = "USD-3M";
  173.         double dblFloatSpread = 0.03899;
  174.         String strFixedDayCount = "30/360";
  175.         double dblSpreadDurationMultiplier = 5.;

  176.         JulianDate dtEffective = DateUtil.CreateFromYMD (
  177.             2017,
  178.             DateUtil.FEBRUARY,
  179.             28
  180.         );

  181.         JulianDate dtFixedFirstCoupon = DateUtil.CreateFromYMD (
  182.             2017,
  183.             DateUtil.AUGUST,
  184.             28
  185.         );

  186.         JulianDate dtFixedEnd = DateUtil.CreateFromYMD (
  187.             2027,
  188.             DateUtil.AUGUST,
  189.             28
  190.         );

  191.         JulianDate dtFloatPenultimateCoupon = DateUtil.CreateFromYMD (
  192.             2056,
  193.             DateUtil.AUGUST,
  194.             28
  195.         );

  196.         JulianDate dtMaturity = DateUtil.CreateFromYMD (
  197.             2057,
  198.             DateUtil.FEBRUARY,
  199.             28
  200.         );

  201.         BondComponent bond = BondBuilder.FixedFToFloatP (
  202.             strName,
  203.             strName,
  204.             dtEffective.julian(),
  205.             dtFixedEnd.julian(),
  206.             dtFixedFirstCoupon.julian(),
  207.             iFixedFreq,
  208.             dblFixedCoupon,
  209.             strFixedDayCount,
  210.             strFixedDayCount,
  211.             dtMaturity.julian(),
  212.             dtFloatPenultimateCoupon.julian(),
  213.             iFloatFreq,
  214.             dblFloatSpread,
  215.             strFloatIndex,
  216.             new DateAdjustParams (
  217.                 Convention.DATE_ROLL_FOLLOWING,
  218.                 0,
  219.                 strCurrency
  220.             ),
  221.             null,
  222.             null,
  223.             null,
  224.             null,
  225.             null,
  226.             null,
  227.             null
  228.         );

  229.         BondReplicator abr = BondReplicator.CorporateSenior (
  230.             dblCleanPrice,
  231.             dblIssuePrice,
  232.             dblIssueAmount,
  233.             dtSpot,
  234.             astrDepositTenor,
  235.             adblDepositQuote,
  236.             adblFuturesQuote,
  237.             astrFixFloatTenor,
  238.             adblFixFloatQuote,
  239.             dblSpreadBump,
  240.             dblSpreadDurationMultiplier,
  241.             strTreasuryCode,
  242.             astrGovvieTenor,
  243.             adblGovvieYield,
  244.             astrCreditTenor,
  245.             adblCreditQuote,
  246.             dblFX,
  247.             Double.NaN,
  248.             iSettleLag,
  249.             bond
  250.         );

  251.         BondReplicationRun abrr = abr.generateRun();

  252.         System.out.println (abrr.display());
  253.     }
  254. }