ShapeOvernightZeroLocalSmooth.java

  1. package org.drip.sample.overnight;

  2. import java.util.List;

  3. import org.drip.analytics.date.*;
  4. import org.drip.analytics.definition.LatentStateStatic;
  5. import org.drip.analytics.support.*;
  6. import org.drip.function.r1tor1.QuadraticRationalShapeControl;
  7. import org.drip.market.otc.*;
  8. import org.drip.numerical.common.FormatUtil;
  9. import org.drip.param.creator.*;
  10. import org.drip.param.period.*;
  11. import org.drip.param.valuation.*;
  12. import org.drip.product.creator.*;
  13. import org.drip.product.definition.CalibratableComponent;
  14. import org.drip.product.rates.*;
  15. import org.drip.service.env.EnvManager;
  16. import org.drip.spline.basis.*;
  17. import org.drip.spline.params.*;
  18. import org.drip.spline.pchip.LocalMonotoneCkGenerator;
  19. import org.drip.spline.stretch.*;
  20. import org.drip.state.creator.ScenarioDiscountCurveBuilder;
  21. import org.drip.state.discount.*;
  22. import org.drip.state.estimator.*;
  23. import org.drip.state.identifier.*;
  24. import org.drip.state.inference.*;

  25. /*
  26.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  27.  */

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

  72. /**
  73.  * ShapeOvernightZeroLocalSmooth demonstrates the usage of different local smoothing techniques involved in
  74.  *  the Overnight curve creation. It shows the following:
  75.  *  - Construct the Array of Deposit/OIS Instruments and their Quotes from the given set of parameters.
  76.  *  - Construct the Deposit/OIS Instrument Set Stretch Builder.
  77.  *  - Set up the Linear Curve Calibrator using the following parameters:
  78.  *      - Cubic Exponential Mixture Basis Spline Set
  79.  *      - Ck = 2, Segment Curvature Penalty = 2
  80.  *      - Quadratic Rational Shape Controller
  81.  *      - Natural Boundary Setting
  82.  *  - Set up the Akima Local Curve Control parameters as follows:
  83.  *      - C1 Akima Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  84.  *      - Zero Rate Quantification Metric
  85.  *      - Cubic Polynomial Basis Spline Set
  86.  *      - Ck = 2, Segment Curvature Penalty = 2
  87.  *      - Quadratic Rational Shape Controller
  88.  *      - Natural Boundary Setting
  89.  *  - Set up the Harmonic Local Curve Control parameters as follows:
  90.  *      - C1 Harmonic Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  91.  *      - Zero Rate Quantification Metric
  92.  *      - Cubic Polynomial Basis Spline Set
  93.  *      - Ck = 2, Segment Curvature Penalty = 2
  94.  *      - Quadratic Rational Shape Controller
  95.  *      - Natural Boundary Setting
  96.  *  - Set up the Hyman 1983 Local Curve Control parameters as follows:
  97.  *      - C1 Hyman 1983 Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  98.  *      - Zero Rate Quantification Metric
  99.  *      - Cubic Polynomial Basis Spline Set
  100.  *      - Ck = 2, Segment Curvature Penalty = 2
  101.  *      - Quadratic Rational Shape Controller
  102.  *      - Natural Boundary Setting
  103.  *  - Set up the Hyman 1989 Local Curve Control parameters as follows:
  104.  *      - C1 Akima Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  105.  *      - Zero Rate Quantification Metric
  106.  *      - Cubic Polynomial Basis Spline Set
  107.  *      - Ck = 2, Segment Curvature Penalty = 2
  108.  *      - Quadratic Rational Shape Controller
  109.  *      - Natural Boundary Setting
  110.  *  - Set up the Huynh-Le Floch Delimited Local Curve Control parameters as follows:
  111.  *      - C1 Huynh-Le Floch Delimited Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  112.  *      - Zero Rate Quantification Metric
  113.  *      - Cubic Polynomial Basis Spline Set
  114.  *      - Ck = 2, Segment Curvature Penalty = 2
  115.  *      - Quadratic Rational Shape Controller
  116.  *      - Natural Boundary Setting
  117.  *  - Set up the Kruger Local Curve Control parameters as follows:
  118.  *      - C1 Kruger Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  119.  *      - Zero Rate Quantification Metric
  120.  *      - Cubic Polynomial Basis Spline Set
  121.  *      - Ck = 2, Segment Curvature Penalty = 2
  122.  *      - Quadratic Rational Shape Controller
  123.  *      - Natural Boundary Setting
  124.  *  - Construct the Shape Preserving OIS Discount Curve by applying the linear curve calibrator to the array
  125.  *      of Deposit and OIS Stretches.
  126.  *  - Construct the Akima Locally Smoothened OIS Discount Curve by applying the linear curve calibrator and
  127.  *      the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  128.  *      preserving discount curve.
  129.  *  - Construct the Harmonic Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  130.  *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  131.  *      preserving discount curve.
  132.  *  - Construct the Hyman 1983 Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  133.  *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  134.  *      preserving discount curve.
  135.  *  - Construct the Hyman 1989 Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  136.  *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  137.  *      preserving discount curve.
  138.  *  - Construct the Huynh-Le Floch Delimiter Locally Smoothened OIS Discount Curve by applying the linear
  139.  *      curve calibrator and the Local Curve Control parameters to the array of Deposit and OIS Stretches
  140.  *      and the shape preserving discount curve.
  141.  *  - Construct the Kruger Locally Smoothened OIS Discount Curve by applying the linear curve calibrator and
  142.  *      the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  143.  *      preserving discount curve.
  144.  *  - Cross-Comparison of the Deposit/OIS Calibration Instrument "Rate" metric across the different curve
  145.  *      construction methodologies.
  146.  *  - Cross-Comparison of the OIS Calibration Instrument "Rate" metric across the different curve
  147.  *      construction methodologies for a sequence of bespoke swap instruments.
  148.  *
  149.  * @author Lakshmi Krishnamurthy
  150.  */

  151. public class ShapeOvernightZeroLocalSmooth {

  152.     private static final FixFloatComponent OTCOISFixFloat (
  153.         final JulianDate dtSpot,
  154.         final String strCurrency,
  155.         final String strMaturityTenor,
  156.         final double dblCoupon)
  157.     {
  158.         FixedFloatSwapConvention ffConv = OvernightFixedFloatContainer.FundConventionFromJurisdiction (
  159.             strCurrency
  160.         );

  161.         return ffConv.createFixFloatComponent (
  162.             dtSpot,
  163.             strMaturityTenor,
  164.             dblCoupon,
  165.             0.,
  166.             1.
  167.         );
  168.     }

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

  174.     private static final SingleStreamComponent[] DepositInstrumentsFromMaturityDays (
  175.         final JulianDate dtEffective,
  176.         final String strCurrency,
  177.         final int[] aiDay)
  178.         throws Exception
  179.     {
  180.         SingleStreamComponent[] aDeposit = new SingleStreamComponent[aiDay.length];

  181.         for (int i = 0; i < aiDay.length; ++i)
  182.             aDeposit[i] = SingleStreamComponentBuilder.Deposit (
  183.                 dtEffective,
  184.                 dtEffective.addBusDays (
  185.                     aiDay[i],
  186.                     strCurrency
  187.                 ),
  188.                 OvernightLabel.Create (
  189.                     strCurrency
  190.                 )
  191.             );

  192.         return aDeposit;
  193.     }

  194.     /*
  195.      * Construct the Array of Overnight Index Instruments from the given set of parameters
  196.      *
  197.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  198.      */

  199.     private static final FixFloatComponent[] OvernightIndexFromMaturityTenor (
  200.         final JulianDate dtEffective,
  201.         final String[] astrMaturityTenor,
  202.         final double[] adblCoupon,
  203.         final String strCurrency)
  204.         throws Exception
  205.     {
  206.         FixFloatComponent[] aOIS = new FixFloatComponent[astrMaturityTenor.length];

  207.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  208.             2,
  209.             "Act/360",
  210.             false,
  211.             "Act/360",
  212.             false,
  213.             strCurrency,
  214.             false,
  215.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  216.         );

  217.         CashSettleParams csp = new CashSettleParams (
  218.             0,
  219.             strCurrency,
  220.             0
  221.         );

  222.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  223.             java.lang.String strFixedTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  224.                 astrMaturityTenor[i],
  225.                 "6M"
  226.             ) ? astrMaturityTenor[i] : "6M";

  227.             java.lang.String strFloatingTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  228.                 astrMaturityTenor[i],
  229.                 "3M"
  230.             ) ? astrMaturityTenor[i] : "3M";

  231.             ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  232.                 "ON",
  233.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_OVERNIGHT,
  234.                 null,
  235.                 OvernightLabel.Create (
  236.                     strCurrency
  237.                 ),
  238.                 CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  239.                 0.
  240.             );

  241.             ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  242.                 strFixedTenor,
  243.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  244.                 null,
  245.                 adblCoupon[i],
  246.                 0.,
  247.                 strCurrency
  248.             );

  249.             CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  250.                 4,
  251.                 strFloatingTenor,
  252.                 strCurrency,
  253.                 null,
  254.                 -1.,
  255.                 null,
  256.                 null,
  257.                 null,
  258.                 null
  259.             );

  260.             CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  261.                 2,
  262.                 strFixedTenor,
  263.                 strCurrency,
  264.                 null,
  265.                 1.,
  266.                 null,
  267.                 null,
  268.                 null,
  269.                 null
  270.             );

  271.             List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  272.                 dtEffective,
  273.                 strFixedTenor,
  274.                 astrMaturityTenor[i],
  275.                 null
  276.             );

  277.             List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  278.                 dtEffective,
  279.                 strFloatingTenor,
  280.                 astrMaturityTenor[i],
  281.                 null
  282.             );

  283.             Stream floatingStream = new Stream (
  284.                 CompositePeriodBuilder.FloatingCompositeUnit (
  285.                     lsFloatingStreamEdgeDate,
  286.                     cpsFloating,
  287.                     cfusFloating
  288.                 )
  289.             );

  290.             Stream fixedStream = new Stream (
  291.                 CompositePeriodBuilder.FixedCompositeUnit (
  292.                     lsFixedStreamEdgeDate,
  293.                     cpsFixed,
  294.                     ucasFixed,
  295.                     cfusFixed
  296.                 )
  297.             );

  298.             FixFloatComponent ois = new FixFloatComponent (
  299.                 fixedStream,
  300.                 floatingStream,
  301.                 csp
  302.             );

  303.             ois.setPrimaryCode ("OIS." + astrMaturityTenor[i] + "." + strCurrency);

  304.             aOIS[i] = ois;
  305.         }

  306.         return aOIS;
  307.     }

  308.     private static final FixFloatComponent[] OISFromMaturityTenor (
  309.         final JulianDate dtSpot,
  310.         final String strCurrency,
  311.         final String[] astrMaturityTenor,
  312.         final double[] adblCoupon)
  313.         throws Exception
  314.     {
  315.         FixFloatComponent[] aOIS = new FixFloatComponent[astrMaturityTenor.length];

  316.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  317.             aOIS[i] = OTCOISFixFloat (
  318.                 dtSpot,
  319.                 strCurrency,
  320.                 astrMaturityTenor[i],
  321.                 adblCoupon[i]
  322.             );

  323.         return aOIS;
  324.     }

  325.     /*
  326.      * Construct the Array of Overnight Index Future Instruments from the given set of parameters
  327.      *
  328.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  329.      */

  330.     private static final FixFloatComponent[] OISFuturesFromMaturityTenor (
  331.         final JulianDate dtSpot,
  332.         final String strCurrency,
  333.         final String[] astrStartTenor,
  334.         final String[] astrMaturityTenor,
  335.         final double[] adblCoupon)
  336.         throws Exception
  337.     {
  338.         FixFloatComponent[] aOISFutures = new FixFloatComponent[astrMaturityTenor.length];

  339.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  340.             aOISFutures[i] = OTCOISFixFloat (
  341.                 dtSpot.addTenor (astrStartTenor[i]),
  342.                 strCurrency,
  343.                 astrMaturityTenor[i],
  344.                 adblCoupon[i]
  345.             );

  346.         return aOISFutures;
  347.     }

  348.     /*
  349.      * This sample demonstrates the usage of different local smoothing techniques involved in the OIS discount
  350.      *  curve creation. It shows the following:
  351.      *  - Construct the Array of Deposit/OIS Instruments and their Quotes from the given set of parameters.
  352.      *  - Construct the Deposit/OIS Instrument Set Stretch Builder.
  353.      *  - Set up the Linear Curve Calibrator using the following parameters:
  354.      *      - Cubic Exponential Mixture Basis Spline Set
  355.      *      - Ck = 2, Segment Curvature Penalty = 2
  356.      *      - Quadratic Rational Shape Controller
  357.      *      - Natural Boundary Setting
  358.      *  - Set up the Akima Local Curve Control parameters as follows:
  359.      *      - C1 Akima Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  360.      *      - Zero Rate Quantification Metric
  361.      *      - Cubic Polynomial Basis Spline Set
  362.      *      - Ck = 2, Segment Curvature Penalty = 2
  363.      *      - Quadratic Rational Shape Controller
  364.      *      - Natural Boundary Setting
  365.      *  - Set up the Harmonic Local Curve Control parameters as follows:
  366.      *      - C1 Harmonic Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  367.      *      - Zero Rate Quantification Metric
  368.      *      - Cubic Polynomial Basis Spline Set
  369.      *      - Ck = 2, Segment Curvature Penalty = 2
  370.      *      - Quadratic Rational Shape Controller
  371.      *      - Natural Boundary Setting
  372.      *  - Set up the Hyman 1983 Local Curve Control parameters as follows:
  373.      *      - C1 Hyman 1983 Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  374.      *      - Zero Rate Quantification Metric
  375.      *      - Cubic Polynomial Basis Spline Set
  376.      *      - Ck = 2, Segment Curvature Penalty = 2
  377.      *      - Quadratic Rational Shape Controller
  378.      *      - Natural Boundary Setting
  379.      *  - Set up the Hyman 1989 Local Curve Control parameters as follows:
  380.      *      - C1 Akima Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  381.      *      - Zero Rate Quantification Metric
  382.      *      - Cubic Polynomial Basis Spline Set
  383.      *      - Ck = 2, Segment Curvature Penalty = 2
  384.      *      - Quadratic Rational Shape Controller
  385.      *      - Natural Boundary Setting
  386.      *  - Set up the Huynh-Le Floch Delimited Local Curve Control parameters as follows:
  387.      *      - C1 Huynh-Le Floch Delimited Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  388.      *      - Zero Rate Quantification Metric
  389.      *      - Cubic Polynomial Basis Spline Set
  390.      *      - Ck = 2, Segment Curvature Penalty = 2
  391.      *      - Quadratic Rational Shape Controller
  392.      *      - Natural Boundary Setting
  393.      *  - Set up the Kruger Local Curve Control parameters as follows:
  394.      *      - C1 Kruger Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  395.      *      - Zero Rate Quantification Metric
  396.      *      - Cubic Polynomial Basis Spline Set
  397.      *      - Ck = 2, Segment Curvature Penalty = 2
  398.      *      - Quadratic Rational Shape Controller
  399.      *      - Natural Boundary Setting
  400.      *  - Construct the Shape Preserving OIS Discount Curve by applying the linear curve calibrator to the array
  401.      *      of Deposit and OIS Stretches.
  402.      *  - Construct the Akima Locally Smoothened OIS Discount Curve by applying the linear curve calibrator and
  403.      *      the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  404.      *      preserving discount curve.
  405.      *  - Construct the Harmonic Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  406.      *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  407.      *      preserving discount curve.
  408.      *  - Construct the Hyman 1983 Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  409.      *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  410.      *      preserving discount curve.
  411.      *  - Construct the Hyman 1989 Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  412.      *      and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  413.      *      preserving discount curve.
  414.      *  - Construct the Huynh-Le Floch Delimiter Locally Smoothened OIS Discount Curve by applying the linear
  415.      *      curve calibrator and the Local Curve Control parameters to the array of Deposit and OIS Stretches
  416.      *      and the shape preserving discount curve.
  417.      *  - Construct the Kruger Locally Smoothened OIS Discount Curve by applying the linear curve calibrator and
  418.      *      the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  419.      *      preserving discount curve.
  420.      *  - Cross-Comparison of the Deposit/OIS Calibration Instrument "Rate" metric across the different curve
  421.      *      construction methodologies.
  422.      *  - Cross-Comparison of the OIS Calibration Instrument "Rate" metric across the different curve
  423.      *      construction methodologies for a sequence of bespoke OIS instruments.
  424.      *
  425.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  426.      */

  427.     private static final void ShapeOISDFZeroLocalSmoothSample (
  428.         final JulianDate dtSpot,
  429.         final String strHeaderComment,
  430.         final String strCurrency)
  431.         throws Exception
  432.     {
  433.         System.out.println ("\n\t----------------------------------------------------------------");

  434.         System.out.println ("\t" + strHeaderComment);

  435.         /*
  436.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  437.          */

  438.         SingleStreamComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  439.             dtSpot,
  440.             strCurrency,
  441.             new int[] {
  442.                 1, 2, 3
  443.             }
  444.         );

  445.         double[] adblDepositQuote = new double[] {
  446.             0.0004, 0.0004, 0.0004       // Deposit
  447.         };

  448.         /*
  449.          * Construct the Deposit Instrument Set Stretch Builder
  450.          */

  451.         LatentStateStretchSpec depositStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  452.             "   DEPOSIT   ",
  453.             aDepositComp,
  454.             "ForwardRate",
  455.             adblDepositQuote
  456.         );

  457.         /*
  458.          * Construct the Array of Short End OIS Instruments and their Quotes from the given set of parameters
  459.          */

  460.         double[] adblShortEndOISQuote = new double[] {
  461.             0.00070,    //   1W
  462.             0.00069,    //   2W
  463.             0.00078,    //   3W
  464.             0.00074     //   1M
  465.         };

  466.         CalibratableComponent[] aShortEndOISComp = OISFromMaturityTenor (
  467.             dtSpot,
  468.             strCurrency,
  469.             new java.lang.String[] {
  470.                 "1W", "2W", "3W", "1M"
  471.             },
  472.             adblShortEndOISQuote
  473.         );

  474.         /*
  475.          * Construct the Short End OIS Instrument Set Stretch Builder
  476.          */

  477.         LatentStateStretchSpec oisShortEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  478.             "SHORT END OIS",
  479.             aShortEndOISComp,
  480.             "SwapRate",
  481.             adblShortEndOISQuote
  482.         );

  483.         /*
  484.          * Construct the Array of OIS Futures Instruments and their Quotes from the given set of parameters
  485.          */

  486.         double[] adblOISFutureQuote = new double[] {
  487.              0.00046,    //   1M x 1M
  488.              0.00016,    //   2M x 1M
  489.             -0.00007,    //   3M x 1M
  490.             -0.00013,    //   4M x 1M
  491.             -0.00014     //   5M x 1M
  492.         };

  493.         CalibratableComponent[] aOISFutureComp = OISFuturesFromMaturityTenor (
  494.             dtSpot,
  495.             strCurrency,
  496.             new java.lang.String[] {
  497.                 "1M", "2M", "3M", "4M", "5M"
  498.             },
  499.             new java.lang.String[] {
  500.                 "1M", "1M", "1M", "1M", "1M"
  501.             },
  502.             adblOISFutureQuote
  503.         );

  504.         /*
  505.          * Construct the OIS Future Instrument Set Stretch Builder
  506.          */

  507.         LatentStateStretchSpec oisFutureStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  508.             " OIS FUTURE  ",
  509.             aOISFutureComp,
  510.             "SwapRate",
  511.             adblOISFutureQuote
  512.         );

  513.         /*
  514.          * Construct the Array of Long End OIS Instruments and their Quotes from the given set of parameters
  515.          */

  516.         double[] adblLongEndOISQuote = new double[] {
  517.             0.00002,    //  15M
  518.             0.00008,    //  18M
  519.             0.00021,    //  21M
  520.             0.00036,    //   2Y
  521.             0.00127,    //   3Y
  522.             0.00274,    //   4Y
  523.             0.00456,    //   5Y
  524.             0.00647,    //   6Y
  525.             0.00827,    //   7Y
  526.             0.00996,    //   8Y
  527.             0.01147,    //   9Y
  528.             0.01280,    //  10Y
  529.             0.01404,    //  11Y
  530.             0.01516,    //  12Y
  531.             0.01764,    //  15Y
  532.             0.01939,    //  20Y
  533.             0.02003,    //  25Y
  534.             0.02038     //  30Y
  535.         };

  536.         CalibratableComponent[] aLongEndOISComp = OISFromMaturityTenor (
  537.             dtSpot,
  538.             strCurrency,
  539.             new java.lang.String[] {
  540.                 "15M", "18M", "21M", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  541.             },
  542.             adblLongEndOISQuote
  543.         );

  544.         /*
  545.          * Construct the Long End OIS Instrument Set Stretch Builder
  546.          */

  547.         LatentStateStretchSpec oisLongEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  548.             "LONG END OIS ",
  549.             aLongEndOISComp,
  550.             "SwapRate",
  551.             adblLongEndOISQuote
  552.         );

  553.         LatentStateStretchSpec[] aStretchSpec = new LatentStateStretchSpec[] {
  554.             depositStretch,
  555.             oisShortEndStretch,
  556.             oisFutureStretch,
  557.             oisLongEndStretch
  558.         };

  559.         /*
  560.          * Set up the Linear Curve Calibrator using the following parameters:
  561.          *  - Cubic Exponential Mixture Basis Spline Set
  562.          *  - Ck = 2, Segment Curvature Penalty = 2
  563.          *  - Quadratic Rational Shape Controller
  564.          *  - Natural Boundary Setting
  565.          */

  566.         LinearLatentStateCalibrator lcc = new LinearLatentStateCalibrator (
  567.             new SegmentCustomBuilderControl (
  568.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_EXPONENTIAL_MIXTURE,
  569.                 new ExponentialMixtureSetParams (
  570.                     new double[] {
  571.                         0.01,
  572.                         0.05,
  573.                         0.25
  574.                     }
  575.                 ),
  576.                 SegmentInelasticDesignControl.Create (
  577.                     2,
  578.                     2
  579.                 ),
  580.                 new ResponseScalingShapeControl (
  581.                     true,
  582.                     new QuadraticRationalShapeControl (0.)
  583.                 ),
  584.                 null
  585.             ),
  586.             BoundarySettings.NaturalStandard(),
  587.             MultiSegmentSequence.CALIBRATE,
  588.             null,
  589.             null
  590.         );

  591.         /*
  592.          * Set up the Akima Local Curve Control parameters as follows:
  593.          *  - C1 Akima Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  594.          *  - Zero Rate Quantification Metric
  595.          *  - Cubic Polynomial Basis Spline Set
  596.          *  - Ck = 2, Segment Curvature Penalty = 2
  597.          *  - Quadratic Rational Shape Controller
  598.          *  - Natural Boundary Setting
  599.          */

  600.         LocalControlCurveParams lccpAkima = new LocalControlCurveParams (
  601.             LocalMonotoneCkGenerator.C1_AKIMA,
  602.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  603.             new SegmentCustomBuilderControl (
  604.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  605.                 new PolynomialFunctionSetParams (4),
  606.                 SegmentInelasticDesignControl.Create (
  607.                     2,
  608.                     2
  609.                 ),
  610.                 new ResponseScalingShapeControl (
  611.                     true,
  612.                     new QuadraticRationalShapeControl (0.)
  613.                 ),
  614.                 null
  615.             ),
  616.             MultiSegmentSequence.CALIBRATE,
  617.             null,
  618.             null,
  619.             true,
  620.             true
  621.         );

  622.         /*
  623.          * Set up the Harmonic Local Curve Control parameters as follows:
  624.          *  - C1 Harmonic Monotone Smoothener with spurious extrema elimination and monotone filtering
  625.          *      applied
  626.          *  - Zero Rate Quantification Metric
  627.          *  - Cubic Polynomial Basis Spline Set
  628.          *  - Ck = 2, Segment Curvature Penalty = 2
  629.          *  - Quadratic Rational Shape Controller
  630.          *  - Natural Boundary Setting
  631.          */

  632.         LocalControlCurveParams lccpHarmonic = new LocalControlCurveParams (
  633.             LocalMonotoneCkGenerator.C1_HARMONIC,
  634.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  635.             new SegmentCustomBuilderControl (
  636.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  637.                 new PolynomialFunctionSetParams (4),
  638.                 SegmentInelasticDesignControl.Create (
  639.                     2,
  640.                     2
  641.                 ),
  642.                 new ResponseScalingShapeControl (
  643.                     true,
  644.                     new QuadraticRationalShapeControl (0.)
  645.                 ),
  646.                 null
  647.             ),
  648.             MultiSegmentSequence.CALIBRATE,
  649.             null,
  650.             null,
  651.             true,
  652.             true
  653.         );

  654.         /*
  655.          * Set up the Hyman 1983 Local Curve Control parameters as follows:
  656.          *  - C1 Hyman 1983 Monotone Smoothener with spurious extrema elimination and monotone filtering
  657.          *      applied
  658.          *  - Zero Rate Quantification Metric
  659.          *  - Cubic Polynomial Basis Spline Set
  660.          *  - Ck = 2, Segment Curvature Penalty = 2
  661.          *  - Quadratic Rational Shape Controller
  662.          *  - Natural Boundary Setting
  663.          */

  664.         LocalControlCurveParams lccpHyman83 = new LocalControlCurveParams (
  665.             LocalMonotoneCkGenerator.C1_HYMAN83,
  666.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  667.             new SegmentCustomBuilderControl (
  668.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  669.                 new PolynomialFunctionSetParams (4),
  670.                 SegmentInelasticDesignControl.Create (
  671.                     2,
  672.                     2
  673.                 ),
  674.                 new ResponseScalingShapeControl (
  675.                     true,
  676.                     new QuadraticRationalShapeControl (0.)
  677.                 ),
  678.                 null
  679.             ),
  680.             MultiSegmentSequence.CALIBRATE,
  681.             null,
  682.             null,
  683.             true,
  684.             true
  685.         );

  686.         /*
  687.          * Set up the Hyman 1989 Local Curve Control parameters as follows:
  688.          *  - C1 Hyman 1989 Monotone Smoothener with spurious extrema elimination and monotone filtering
  689.          *      applied
  690.          *  - Zero Rate Quantification Metric
  691.          *  - Cubic Polynomial Basis Spline Set
  692.          *  - Ck = 2, Segment Curvature Penalty = 2
  693.          *  - Quadratic Rational Shape Controller
  694.          *  - Natural Boundary Setting
  695.          */

  696.         LocalControlCurveParams lccpHyman89 = new LocalControlCurveParams (
  697.             LocalMonotoneCkGenerator.C1_HYMAN89,
  698.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  699.             new SegmentCustomBuilderControl (
  700.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  701.                 new PolynomialFunctionSetParams (4),
  702.                 SegmentInelasticDesignControl.Create (
  703.                     2,
  704.                     2
  705.                 ),
  706.                 new ResponseScalingShapeControl (
  707.                     true,
  708.                     new QuadraticRationalShapeControl (0.)
  709.                 ),
  710.                 null
  711.             ),
  712.             MultiSegmentSequence.CALIBRATE,
  713.             null,
  714.             null,
  715.             true,
  716.             true
  717.         );

  718.         /*
  719.          * Set up the Huynh-LeFloch Limiter Local Curve Control parameters as follows:
  720.          *  - C1 Huynh-LeFloch Limiter Monotone Smoothener with spurious extrema elimination and monotone
  721.          *      filtering applied
  722.          *  - Zero Rate Quantification Metric
  723.          *  - Cubic Polynomial Basis Spline Set
  724.          *  - Ck = 2, Segment Curvature Penalty = 2
  725.          *  - Quadratic Rational Shape Controller
  726.          *  - Natural Boundary Setting
  727.          */

  728.         LocalControlCurveParams lccpHuynhLeFloch = new LocalControlCurveParams (
  729.             LocalMonotoneCkGenerator.C1_HUYNH_LE_FLOCH,
  730.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  731.             new SegmentCustomBuilderControl (
  732.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  733.                 new PolynomialFunctionSetParams (4),
  734.                 SegmentInelasticDesignControl.Create (
  735.                     2,
  736.                     2
  737.                 ),
  738.                 new ResponseScalingShapeControl (
  739.                     true,
  740.                     new QuadraticRationalShapeControl (0.)
  741.                 ),
  742.                 null
  743.             ),
  744.             MultiSegmentSequence.CALIBRATE,
  745.             null,
  746.             null,
  747.             true,
  748.             true
  749.         );

  750.         /*
  751.          * Set up the Kruger Local Curve Control parameters as follows:
  752.          *  - C1 Kruger Monotone Smoothener with spurious extrema elimination and monotone filtering applied
  753.          *  - Zero Rate Quantification Metric
  754.          *  - Cubic Polynomial Basis Spline Set
  755.          *  - Ck = 2, Segment Curvature Penalty = 2
  756.          *  - Quadratic Rational Shape Controller
  757.          *  - Natural Boundary Setting
  758.          */

  759.         LocalControlCurveParams lccpKruger = new LocalControlCurveParams (
  760.             LocalMonotoneCkGenerator.C1_KRUGER,
  761.             LatentStateStatic.DISCOUNT_QM_ZERO_RATE,
  762.             new SegmentCustomBuilderControl (
  763.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  764.                 new PolynomialFunctionSetParams (4),
  765.                 SegmentInelasticDesignControl.Create (
  766.                     2,
  767.                     2
  768.                 ),
  769.                 new ResponseScalingShapeControl (
  770.                     true,
  771.                     new QuadraticRationalShapeControl (0.)
  772.                 ),
  773.                 null
  774.             ),
  775.             MultiSegmentSequence.CALIBRATE,
  776.             null,
  777.             null,
  778.             true,
  779.             true
  780.         );

  781.         ValuationParams valParams = new ValuationParams (
  782.             dtSpot,
  783.             dtSpot,
  784.             strCurrency
  785.         );

  786.         /*
  787.          * Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  788.          *  of Deposit and OIS Stretches.
  789.          */

  790.         MergedDiscountForwardCurve dcShapePreserving = ScenarioDiscountCurveBuilder.ShapePreservingDFBuild (
  791.             strCurrency,
  792.             lcc,
  793.             aStretchSpec,
  794.             valParams,
  795.             null,
  796.             null,
  797.             null,
  798.             1.
  799.         );

  800.         /*
  801.          * Construct the Akima Locally Smoothened Discount Curve by applying the linear curve calibrator and
  802.          *  the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  803.          *  preserving discount curve.
  804.          */

  805.         MergedDiscountForwardCurve dcLocalAkima = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  806.             dcShapePreserving,
  807.             lcc,
  808.             lccpAkima,
  809.             valParams,
  810.             null,
  811.             null,
  812.             null
  813.         );

  814.         /*
  815.          * Construct the Harmonic Locally Smoothened Discount Curve by applying the linear curve calibrator
  816.          *  and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  817.          *  preserving discount curve.
  818.          */

  819.         MergedDiscountForwardCurve dcLocalHarmonic = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  820.             dcShapePreserving,
  821.             lcc,
  822.             lccpHarmonic,
  823.             valParams,
  824.             null,
  825.             null,
  826.             null
  827.         );

  828.         /*
  829.          * Construct the Hyman 1983 Locally Smoothened Discount Curve by applying the linear curve calibrator
  830.          *  and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  831.          *  preserving discount curve.
  832.          */

  833.         MergedDiscountForwardCurve dcLocalHyman83 = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  834.             dcShapePreserving,
  835.             lcc,
  836.             lccpHyman83,
  837.             valParams,
  838.             null,
  839.             null,
  840.             null
  841.         );

  842.         /*
  843.          * Construct the Hyman 1989 Locally Smoothened OIS Discount Curve by applying the linear curve calibrator
  844.          *  and the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  845.          *  preserving discount curve.
  846.          */

  847.         MergedDiscountForwardCurve dcLocalHyman89 = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  848.             dcShapePreserving,
  849.             lcc,
  850.             lccpHyman89,
  851.             valParams,
  852.             null,
  853.             null,
  854.             null
  855.         );

  856.         /*
  857.          * Construct the Huynh-Le Floch delimited Locally Smoothened OIS Discount Curve by applying the linear
  858.          *  curve calibrator and the Local Curve Control parameters to the array of Deposit and OIS Stretches
  859.          *  and the shape preserving discount curve.
  860.          */

  861.         MergedDiscountForwardCurve dcLocalHuynhLeFloch = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  862.             dcShapePreserving,
  863.             lcc,
  864.             lccpHuynhLeFloch,
  865.             valParams,
  866.             null,
  867.             null,
  868.             null
  869.         );

  870.         /*
  871.          * Construct the Kruger Locally Smoothened OIS Discount Curve by applying the linear curve calibrator and
  872.          *  the Local Curve Control parameters to the array of Deposit and OIS Stretches and the shape
  873.          *  preserving discount curve.
  874.          */

  875.         MergedDiscountForwardCurve dcLocalKruger = ScenarioDiscountCurveBuilder.SmoothingLocalControlBuild (
  876.             dcShapePreserving,
  877.             lcc,
  878.             lccpKruger,
  879.             valParams,
  880.             null,
  881.             null,
  882.             null
  883.         );

  884.         /*
  885.          * Cross-Comparison of the Deposit Calibration Instrument "Rate" metric across the different curve
  886.          *  construction methodologies.
  887.          */

  888.         System.out.println ("\n\t-------------------------------------------------------------------------------------------------------------------------------------------");

  889.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  890.         System.out.println ("\t                                                DEPOSIT INSTRUMENTS CALIBRATION RECOVERY");

  891.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  892.         System.out.println ("\t        SHAPE PRESERVING   |  LOCAL AKIMA  | LOCAL HARMONIC | LOCAL HYMAN83 | LOCAL HYMAN89 | LOCAL HUYNHLF | LOCAL KRUGER  |  INPUT QUOTE  ");

  893.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  894.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  895.         for (int i = 0; i < aDepositComp.length; ++i)
  896.             System.out.println ("\t[" + aDepositComp[i].maturityDate() + "] = " +
  897.                 FormatUtil.FormatDouble (
  898.                     aDepositComp[i].measureValue (
  899.                         valParams, null,
  900.                         MarketParamsBuilder.Create (dcShapePreserving, null, null, null, null, null, null),
  901.                         null,
  902.                         "Rate"),
  903.                     1, 6, 1.) + "   |   " +
  904.                 FormatUtil.FormatDouble (
  905.                     aDepositComp[i].measureValue (
  906.                         valParams, null,
  907.                         MarketParamsBuilder.Create (dcLocalAkima, null, null, null, null, null, null),
  908.                         null,
  909.                         "Rate"),
  910.                     1, 6, 1.) + "   |   " +
  911.                 FormatUtil.FormatDouble (
  912.                     aDepositComp[i].measureValue (
  913.                         valParams, null,
  914.                         MarketParamsBuilder.Create (dcLocalHarmonic, null, null, null, null, null, null),
  915.                         null,
  916.                         "Rate"),
  917.                     1, 6, 1.) + "    |   " +
  918.                 FormatUtil.FormatDouble (
  919.                     aDepositComp[i].measureValue (
  920.                         valParams, null,
  921.                         MarketParamsBuilder.Create (dcLocalHyman83, null, null, null, null, null, null),
  922.                         null,
  923.                         "Rate"),
  924.                     1, 6, 1.) + "   |   " +
  925.                 FormatUtil.FormatDouble (
  926.                     aDepositComp[i].measureValue (
  927.                         valParams, null,
  928.                         MarketParamsBuilder.Create (dcLocalHyman89, null, null, null, null, null, null),
  929.                         null,
  930.                         "Rate"),
  931.                     1, 6, 1.) + "   |   " +
  932.                 FormatUtil.FormatDouble (
  933.                     aDepositComp[i].measureValue (
  934.                         valParams, null,
  935.                         MarketParamsBuilder.Create (dcLocalHuynhLeFloch, null, null, null, null, null, null),
  936.                         null,
  937.                         "Rate"),
  938.                     1, 6, 1.) + "   |   " +
  939.                 FormatUtil.FormatDouble (
  940.                     aDepositComp[i].measureValue (
  941.                         valParams, null,
  942.                         MarketParamsBuilder.Create (dcLocalKruger, null, null, null, null, null, null),
  943.                         null,
  944.                         "Rate"),
  945.                     1, 6, 1.) + "   |   " +
  946.                 FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.)
  947.             );

  948.         /*
  949.          * Cross-Comparison of the Short End OIS Calibration Instrument "Rate" metric across the different curve
  950.          *  construction methodologies.
  951.          */

  952.         System.out.println ("\n\t--------------------------------------------------------------------------------------------------------------------------------------------");

  953.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  954.         System.out.println ("\t                                                 SHORT END OIS INSTRUMENTS CALIBRATION RECOVERY");

  955.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  956.         System.out.println ("\t        SHAPE PRESERVING   |  LOCAL AKIMA  | LOCAL HARMONIC | LOCAL HYMAN83 | LOCAL HYMAN89 | LOCAL HUYNHLF | LOCAL KRUGER  |  INPUT QUOTE  ");

  957.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  958.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  959.         for (int i = 0; i < aShortEndOISComp.length; ++i)
  960.             System.out.println ("\t[" + aShortEndOISComp[i].maturityDate() + "] = " +
  961.                 FormatUtil.FormatDouble (
  962.                     aShortEndOISComp[i].measureValue (
  963.                         valParams, null,
  964.                         MarketParamsBuilder.Create (dcShapePreserving, null, null, null, null, null, null),
  965.                         null,
  966.                         "CalibSwapRate"),
  967.                     1, 6, 1.) + "   |   " +
  968.                 FormatUtil.FormatDouble (
  969.                     aShortEndOISComp[i].measureValue (
  970.                         valParams, null,
  971.                         MarketParamsBuilder.Create (dcLocalAkima, null, null, null, null, null, null),
  972.                         null,
  973.                         "CalibSwapRate"),
  974.                     1, 6, 1.) + "   |   " +
  975.                 FormatUtil.FormatDouble (
  976.                     aShortEndOISComp[i].measureValue (
  977.                         valParams, null,
  978.                         MarketParamsBuilder.Create (dcLocalHarmonic, null, null, null, null, null, null),
  979.                         null,
  980.                         "CalibSwapRate"),
  981.                     1, 6, 1.) + "    |   " +
  982.                 FormatUtil.FormatDouble (
  983.                     aShortEndOISComp[i].measureValue (
  984.                         valParams, null,
  985.                         MarketParamsBuilder.Create (dcLocalHyman83, null, null, null, null, null, null),
  986.                         null,
  987.                         "CalibSwapRate"),
  988.                     1, 6, 1.) + "   |   " +
  989.                 FormatUtil.FormatDouble (
  990.                     aShortEndOISComp[i].measureValue (
  991.                         valParams, null,
  992.                         MarketParamsBuilder.Create (dcLocalHyman89, null, null, null, null, null, null),
  993.                         null,
  994.                         "CalibSwapRate"),
  995.                     1, 6, 1.) + "   |   " +
  996.                 FormatUtil.FormatDouble (
  997.                     aShortEndOISComp[i].measureValue (
  998.                         valParams, null,
  999.                         MarketParamsBuilder.Create (dcLocalHuynhLeFloch, null, null, null, null, null, null),
  1000.                         null,
  1001.                         "CalibSwapRate"),
  1002.                     1, 6, 1.) + "   |   " +
  1003.                 FormatUtil.FormatDouble (
  1004.                     aShortEndOISComp[i].measureValue (
  1005.                         valParams, null,
  1006.                         MarketParamsBuilder.Create (dcLocalKruger, null, null, null, null, null, null),
  1007.                         null,
  1008.                         "CalibSwapRate"),
  1009.                     1, 6, 1.) + "   |   " +
  1010.                 FormatUtil.FormatDouble (adblShortEndOISQuote[i], 1, 6, 1.)
  1011.             );

  1012.         /*
  1013.          * Cross-Comparison of the OIS Future Calibration Instrument "Rate" metric across the different curve
  1014.          *  construction methodologies.
  1015.          */

  1016.         System.out.println ("\n\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1017.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1018.         System.out.println ("\t                                                 OIS FUTURE INSTRUMENTS CALIBRATION RECOVERY");

  1019.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1020.         System.out.println ("\t        SHAPE PRESERVING   |  LOCAL AKIMA  | LOCAL HARMONIC | LOCAL HYMAN83 | LOCAL HYMAN89 | LOCAL HUYNHLF | LOCAL KRUGER  |  INPUT QUOTE  ");

  1021.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1022.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1023.         for (int i = 0; i < aOISFutureComp.length; ++i)
  1024.             System.out.println ("\t[" + aOISFutureComp[i].maturityDate() + "] = " +
  1025.                 FormatUtil.FormatDouble (
  1026.                     aOISFutureComp[i].measureValue (
  1027.                         valParams, null,
  1028.                         MarketParamsBuilder.Create (dcShapePreserving, null, null, null, null, null, null),
  1029.                         null,
  1030.                         "SwapRate"),
  1031.                     1, 6, 1.) + "   |   " +
  1032.                 FormatUtil.FormatDouble (
  1033.                     aOISFutureComp[i].measureValue (
  1034.                         valParams, null,
  1035.                         MarketParamsBuilder.Create (dcLocalAkima, null, null, null, null, null, null),
  1036.                         null,
  1037.                         "SwapRate"),
  1038.                     1, 6, 1.) + "   |   " +
  1039.                 FormatUtil.FormatDouble (
  1040.                     aOISFutureComp[i].measureValue (
  1041.                         valParams, null,
  1042.                         MarketParamsBuilder.Create (dcLocalHarmonic, null, null, null, null, null, null),
  1043.                         null,
  1044.                         "SwapRate"),
  1045.                     1, 6, 1.) + "    |   " +
  1046.                 FormatUtil.FormatDouble (
  1047.                     aOISFutureComp[i].measureValue (
  1048.                         valParams, null,
  1049.                         MarketParamsBuilder.Create (dcLocalHyman83, null, null, null, null, null, null),
  1050.                         null,
  1051.                         "SwapRate"),
  1052.                     1, 6, 1.) + "   |   " +
  1053.                 FormatUtil.FormatDouble (
  1054.                     aOISFutureComp[i].measureValue (
  1055.                         valParams, null,
  1056.                         MarketParamsBuilder.Create (dcLocalHyman89, null, null, null, null, null, null),
  1057.                         null,
  1058.                         "SwapRate"),
  1059.                     1, 6, 1.) + "   |   " +
  1060.                 FormatUtil.FormatDouble (
  1061.                     aOISFutureComp[i].measureValue (
  1062.                         valParams, null,
  1063.                         MarketParamsBuilder.Create (dcLocalHuynhLeFloch, null, null, null, null, null, null),
  1064.                         null,
  1065.                         "SwapRate"),
  1066.                     1, 6, 1.) + "   |   " +
  1067.                 FormatUtil.FormatDouble (
  1068.                     aOISFutureComp[i].measureValue (
  1069.                         valParams, null,
  1070.                         MarketParamsBuilder.Create (dcLocalKruger, null, null, null, null, null, null),
  1071.                         null,
  1072.                         "SwapRate"),
  1073.                     1, 6, 1.) + "   |   " +
  1074.                 FormatUtil.FormatDouble (adblOISFutureQuote[i], 1, 6, 1.)
  1075.             );

  1076.         System.out.println ("\n\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1077.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1078.         System.out.println ("\t                                                 LONG END OIS INSTRUMENTS CALIBRATION RECOVERY");

  1079.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1080.         System.out.println ("\t        SHAPE PRESERVING   |  LOCAL AKIMA  | LOCAL HARMONIC | LOCAL HYMAN83 | LOCAL HYMAN89 | LOCAL HUYNHLF | LOCAL KRUGER  |  INPUT QUOTE  ");

  1081.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1082.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------------------");

  1083.         for (int i = 0; i < aLongEndOISComp.length; ++i)
  1084.             System.out.println ("\t[" + aLongEndOISComp[i].maturityDate() + "] = " +
  1085.                 FormatUtil.FormatDouble (
  1086.                     aLongEndOISComp[i].measureValue (
  1087.                         valParams, null,
  1088.                         MarketParamsBuilder.Create (dcShapePreserving, null, null, null, null, null, null),
  1089.                         null,
  1090.                         "CalibSwapRate"),
  1091.                     1, 6, 1.) + "   |   " +
  1092.                 FormatUtil.FormatDouble (
  1093.                     aLongEndOISComp[i].measureValue (
  1094.                         valParams, null,
  1095.                         MarketParamsBuilder.Create (dcLocalAkima, null, null, null, null, null, null),
  1096.                         null,
  1097.                         "CalibSwapRate"),
  1098.                     1, 6, 1.) + "   |   " +
  1099.                 FormatUtil.FormatDouble (
  1100.                     aLongEndOISComp[i].measureValue (
  1101.                         valParams, null,
  1102.                         MarketParamsBuilder.Create (dcLocalHarmonic, null, null, null, null, null, null),
  1103.                         null,
  1104.                         "CalibSwapRate"),
  1105.                     1, 6, 1.) + "    |   " +
  1106.                 FormatUtil.FormatDouble (
  1107.                     aLongEndOISComp[i].measureValue (
  1108.                         valParams, null,
  1109.                         MarketParamsBuilder.Create (dcLocalHyman83, null, null, null, null, null, null),
  1110.                         null,
  1111.                         "CalibSwapRate"),
  1112.                     1, 6, 1.) + "   |   " +
  1113.                 FormatUtil.FormatDouble (
  1114.                     aLongEndOISComp[i].measureValue (
  1115.                         valParams, null,
  1116.                         MarketParamsBuilder.Create (dcLocalHyman89, null, null, null, null, null, null),
  1117.                         null,
  1118.                         "CalibSwapRate"),
  1119.                     1, 6, 1.) + "   |   " +
  1120.                 FormatUtil.FormatDouble (
  1121.                     aLongEndOISComp[i].measureValue (
  1122.                         valParams, null,
  1123.                         MarketParamsBuilder.Create (dcLocalHuynhLeFloch, null, null, null, null, null, null),
  1124.                         null,
  1125.                         "CalibSwapRate"),
  1126.                     1, 6, 1.) + "   |   " +
  1127.                 FormatUtil.FormatDouble (
  1128.                     aLongEndOISComp[i].measureValue (
  1129.                         valParams, null,
  1130.                         MarketParamsBuilder.Create (dcLocalKruger, null, null, null, null, null, null),
  1131.                         null,
  1132.                         "CalibSwapRate"),
  1133.                     1, 6, 1.) + "   |   " +
  1134.                 FormatUtil.FormatDouble (adblLongEndOISQuote[i], 1, 6, 1.)
  1135.             );

  1136.         /*
  1137.          * Cross-Comparison of the OIS Calibration Instrument "Rate" metric across the different curve
  1138.          *  construction methodologies for a sequence of bespoke OIS instruments.
  1139.          */

  1140.         CalibratableComponent[] aCC = OvernightIndexFromMaturityTenor (
  1141.             dtSpot,
  1142.             new java.lang.String[] {
  1143.                 "3Y", "6Y", "9Y", "12Y", "15Y", "18Y", "21Y", "24Y", "27Y", "30Y"
  1144.             },
  1145.             new double[] {
  1146.                 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01
  1147.             },
  1148.             strCurrency
  1149.         );

  1150.         System.out.println ("\n\t--------------------------------------------------------------------------------------------------------------------------------");

  1151.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------");

  1152.         System.out.println ("\t                                                BESPOKE OIS PAR RATE");

  1153.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------");

  1154.         System.out.println ("\t        SHAPE PRESERVING   |  LOCAL AKIMA  | LOCAL HARMONIC | LOCAL HYMAN83  | LOCAL HYMAN89  | LOCAL HUYNHLF  | LOCAL KRUGER ");

  1155.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------");

  1156.         System.out.println ("\t--------------------------------------------------------------------------------------------------------------------------------");

  1157.         for (int i = 0; i < aCC.length; ++i)
  1158.             System.out.println ("\t[" + aCC[i].maturityDate() + "] = " +
  1159.                 FormatUtil.FormatDouble (
  1160.                     aCC[i].measureValue (valParams, null,
  1161.                     MarketParamsBuilder.Create (dcShapePreserving, null, null, null, null, null, null),
  1162.                     null,
  1163.                     "CalibSwapRate"),
  1164.                 1, 6, 1.) + "   |   " +
  1165.                 FormatUtil.FormatDouble (
  1166.                     aCC[i].measureValue (valParams, null,
  1167.                     MarketParamsBuilder.Create (dcLocalAkima, null, null, null, null, null, null),
  1168.                     null,
  1169.                     "CalibSwapRate"),
  1170.                 1, 6, 1.) + "   |   " +
  1171.                 FormatUtil.FormatDouble (
  1172.                     aCC[i].measureValue (valParams, null,
  1173.                     MarketParamsBuilder.Create (dcLocalHarmonic, null, null, null, null, null, null),
  1174.                     null,
  1175.                     "CalibSwapRate"),
  1176.                 1, 6, 1.) + "    |   " +
  1177.                 FormatUtil.FormatDouble (
  1178.                     aCC[i].measureValue (valParams, null,
  1179.                     MarketParamsBuilder.Create (dcLocalHyman83, null, null, null, null, null, null),
  1180.                     null,
  1181.                     "CalibSwapRate"),
  1182.                     1, 6, 1.) + "    |   " +
  1183.                 FormatUtil.FormatDouble (
  1184.                     aCC[i].measureValue (valParams, null,
  1185.                     MarketParamsBuilder.Create (dcLocalHyman89, null, null, null, null, null, null),
  1186.                     null,
  1187.                     "CalibSwapRate"),
  1188.                     1, 6, 1.) + "    |   " +
  1189.                 FormatUtil.FormatDouble (
  1190.                     aCC[i].measureValue (valParams, null,
  1191.                     MarketParamsBuilder.Create (dcLocalHuynhLeFloch, null, null, null, null, null, null),
  1192.                     null,
  1193.                     "CalibSwapRate"),
  1194.                     1, 6, 1.) + "    |   " +
  1195.                 FormatUtil.FormatDouble (
  1196.                     aCC[i].measureValue (valParams, null,
  1197.                     MarketParamsBuilder.Create (dcLocalKruger, null, null, null, null, null, null),
  1198.                     null,
  1199.                     "CalibSwapRate"),
  1200.                 1, 6, 1.)
  1201.             );
  1202.     }

  1203.     public static final void main (
  1204.         final String[] astrArgs)
  1205.         throws Exception
  1206.     {
  1207.         /*
  1208.          * Initialize the Credit Analytics Library
  1209.          */

  1210.         EnvManager.InitEnv ("");

  1211.         JulianDate dtSpot = DateUtil.Today();

  1212.         ShapeOISDFZeroLocalSmoothSample (
  1213.             dtSpot,
  1214.             "---- DISCOUNT CURVE WITH OVERNIGHT INDEX ---",
  1215.             "EUR"
  1216.         );
  1217.     }
  1218. }