ForwardReferenceBasisSensitivity.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.  * ForwardReferenceBasisSensitivity 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 ForwardReferenceBasisSensitivity {

  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.         final double dblBump)
  204.         throws Exception
  205.     {
  206.         /*
  207.          * Construct the array of Deposit instruments and their quotes.
  208.          */

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

  215.         double[] adblDepositQuote = new double[] {}; // Futures

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

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

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

  239.         CalibratableComponent[] aSwapComp = SwapInstrumentsFromMaturityTenor (
  240.             dtSpot,
  241.             strCurrency,
  242.             new java.lang.String[] {
  243.                 "9M", "1Y", "18M", "2Y", "3Y", "4Y", "5Y", "10Y"
  244.             },
  245.             new double[] {
  246.                 0.0009875, 0.00122, 0.00223, 0.00383, 0.00827, 0.01245, 0.01605, 0.02597
  247.             }
  248.         );

  249.         /*
  250.          * Construct a shape preserving and smoothing KLK Hyperbolic Spline from the cash/swap instruments.
  251.          */

  252.         return ScenarioDiscountCurveBuilder.CubicKLKHyperbolicDFRateShapePreserver (
  253.             "KLK_HYPERBOLIC_SHAPE_TEMPLATE",
  254.             new ValuationParams (
  255.                 dtSpot,
  256.                 dtSpot,
  257.                 strCurrency
  258.             ),
  259.             aDepositComp,
  260.             adblDepositQuote,
  261.             null,
  262.             aSwapComp,
  263.             adblSwapQuote,
  264.             astrSwapManifestMeasure,
  265.             false
  266.         );
  267.     }

  268.     /*
  269.      * Construct an array of float-float swaps from the corresponding reference (6M) and the derived legs.
  270.      *
  271.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  272.      */

  273.     private static final FloatFloatComponent[] MakexM6MBasisSwap (
  274.         final JulianDate dtSpot,
  275.         final String strCurrency,
  276.         final String[] astrMaturityTenor,
  277.         final int iTenorInMonths)
  278.         throws Exception
  279.     {
  280.         FloatFloatComponent[] aFFC = new FloatFloatComponent[astrMaturityTenor.length];

  281.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  282.             aFFC[i] = OTCFloatFloat (
  283.                 dtSpot,
  284.                 strCurrency,
  285.                 iTenorInMonths + "M",
  286.                 astrMaturityTenor[i],
  287.                 0.
  288.             );

  289.         return aFFC;
  290.     }

  291.     private static final void ForwardJack (
  292.         final JulianDate dt,
  293.         final Map<String, ForwardCurve> mapForward,
  294.         final String strStartDateTenor)
  295.     {
  296.         for (Map.Entry<String, ForwardCurve> me : mapForward.entrySet())
  297.             System.out.println (me.getKey() + " | " + strStartDateTenor + ": " +
  298.                 me.getValue().jackDForwardDManifestMeasure (
  299.                     "PV",
  300.                     dt.addTenor (strStartDateTenor)).displayString()
  301.                 );
  302.     }

  303.     private static final void ForwardJack (
  304.         final JulianDate dt,
  305.         final Map<String, ForwardCurve> mapForward)
  306.     {
  307.         ForwardJack (dt, mapForward, "1Y");

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

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

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

  311.         ForwardJack (dt, mapForward, "7Y");
  312.     }

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

  333.     private static final Map<String, ForwardCurve> xM6MBasisSample (
  334.         final JulianDate dtSpot,
  335.         final String strCurrency,
  336.         final MergedDiscountForwardCurve dc,
  337.         final int iTenorInMonths,
  338.         final String[] astrxM6MFwdTenor,
  339.         final double[] adblxM6MBasisSwapQuote)
  340.         throws Exception
  341.     {
  342.         System.out.println ("------------------------------------------------------------");

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

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

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

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

  347.         /*
  348.          * Construct the 6M-xM float-float basis swap.
  349.          */

  350.         FloatFloatComponent[] aFFC = MakexM6MBasisSwap (
  351.             dtSpot,
  352.             strCurrency,
  353.             astrxM6MFwdTenor,
  354.             iTenorInMonths
  355.         );

  356.         String strBasisTenor = iTenorInMonths + "M";

  357.         ValuationParams valParams = new ValuationParams (
  358.             dtSpot,
  359.             dtSpot,
  360.             strCurrency
  361.         );

  362.         /*
  363.          * Calculate the starting forward rate off of the discount curve.
  364.          */

  365.         double dblStartingFwd = dc.forward (
  366.             dtSpot.julian(),
  367.             dtSpot.addTenor (strBasisTenor).julian()
  368.         );

  369.         /*
  370.          * Set the discount curve based component market parameters.
  371.          */

  372.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  373.             dc,
  374.             null,
  375.             null,
  376.             null,
  377.             null,
  378.             null,
  379.             null
  380.         );

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

  382.         /*
  383.          * Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  384.          */

  385.         ForwardCurve fcxMQuartic = ScenarioForwardCurveBuilder.ShapePreservingForwardCurve (
  386.             "QUARTIC_FWD" + strBasisTenor,
  387.             ForwardLabel.Create (
  388.                 strCurrency,
  389.                 strBasisTenor
  390.             ),
  391.             valParams,
  392.             null,
  393.             mktParams,
  394.             null,
  395.             MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  396.             new PolynomialFunctionSetParams (5),
  397.             aFFC,
  398.             "ReferenceParBasisSpread",
  399.             adblxM6MBasisSwapQuote,
  400.             dblStartingFwd
  401.         );

  402.         mapForward.put (
  403.             " QUARTIC_FWD" + strBasisTenor,
  404.             fcxMQuartic
  405.         );

  406.         /*
  407.          * Set the discount curve + quartic polynomial forward curve based component market parameters.
  408.          */

  409.         CurveSurfaceQuoteContainer mktParamsQuarticFwd = MarketParamsBuilder.Create (
  410.             dc,
  411.             fcxMQuartic,
  412.             null,
  413.             null,
  414.             null,
  415.             null,
  416.             null,
  417.             null
  418.         );

  419.         int i = 0;
  420.         int iFreq = 12 / iTenorInMonths;

  421.         /*
  422.          * Compute the following forward curve metrics for each of cubic polynomial forward, quartic
  423.          *  polynomial forward, and KLK Hyperbolic tension forward curves:
  424.          *  - Reference Basis Par Spread
  425.          *  - Derived Basis Par Spread
  426.          *
  427.          * Further compare these with a) the forward rate off of the discount curve, b) the LIBOR rate, and
  428.          *  c) Input Basis Swap Quote.
  429.          */

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

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

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

  434.             CaseInsensitiveTreeMap<Double> mapQuarticValue = ffc.value (
  435.                 valParams,
  436.                 null,
  437.                 mktParamsQuarticFwd,
  438.                 null
  439.             );

  440.             System.out.println (" " + strMaturityTenor + " =>  " +
  441.                 FormatUtil.FormatDouble (fcxMQuartic.forward (strMaturityTenor), 2, 2, 100.) + "  |  " +
  442.                 FormatUtil.FormatDouble (mapQuarticValue.get ("ReferenceParBasisSpread"), 2, 2, 1.) + "  |  " +
  443.                 FormatUtil.FormatDouble (mapQuarticValue.get ("DerivedParBasisSpread"), 2, 2, 1.) + "  |  " +
  444.                 FormatUtil.FormatDouble (iFreq * java.lang.Math.log (dc.df (iFwdStartDate) / dc.df (iFwdEndDate)), 1, 2, 100.) + "  |  " +
  445.                 FormatUtil.FormatDouble (dc.libor (iFwdStartDate, iFwdEndDate), 1, 2, 100.) + "  |  "
  446.             );
  447.         }

  448.         return mapForward;
  449.     }

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

  461.     private static final void CustomForwardCurveBuilderSample()
  462.         throws Exception
  463.     {
  464.         /*
  465.          * Initialize the Credit Analytics Library
  466.          */

  467.         EnvManager.InitEnv ("");

  468.         String strCurrency = "AUD";

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

  470.         /*
  471.          * Construct the Discount Curve using its instruments and quotes
  472.          */

  473.         MergedDiscountForwardCurve dc = MakeDC (
  474.             dtToday,
  475.             strCurrency,
  476.             0.
  477.         );

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

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

  480.         /*
  481.          * Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  482.          */

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

  510.         /*
  511.          * Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  512.          */

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

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

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

  542.         /*
  543.          * Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  544.          */

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

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

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

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

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

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

  579.         ForwardJack (
  580.             dtToday,
  581.             mapForward1M6M
  582.         );

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

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

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

  586.         ForwardJack (
  587.             dtToday,
  588.             mapForward3M6M
  589.         );

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

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

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

  593.         ForwardJack (
  594.             dtToday,
  595.             mapForward12M6M
  596.         );
  597.     }

  598.     public static final void main (
  599.         final String[] astrArgs)
  600.         throws Exception
  601.     {
  602.         CustomForwardCurveBuilderSample();
  603.     }
  604. }