IBOR12MCubicKLKHyperbolic.java

  1. package org.drip.sample.forward;

  2. import org.drip.analytics.date.*;
  3. import org.drip.function.r1tor1.QuadraticRationalShapeControl;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.spline.basis.ExponentialTensionSetParams;
  6. import org.drip.spline.params.*;
  7. import org.drip.spline.stretch.MultiSegmentSequenceBuilder;
  8. import org.drip.state.discount.*;
  9. import org.drip.state.forward.ForwardCurve;
  10. import org.drip.state.identifier.ForwardLabel;

  11. /*
  12.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  13.  */

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

  77. /**
  78.  * <i>IBOR12MCubicKLKHyperbolic</i> illustrates the Construction and Usage of the IBOR 12M Forward Curve
  79.  * Using Vanilla Cubic KLK Hyperbolic Tension B-Splines.
  80.  *  
  81.  * <br><br>
  82.  *  <ul>
  83.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  84.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  85.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  86.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/forward/README.md">Forward Rate Curve Construction</a></li>
  87.  *  </ul>
  88.  * <br><br>
  89.  *
  90.  * @author Lakshmi Krishnamurthy
  91.  */

  92. public class IBOR12MCubicKLKHyperbolic {
  93.     public static final void main (
  94.         final String[] astrArgs)
  95.         throws Exception
  96.     {
  97.         /*
  98.          * Initialize the Credit Analytics Library
  99.          */

  100.         EnvManager.InitEnv ("");

  101.         JulianDate dtValue = DateUtil.CreateFromYMD (
  102.             2012,
  103.             DateUtil.DECEMBER,
  104.             11
  105.         );

  106.         String strTenor = "12M";
  107.         String strCurrency = "USD";

  108.         ForwardLabel fri = ForwardLabel.Create (
  109.             strCurrency,
  110.             strTenor
  111.         );

  112.         MergedDiscountForwardCurve dcEONIA = OvernightIndexCurve.MakeDC (
  113.             dtValue,
  114.             strCurrency
  115.         );

  116.         SegmentCustomBuilderControl scbcCubicKLKHyperbolic = new SegmentCustomBuilderControl (
  117.             MultiSegmentSequenceBuilder.BASIS_SPLINE_KLK_HYPERBOLIC_TENSION,
  118.             new ExponentialTensionSetParams (1.),
  119.             SegmentInelasticDesignControl.Create (
  120.                 2,
  121.                 2
  122.             ),
  123.             new ResponseScalingShapeControl (
  124.                 true,
  125.                 new QuadraticRationalShapeControl (0.)
  126.             ),
  127.             null
  128.         );

  129.         /*
  130.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  131.          */

  132.         double[] adblDepositQuote = new double[] {
  133.             0.006537,
  134.             0.006187,
  135.             0.005772,
  136.             0.005563,
  137.             0.005400
  138.         };

  139.         String[] astrDepositTenor = new String[] {
  140.              "1M",
  141.              "3M",
  142.              "6M",
  143.              "9M",
  144.             "12M"
  145.         };

  146.         /*
  147.          * Construct the Array of Fix-Float Component and their Quotes from the given set of parameters
  148.          */

  149.         double[] adblFRAQuote = new double[] {
  150.             0.004974,
  151.             0.004783,
  152.             0.004822,
  153.             0.005070,
  154.             0.005481,
  155.             0.006025
  156.         };

  157.         String[] astrFRATenor = new String[] {
  158.              "3M",
  159.              "6M",
  160.              "9M",
  161.             "12M",
  162.             "15M",
  163.             "18M",
  164.         };

  165.         /*
  166.          * Construct the Array of Float-Float Component and their Quotes from the given set of parameters
  167.          */

  168.         double[] adblFloatFloatQuote = new double[] {
  169.             -0.002070,  //  3Y
  170.             -0.001640,  //  4Y
  171.             -0.001510,  //  5Y
  172.             -0.001390,  //  6Y
  173.             -0.001300,  //  7Y
  174.             -0.001230,  //  8Y
  175.             -0.001180,  //  9Y
  176.             -0.001130,  // 10Y
  177.             -0.001090,  // 11Y
  178.             -0.001060,  // 12Y
  179.             -0.000930,  // 15Y
  180.             -0.000800,  // 20Y
  181.             -0.000720,  // 25Y
  182.             -0.000660   // 30Y
  183.         };

  184.         String[] astrFloatFloatTenor = new String[] {
  185.               "3Y",
  186.               "4Y",
  187.               "5Y",
  188.               "6Y",
  189.               "7Y",
  190.               "8Y",
  191.               "9Y",
  192.              "10Y",
  193.              "11Y",
  194.              "12Y",
  195.              "15Y",
  196.              "20Y",
  197.              "25Y",
  198.              "30Y"
  199.         };

  200.         /*
  201.          * Construct the Array of Terminal Synthetic Float-Float Components and their Quotes from the given set of parameters
  202.          */

  203.         String[] astrSyntheticFloatFloatTenor = new String[] {
  204.             "35Y",
  205.             "40Y",
  206.             "50Y",
  207.             "60Y"
  208.         };

  209.         double[] adblSyntheticFloatFloatQuote = new double[] {
  210.             -0.000660,
  211.             -0.000660,
  212.             -0.000660,
  213.             -0.000660
  214.         };

  215.         ForwardCurve fc6M = IBOR6MCubicPolyVanilla.Make6MForward (
  216.             dtValue,
  217.             strCurrency,
  218.             "6M",
  219.             true
  220.         );

  221.         ForwardCurve fc12M = IBORCurve.CustomIBORBuilderSample (
  222.             dcEONIA,
  223.             fc6M,
  224.             fri,
  225.             scbcCubicKLKHyperbolic,
  226.             astrDepositTenor,
  227.             adblDepositQuote,
  228.             "ForwardRate",
  229.             astrFRATenor,
  230.             adblFRAQuote,
  231.             "ParForwardRate",
  232.             null,
  233.             null,
  234.             "SwapRate",
  235.             astrFloatFloatTenor,
  236.             adblFloatFloatQuote,
  237.             "ReferenceParBasisSpread",
  238.             astrSyntheticFloatFloatTenor,
  239.             adblSyntheticFloatFloatQuote,
  240.             "ReferenceParBasisSpread",
  241.             "---- VANILLA CUBIC KLK HYPERBOLIC TENSION B-SPLINE FORWARD CURVE ---",
  242.             true
  243.         );

  244.         IBORCurve.ForwardJack (
  245.             dtValue,
  246.             "---- VANILLA CUBIC KLK HYPERBOLIC TENSION B-SPLINE FORWARD CURVE SENSITIVITY ---",
  247.             fc12M,
  248.             "DerivedParBasisSpread"
  249.         );

  250.         EnvManager.TerminateEnv();
  251.     }
  252. }