ForwardDerivedBasisSensitivity.java

  1. package org.drip.sample.sensitivity;

  2. import java.util.*;

  3. import org.drip.analytics.date.*;
  4. import org.drip.analytics.support.*;
  5. import org.drip.market.otc.*;
  6. import org.drip.numerical.common.FormatUtil;
  7. import org.drip.param.creator.*;
  8. import org.drip.param.market.CurveSurfaceQuoteContainer;
  9. import org.drip.param.valuation.*;
  10. import org.drip.product.creator.*;
  11. import org.drip.product.definition.*;
  12. import org.drip.product.rates.*;
  13. import org.drip.service.env.EnvManager;
  14. import org.drip.spline.basis.*;
  15. import org.drip.spline.stretch.MultiSegmentSequenceBuilder;
  16. import org.drip.state.creator.*;
  17. import org.drip.state.discount.*;
  18. import org.drip.state.forward.ForwardCurve;
  19. import org.drip.state.identifier.ForwardLabel;

  20. /*
  21.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  22.  */

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

  68. /**
  69.  * ForwardDerivedBasisSensitivity contains the sample demonstrating the full functionality behind creating
  70.  *  highly customized spline based forward curves.
  71.  *
  72.  * The first sample illustrates the creation and usage of the xM-6M Tenor Basis Swap:
  73.  *  - Construct the 6M-xM float-float basis swap.
  74.  *  - Calculate the corresponding starting forward rate off of the discount curve.
  75.  *  - Construct the shape preserving forward curve off of Cubic Polynomial Basis Spline.
  76.  *  - Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  77.  *  - Construct the shape preserving forward curve off of Hyperbolic Tension Based Basis Spline.
  78.  *  - Set the discount curve based component market parameters.
  79.  *  - Set the discount curve + cubic polynomial forward curve based component market parameters.
  80.  *  - Set the discount curve + quartic polynomial forward curve based component market parameters.
  81.  *  - Set the discount curve + hyperbolic tension forward curve based component market parameters.
  82.  *  - Compute the following forward curve metrics for each of cubic polynomial forward, quartic
  83.  *      polynomial forward, and KLK Hyperbolic tension forward curves:
  84.  *      - Reference Basis Par Spread
  85.  *      - Derived Basis Par Spread
  86.  *  - Compare these with a) the forward rate off of the discount curve, b) The LIBOR rate, and c) The
  87.  *      Input Basis Swap Quote.
  88.  *
  89.  * The second sample illustrates how to build and test the forward curves across various tenor basis. It
  90.  *  shows the following steps:
  91.  *  - Construct the Discount Curve using its instruments and quotes.
  92.  *  - Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  93.  *  - Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  94.  *  - Build and run the sampling for the 6M-6M Tenor Basis Swap from its instruments and quotes.
  95.  *  - Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  96.  *
  97.  * @author Lakshmi Krishnamurthy
  98.  */

  99. public class ForwardDerivedBasisSensitivity {

  100.     private static final FixFloatComponent OTCFixFloat (
  101.         final JulianDate dtSpot,
  102.         final String strCurrency,
  103.         final String strMaturityTenor,
  104.         final double dblCoupon)
  105.     {
  106.         FixedFloatSwapConvention ffConv = IBORFixedFloatContainer.ConventionFromJurisdiction (
  107.             strCurrency,
  108.             "ALL",
  109.             strMaturityTenor,
  110.             "MAIN"
  111.         );

  112.         return ffConv.createFixFloatComponent (
  113.             dtSpot,
  114.             strMaturityTenor,
  115.             dblCoupon,
  116.             0.,
  117.             1.
  118.         );
  119.     }

  120.     private static final FloatFloatComponent OTCFloatFloat (
  121.         final JulianDate dtSpot,
  122.         final String strCurrency,
  123.         final String strDerivedTenor,
  124.         final String strMaturityTenor,
  125.         final double dblBasis)
  126.     {
  127.         FloatFloatSwapConvention ffConv = IBORFloatFloatContainer.ConventionFromJurisdiction (strCurrency);

  128.         return ffConv.createFloatFloatComponent (
  129.             dtSpot,
  130.             strDerivedTenor,
  131.             strMaturityTenor,
  132.             dblBasis,
  133.             1.
  134.         );
  135.     }

  136.     /*
  137.      * Construct the Array of Deposit Instruments from the given set of parameters
  138.      *
  139.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  140.      */

  141.     private static final CalibratableComponent[] DepositInstrumentsFromMaturityDays (
  142.         final JulianDate dtEffective,
  143.         final int[] aiDay,
  144.         final int iNumFutures,
  145.         final String strCurrency)
  146.         throws Exception
  147.     {
  148.         CalibratableComponent[] aCalibComp = new CalibratableComponent[aiDay.length + iNumFutures];

  149.         for (int i = 0; i < aiDay.length; ++i)
  150.             aCalibComp[i] = SingleStreamComponentBuilder.Deposit (
  151.                 dtEffective,
  152.                 dtEffective.addBusDays (
  153.                     aiDay[i],
  154.                     strCurrency
  155.                 ),
  156.                 ForwardLabel.Create (
  157.                     strCurrency,
  158.                     aiDay[i] + "D"
  159.                 )
  160.             );

  161.         CalibratableComponent[] aEDF = SingleStreamComponentBuilder.ForwardRateFuturesPack (
  162.             dtEffective,
  163.             iNumFutures,
  164.             strCurrency
  165.         );

  166.         for (int i = aiDay.length; i < aiDay.length + iNumFutures; ++i)
  167.             aCalibComp[i] = aEDF[i - aiDay.length];

  168.         return aCalibComp;
  169.     }

  170.     /*
  171.      * Construct the Array of Swap Instruments from the given set of parameters
  172.      *
  173.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  174.      */

  175.     private static final FixFloatComponent[] SwapInstrumentsFromMaturityTenor (
  176.         final JulianDate dtSpot,
  177.         final String strCurrency,
  178.         final String[] astrMaturityTenor,
  179.         final double[] adblCoupon)
  180.         throws Exception
  181.     {
  182.         FixFloatComponent[] aIRS = new FixFloatComponent[astrMaturityTenor.length];

  183.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  184.             aIRS[i] = OTCFixFloat (
  185.                 dtSpot,
  186.                 strCurrency,
  187.                 astrMaturityTenor[i],
  188.                 adblCoupon[i]
  189.             );

  190.         return aIRS;
  191.     }

  192.     /*
  193.      * Construct the discount curve using the following steps:
  194.      *  - Construct the array of cash instruments and their quotes.
  195.      *  - Construct the array of swap instruments and their quotes.
  196.      *  - Construct a shape preserving and smoothing KLK Hyperbolic Spline from the cash/swap instruments.
  197.      *
  198.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  199.      */

  200.     private static final MergedDiscountForwardCurve MakeDC (
  201.         final JulianDate dtSpot,
  202.         final String strCurrency)
  203.         throws Exception
  204.     {
  205.         /*
  206.          * Construct the array of Deposit instruments and their quotes.
  207.          */

  208.         CalibratableComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  209.             dtSpot,
  210.             new int[] {
  211.             },
  212.             0,
  213.             strCurrency
  214.         );

  215.         double[] adblDepositQuote = new double[] {
  216.         };

  217.         /*
  218.          * Construct the array of Swap instruments and their quotes.
  219.          */

  220.         double[] adblSwapQuote = new double[] {
  221.             0.0009875,   //  9M
  222.             0.00122,     //  1Y
  223.             0.00223,     // 18M
  224.             0.00383,     //  2Y
  225.             0.00827,     //  3Y
  226.             0.01245,     //  4Y
  227.             0.01605,     //  5Y
  228.             0.02597      // 10Y
  229.         };

  230.         String[] astrSwapManifestMeasure = new String[] {
  231.             "SwapRate",     //  9M
  232.             "SwapRate",     //  1Y
  233.             "SwapRate",     // 18M
  234.             "SwapRate",     //  2Y
  235.             "SwapRate",     //  3Y
  236.             "SwapRate",     //  4Y
  237.             "SwapRate",     //  5Y
  238.             "SwapRate"      // 10Y
  239.         };

  240.         CalibratableComponent[] aSwapComp = SwapInstrumentsFromMaturityTenor (
  241.             dtSpot,
  242.             strCurrency,
  243.             new java.lang.String[] {
  244.                 "9M",
  245.                 "1Y",
  246.                 "18M",
  247.                 "2Y",
  248.                 "3Y",
  249.                 "4Y",
  250.                 "5Y",
  251.                 "10Y"
  252.             },
  253.             adblSwapQuote
  254.         );

  255.         /*
  256.          * Construct a shape preserving and smoothing KLK Hyperbolic Spline from the cash/swap instruments.
  257.          */

  258.         return ScenarioDiscountCurveBuilder.CubicKLKHyperbolicDFRateShapePreserver (
  259.             "KLK_HYPERBOLIC_SHAPE_TEMPLATE",
  260.             new ValuationParams (
  261.                 dtSpot,
  262.                 dtSpot,
  263.                 strCurrency
  264.             ),
  265.             aDepositComp,
  266.             adblDepositQuote,
  267.             null,
  268.             aSwapComp,
  269.             adblSwapQuote,
  270.             astrSwapManifestMeasure,
  271.             false
  272.         );
  273.     }

  274.     /*
  275.      * Construct an array of float-float swaps from the corresponding reference (6M) and the derived legs.
  276.      *
  277.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  278.      */

  279.     private static final FloatFloatComponent[] MakexM6MBasisSwap (
  280.         final JulianDate dtSpot,
  281.         final String strCurrency,
  282.         final String[] astrMaturityTenor,
  283.         final int iTenorInMonths)
  284.         throws Exception
  285.     {
  286.         FloatFloatComponent[] aFFC = new FloatFloatComponent[astrMaturityTenor.length];

  287.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  288.             aFFC[i] = OTCFloatFloat (
  289.                 dtSpot,
  290.                 strCurrency,
  291.                 iTenorInMonths + "M",
  292.                 astrMaturityTenor[i],
  293.                 0.
  294.             );

  295.         return aFFC;
  296.     }

  297.     private static final void ForwardJack (
  298.         final JulianDate dt,
  299.         final Map<String, ForwardCurve> mapForward,
  300.         final String strStartDateTenor)
  301.     {
  302.         for (Map.Entry<String, ForwardCurve> me : mapForward.entrySet())
  303.             System.out.println (me.getKey() + " | " + strStartDateTenor + ": " +
  304.                 me.getValue().jackDForwardDManifestMeasure (
  305.                     "PV",
  306.                     dt.addTenor (strStartDateTenor)).displayString()
  307.                 );
  308.     }

  309.     private static final void ForwardJack (
  310.         final JulianDate dt,
  311.         final Map<String, ForwardCurve> mapForward)
  312.     {
  313.         ForwardJack (dt, mapForward, "1Y");

  314.         ForwardJack (dt, mapForward, "2Y");

  315.         ForwardJack (dt, mapForward, "3Y");

  316.         ForwardJack (dt, mapForward, "5Y");

  317.         ForwardJack (dt, mapForward, "7Y");
  318.     }

  319.     /*
  320.      * This sample illustrates the creation and usage of the xM-6M Tenor Basis Swap. It shows the following:
  321.      *  - Construct the 6M-xM float-float basis swap.
  322.      *  - Calculate the corresponding starting forward rate off of the discount curve.
  323.      *  - Construct the shape preserving forward curve off of Cubic Polynomial Basis Spline.
  324.      *  - Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  325.      *  - Construct the shape preserving forward curve off of Hyperbolic Tension Based Basis Spline.
  326.      *  - Set the discount curve based component market parameters.
  327.      *  - Set the discount curve + cubic polynomial forward curve based component market parameters.
  328.      *  - Set the discount curve + quartic polynomial forward curve based component market parameters.
  329.      *  - Set the discount curve + hyperbolic tension forward curve based component market parameters.
  330.      *  - Compute the following forward curve metrics for each of cubic polynomial forward, quartic
  331.      *      polynomial forward, and KLK Hyperbolic tension forward curves:
  332.      *      - Reference Basis Par Spread
  333.      *      - Derived Basis Par Spread
  334.      *  - Compare these with a) the forward rate off of the discount curve, b) The LIBOR rate, and c) The
  335.      *      Input Basis Swap Quote.
  336.      *
  337.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  338.      */

  339.     private static final Map<String, ForwardCurve> xM6MBasisSample (
  340.         final JulianDate dtSpot,
  341.         final String strCurrency,
  342.         final MergedDiscountForwardCurve dc,
  343.         final int iTenorInMonths,
  344.         final String[] astrxM6MFwdTenor,
  345.         final double[] adblxM6MBasisSwapQuote)
  346.         throws Exception
  347.     {
  348.         System.out.println ("------------------------------------------------------------");

  349.         System.out.println (" SPL =>              n=4               |         |         |");

  350.         System.out.println ("---------------------------------------|  LOG DF |  LIBOR  |");

  351.         System.out.println (" MSR =>  RECALC  |  REFEREN |  DERIVED |         |         |");

  352.         System.out.println ("------------------------------------------------------------");

  353.         /*
  354.          * Construct the 6M-xM float-float basis swap.
  355.          */

  356.         FloatFloatComponent[] aFFC = MakexM6MBasisSwap (
  357.             dtSpot,
  358.             strCurrency,
  359.             astrxM6MFwdTenor,
  360.             iTenorInMonths
  361.         );

  362.         String strBasisTenor = iTenorInMonths + "M";

  363.         ValuationParams valParams = new ValuationParams (
  364.             dtSpot,
  365.             dtSpot,
  366.             strCurrency
  367.         );

  368.         /*
  369.          * Calculate the starting forward rate off of the discount curve.
  370.          */

  371.         double dblStartingFwd = dc.forward (
  372.             dtSpot.julian(),
  373.             dtSpot.addTenor (strBasisTenor).julian()
  374.         );

  375.         /*
  376.          * Set the discount curve based component market parameters.
  377.          */

  378.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  379.             dc,
  380.             null,
  381.             null,
  382.             null,
  383.             null,
  384.             null,
  385.             null
  386.         );

  387.         Map<String, ForwardCurve> mapForward = new HashMap<String, ForwardCurve>();

  388.         /*
  389.          * Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  390.          */

  391.         ForwardCurve fcxMQuartic = ScenarioForwardCurveBuilder.ShapePreservingForwardCurve (
  392.             "QUARTIC_FWD" + strBasisTenor,
  393.             ForwardLabel.Create (
  394.                 strCurrency,
  395.                 strBasisTenor
  396.             ),
  397.             valParams,
  398.             null,
  399.             mktParams,
  400.             null,
  401.             MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  402.             new PolynomialFunctionSetParams (5),
  403.             aFFC,
  404.             "ReferenceParBasisSpread",
  405.             adblxM6MBasisSwapQuote,
  406.             dblStartingFwd
  407.         );

  408.         mapForward.put (
  409.             " QUARTIC_FWD" + strBasisTenor,
  410.             fcxMQuartic
  411.         );

  412.         /*
  413.          * Set the discount curve + quartic polynomial forward curve based component market parameters.
  414.          */

  415.         CurveSurfaceQuoteContainer mktParamsQuarticFwd = MarketParamsBuilder.Create (
  416.             dc,
  417.             fcxMQuartic,
  418.             null,
  419.             null,
  420.             null,
  421.             null,
  422.             null,
  423.             null
  424.         );

  425.         int i = 0;
  426.         int iFreq = 12 / iTenorInMonths;

  427.         /*
  428.          * Compute the following forward curve metrics for each of cubic polynomial forward, quartic
  429.          *  polynomial forward, and KLK Hyperbolic tension forward curves:
  430.          *  - Reference Basis Par Spread
  431.          *  - Derived Basis Par Spread
  432.          *
  433.          * Further compare these with a) the forward rate off of the discount curve, b) the LIBOR rate, and
  434.          *  c) Input Basis Swap Quote.
  435.          */

  436.         for (String strMaturityTenor : astrxM6MFwdTenor) {
  437.             int iFwdEndDate = dtSpot.addTenor (strMaturityTenor).julian();

  438.             int iFwdStartDate = dtSpot.addTenor (strMaturityTenor).subtractTenor (strBasisTenor).julian();

  439.             FloatFloatComponent ffc = aFFC[i++];

  440.             CaseInsensitiveTreeMap<Double> mapQuarticValue = ffc.value (
  441.                 valParams,
  442.                 null,
  443.                 mktParamsQuarticFwd,
  444.                 null
  445.             );

  446.             System.out.println (" " + strMaturityTenor + " =>  " +
  447.                 FormatUtil.FormatDouble (fcxMQuartic.forward (strMaturityTenor), 2, 2, 100.) + "  |  " +
  448.                 FormatUtil.FormatDouble (mapQuarticValue.get ("ReferenceParBasisSpread"), 2, 2, 1.) + "  |  " +
  449.                 FormatUtil.FormatDouble (mapQuarticValue.get ("DerivedParBasisSpread"), 2, 2, 1.) + "  |  " +
  450.                 FormatUtil.FormatDouble (iFreq * java.lang.Math.log (dc.df (iFwdStartDate) / dc.df (iFwdEndDate)), 1, 2, 100.) + "  |  " +
  451.                 FormatUtil.FormatDouble (dc.libor (iFwdStartDate, iFwdEndDate), 1, 2, 100.) + "  |  "
  452.             );
  453.         }

  454.         return mapForward;
  455.     }

  456.     /*
  457.      * This sample illustrates how to build and test the forward curves across various tenor basis. It shows
  458.      *  the following steps:
  459.      *  - Construct the Discount Curve using its instruments and quotes.
  460.      *  - Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  461.      *  - Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  462.      *  - Build and run the sampling for the 6M-6M Tenor Basis Swap from its instruments and quotes.
  463.      *  - Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  464.      *
  465.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  466.      */

  467.     private static final void CustomForwardCurveBuilderSample()
  468.         throws Exception
  469.     {
  470.         /*
  471.          * Initialize the Credit Analytics Library
  472.          */

  473.         EnvManager.InitEnv ("");

  474.         String strCurrency = "AUD";

  475.         JulianDate dtToday = DateUtil.Today().addTenor ("0D");

  476.         /*
  477.          * Construct the Discount Curve using its instruments and quotes
  478.          */

  479.         MergedDiscountForwardCurve dc = MakeDC (
  480.             dtToday,
  481.             strCurrency
  482.         );

  483.         System.out.println ("\n------------------------------------------------------------");

  484.         System.out.println ("-------------------    1M-6M Basis Swap    -----------------");

  485.         /*
  486.          * Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  487.          */

  488.         Map<String, ForwardCurve> mapForward1M6M = xM6MBasisSample (
  489.             dtToday,
  490.             strCurrency,
  491.             dc,
  492.             1,
  493.             new String[] {
  494.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  495.             },
  496.             new double[] {
  497.                 0.00551,    //  1Y
  498.                 0.00387,    //  2Y
  499.                 0.00298,    //  3Y
  500.                 0.00247,    //  4Y
  501.                 0.00211,    //  5Y
  502.                 0.00185,    //  6Y
  503.                 0.00165,    //  7Y
  504.                 0.00150,    //  8Y
  505.                 0.00137,    //  9Y
  506.                 0.00127,    // 10Y
  507.                 0.00119,    // 11Y
  508.                 0.00112,    // 12Y
  509.                 0.00096,    // 15Y
  510.                 0.00079,    // 20Y
  511.                 0.00069,    // 25Y
  512.                 0.00062     // 30Y
  513.             }
  514.         );

  515.         /*
  516.          * Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  517.          */

  518.         System.out.println ("\n------------------------------------------------------------");

  519.         System.out.println ("-------------------    3M-6M Basis Swap    -----------------");

  520.         Map<String, ForwardCurve> mapForward3M6M = xM6MBasisSample (
  521.             dtToday,
  522.             strCurrency,
  523.             dc,
  524.             3,
  525.             new String[] {
  526.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  527.             },
  528.             new double[] {
  529.                 0.00186,    //  1Y
  530.                 0.00127,    //  2Y
  531.                 0.00097,    //  3Y
  532.                 0.00080,    //  4Y
  533.                 0.00067,    //  5Y
  534.                 0.00058,    //  6Y
  535.                 0.00051,    //  7Y
  536.                 0.00046,    //  8Y
  537.                 0.00042,    //  9Y
  538.                 0.00038,    // 10Y
  539.                 0.00035,    // 11Y
  540.                 0.00033,    // 12Y
  541.                 0.00028,    // 15Y
  542.                 0.00022,    // 20Y
  543.                 0.00020,    // 25Y
  544.                 0.00018     // 30Y
  545.             }
  546.         );

  547.         /*
  548.          * Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  549.          */

  550.         System.out.println ("\n------------------------------------------------------------");

  551.         System.out.println ("-------------------   12M-6M Basis Swap    -----------------");

  552.         Map<String, ForwardCurve> mapForward12M6M = xM6MBasisSample (
  553.             dtToday,
  554.             strCurrency,
  555.             dc,
  556.             12,
  557.             new String[] {
  558.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y"
  559.             },
  560.             new double[] {
  561.                 -0.00212,    //  1Y
  562.                 -0.00152,    //  2Y
  563.                 -0.00117,    //  3Y
  564.                 -0.00097,    //  4Y
  565.                 -0.00082,    //  5Y
  566.                 -0.00072,    //  6Y
  567.                 -0.00063,    //  7Y
  568.                 -0.00057,    //  8Y
  569.                 -0.00051,    //  9Y
  570.                 -0.00047,    // 10Y
  571.                 -0.00044,    // 11Y
  572.                 -0.00041,    // 12Y
  573.                 -0.00035,    // 15Y
  574.                 -0.00028,    // 20Y
  575.                 -0.00025,    // 25Y
  576.                 -0.00022,    // 30Y
  577.                 -0.00022,    // 35Y Extrapolated
  578.                 -0.00022,    // 40Y Extrapolated
  579.             }
  580.         );

  581.         System.out.println ("\n--------------------------------------------------------------------------------------------------------------------------------------------");

  582.         System.out.println ("------------------------------------------------------- 1M-6M Micro Jack -------------------------------------------------------------------");

  583.         System.out.println ("--------------------------------------------------------------------------------------------------------------------------------------------\n");

  584.         ForwardJack (
  585.             dtToday,
  586.             mapForward1M6M
  587.         );

  588.         System.out.println ("\n--------------------------------------------------------------------------------------------------------------------------------------------");

  589.         System.out.println ("------------------------------------------------------- 3M-6M Micro Jack -------------------------------------------------------------------");

  590.         System.out.println ("--------------------------------------------------------------------------------------------------------------------------------------------\n");

  591.         ForwardJack (
  592.             dtToday,
  593.             mapForward3M6M
  594.         );

  595.         System.out.println ("\n--------------------------------------------------------------------------------------------------------------------------------------------");

  596.         System.out.println ("------------------------------------------------------ 12M-6M Micro Jack -------------------------------------------------------------------");

  597.         System.out.println ("--------------------------------------------------------------------------------------------------------------------------------------------\n");

  598.         ForwardJack (
  599.             dtToday,
  600.             mapForward12M6M
  601.         );
  602.     }

  603.     public static final void main (
  604.         final String[] astrArgs)
  605.         throws Exception
  606.     {
  607.         CustomForwardCurveBuilderSample();
  608.     }
  609. }