IBOR6MCubicKLKHyperbolic.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>IBOR6MCubicKLKHyperbolic</i> illustrates the Construction and Usage of the IBOR 6M Forward Curve Using
  79.  * Cubic KLK Hyperbolic Tension B-Spline.
  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 IBOR6MCubicKLKHyperbolic {
  93.     public static final ForwardCurve Make6MForward (
  94.         final JulianDate dtValue,
  95.         final String strCurrency,
  96.         final String strTenor)
  97.         throws Exception
  98.     {
  99.         ForwardLabel fri = ForwardLabel.Create (
  100.             strCurrency,
  101.             strTenor
  102.         );

  103.         MergedDiscountForwardCurve dcEONIA = OvernightIndexCurve.MakeDC (
  104.             dtValue,
  105.             strCurrency
  106.         );

  107.         SegmentCustomBuilderControl scbcCubicKLKHyperbolic = new SegmentCustomBuilderControl (
  108.             MultiSegmentSequenceBuilder.BASIS_SPLINE_KLK_HYPERBOLIC_TENSION,
  109.             new ExponentialTensionSetParams (1.),
  110.             SegmentInelasticDesignControl.Create (
  111.                 2,
  112.                 2
  113.             ),
  114.             new ResponseScalingShapeControl (
  115.                 true,
  116.                 new QuadraticRationalShapeControl (0.)
  117.             ),
  118.             null
  119.         );

  120.         /*
  121.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  122.          */

  123.         double[] adblDepositQuote = new double[] {
  124.             0.003565,   // 1D
  125.             0.003858,   // 1W
  126.             0.003840,   // 2W
  127.             0.003922,   // 3W
  128.             0.003869,   // 1M
  129.             0.003698,   // 2M
  130.             0.003527,   // 3M
  131.             0.003342,   // 4M
  132.             0.003225    // 5M
  133.         };

  134.         String[] astrDepositTenor = new String[] {
  135.             "1D",
  136.             "1W",
  137.             "2W",
  138.             "3W",
  139.             "1M",
  140.             "2M",
  141.             "3M",
  142.             "4M",
  143.             "5M"
  144.         };

  145.         /*
  146.          * Construct the Array of FRAs and their Quotes from the given set of parameters
  147.          */

  148.         double[] adblFRAQuote = new double[] {
  149.             0.003120,   //  0D
  150.             0.002930,   //  1M
  151.             0.002720,   //  2M
  152.             0.002600,   //  3M
  153.             0.002560,   //  4M
  154.             0.002520,   //  5M
  155.             0.002480,   //  6M
  156.             0.002540,   //  7M
  157.             0.002610,   //  8M
  158.             0.002670,   //  9M
  159.             0.002790,   // 10M
  160.             0.002910,   // 11M
  161.             0.003030,   // 12M
  162.             0.003180,   // 13M
  163.             0.003350,   // 14M
  164.             0.003520,   // 15M
  165.             0.003710,   // 16M
  166.             0.003890,   // 17M
  167.             0.004090    // 18M
  168.         };

  169.         String[] astrFRATenor = new String[] {
  170.              "0D",
  171.              "1M",
  172.              "2M",
  173.              "3M",
  174.              "4M",
  175.              "5M",
  176.              "6M",
  177.              "7M",
  178.              "8M",
  179.              "9M",
  180.             "10M",
  181.             "11M",
  182.             "12M",
  183.             "13M",
  184.             "14M",
  185.             "15M",
  186.             "16M",
  187.             "17M",
  188.             "18M"
  189.         };

  190.         /*
  191.          * Construct the Array of Fix-Float Component and their Quotes from the given set of parameters
  192.          */

  193.         double[] adblFixFloatQuote = new double[] {
  194.             0.004240,   //  3Y
  195.             0.005760,   //  4Y          
  196.             0.007620,   //  5Y
  197.             0.009540,   //  6Y
  198.             0.011350,   //  7Y
  199.             0.013030,   //  8Y
  200.             0.014520,   //  9Y
  201.             0.015840,   // 10Y
  202.             0.018090,   // 12Y
  203.             0.020370,   // 15Y
  204.             0.021870,   // 20Y
  205.             0.022340,   // 25Y
  206.             0.022560,   // 30Y
  207.             0.022950,   // 35Y
  208.             0.023480,   // 40Y
  209.             0.024210,   // 50Y
  210.             0.024630    // 60Y
  211.         };

  212.         String[] astrFixFloatTenor = new String[] {
  213.              "3Y",
  214.              "4Y",
  215.              "5Y",
  216.              "6Y",
  217.              "7Y",
  218.              "8Y",
  219.              "9Y",
  220.             "10Y",
  221.             "12Y",
  222.             "15Y",
  223.             "20Y",
  224.             "25Y",
  225.             "30Y",
  226.             "35Y",
  227.             "40Y",
  228.             "50Y",
  229.             "60Y"
  230.         };

  231.         ForwardCurve fc = IBORCurve.CustomIBORBuilderSample (
  232.             dcEONIA,
  233.             null,
  234.             fri,
  235.             scbcCubicKLKHyperbolic,
  236.             astrDepositTenor,
  237.             adblDepositQuote,
  238.             "ForwardRate",
  239.             astrFRATenor,
  240.             adblFRAQuote,
  241.             "ParForwardRate",
  242.             astrFixFloatTenor,
  243.             adblFixFloatQuote,
  244.             "SwapRate",
  245.             null,
  246.             null,
  247.             "DerivedParBasisSpread",
  248.             null,
  249.             null,
  250.             "DerivedParBasisSpread",
  251.             "---- EURIBOR 6M CUBIC KLK HYPERBOLIC TENSION B-SPLINE FORWARD CURVE ---",
  252.             true
  253.         );

  254.         /* IBOR.ForwardJack (
  255.             dtValue,
  256.             "---- EURIBOR 6M CUBIC KLK HYPERBOLIC TENSION B-SPLINE FORWARD CURVE SENSITIVITY ---",
  257.             fc,
  258.             "DerivedParBasisSpread"
  259.         ); */

  260.         return fc;
  261.     }

  262.     public static final void main (
  263.         final String[] astrArgs)
  264.         throws Exception
  265.     {
  266.         /*
  267.          * Initialize the Credit Analytics Library
  268.          */

  269.         EnvManager.InitEnv ("");

  270.         Make6MForward (
  271.             DateUtil.CreateFromYMD (
  272.                 2012,
  273.                 DateUtil.DECEMBER,
  274.                 11
  275.             ),
  276.             "EUR",
  277.             "6M"
  278.         );

  279.         EnvManager.TerminateEnv();
  280.     }
  281. }