OvernightIndexCurve.java

  1. package org.drip.sample.forward;

  2. import java.util.List;

  3. import org.drip.analytics.date.JulianDate;
  4. import org.drip.analytics.support.*;
  5. import org.drip.function.r1tor1.QuadraticRationalShapeControl;
  6. import org.drip.market.definition.FloaterIndex;
  7. import org.drip.market.otc.*;
  8. import org.drip.param.period.*;
  9. import org.drip.param.valuation.*;
  10. import org.drip.product.creator.SingleStreamComponentBuilder;
  11. import org.drip.product.definition.CalibratableComponent;
  12. import org.drip.product.rates.*;
  13. import org.drip.spline.basis.PolynomialFunctionSetParams;
  14. import org.drip.spline.params.*;
  15. import org.drip.spline.stretch.*;
  16. import org.drip.state.creator.ScenarioDiscountCurveBuilder;
  17. import org.drip.state.discount.*;
  18. import org.drip.state.estimator.LatentStateStretchBuilder;
  19. import org.drip.state.identifier.*;
  20. import org.drip.state.inference.*;

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

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

  87. /**
  88.  * <i>OvernightIndexCurve</i> illustrates the Construction and Usage of the Overnight Index Discount Curve.
  89.  *  
  90.  * <br><br>
  91.  *  <ul>
  92.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  93.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  94.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  95.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/forward/README.md">Forward Rate Curve Construction</a></li>
  96.  *  </ul>
  97.  * <br><br>
  98.  *
  99.  * @author Lakshmi Krishnamurthy
  100.  */

  101. public class OvernightIndexCurve {

  102.     /*
  103.      * Construct the Array of Deposit Instruments from the given set of parameters
  104.      *
  105.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  106.      */

  107.     private static final SingleStreamComponent[] DepositInstrumentsFromMaturityDays (
  108.         final JulianDate dtEffective,
  109.         final String strCurrency,
  110.         final int[] aiDay,
  111.         final FloaterIndex fi)
  112.         throws Exception
  113.     {
  114.         SingleStreamComponent[] aDeposit = new SingleStreamComponent[aiDay.length];

  115.         for (int i = 0; i < aiDay.length; ++i)
  116.             aDeposit[i] = SingleStreamComponentBuilder.Deposit (
  117.                 dtEffective,
  118.                 dtEffective.addBusDays (
  119.                     aiDay[i],
  120.                     strCurrency
  121.                 ),
  122.                 null == fi ? OvernightLabel.Create (
  123.                     strCurrency
  124.                 ) : ForwardLabel.Create (
  125.                     fi,
  126.                     "ON"
  127.                 )
  128.             );

  129.         return aDeposit;
  130.     }

  131.     private static final FixFloatComponent OTCOISFixFloat (
  132.         final JulianDate dtSpot,
  133.         final String strCurrency,
  134.         final String strMaturityTenor,
  135.         final double dblCoupon)
  136.     {
  137.         FixedFloatSwapConvention ffConv = OvernightFixedFloatContainer.FundConventionFromJurisdiction (
  138.             strCurrency
  139.         );

  140.         return null == ffConv ? null : ffConv.createFixFloatComponent (
  141.             dtSpot,
  142.             strMaturityTenor,
  143.             dblCoupon,
  144.             0.,
  145.             1.
  146.         );
  147.     }

  148.     /*
  149.      * Construct the Array of Overnight Index Instruments from the given set of parameters
  150.      *
  151.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  152.      */

  153.     private static final FixFloatComponent[] OISFromMaturityTenor (
  154.         final JulianDate dtSpot,
  155.         final String strCurrency,
  156.         final String[] astrMaturityTenor,
  157.         final double[] adblCoupon)
  158.         throws Exception
  159.     {
  160.         FixFloatComponent[] aOIS = new FixFloatComponent[astrMaturityTenor.length];

  161.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  162.             if (null == (aOIS[i] = OTCOISFixFloat (
  163.                 dtSpot,
  164.                 strCurrency,
  165.                 astrMaturityTenor[i],
  166.                 adblCoupon[i]
  167.             )))
  168.             return null;
  169.         }

  170.         return aOIS;
  171.     }

  172.     private static final FixFloatComponent[] OvernightIndexFromMaturityTenor (
  173.         final JulianDate dtEffective,
  174.         final String strCurrency,
  175.         final String[] astrMaturityTenor,
  176.         final double[] adblCoupon,
  177.         final FloaterIndex fi)
  178.         throws Exception
  179.     {
  180.         FixFloatComponent[] aOIS = new FixFloatComponent[astrMaturityTenor.length];

  181.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  182.             2,
  183.             "Act/360",
  184.             false,
  185.             "Act/360",
  186.             false,
  187.             strCurrency,
  188.             false,
  189.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  190.         );

  191.         CashSettleParams csp = new CashSettleParams (
  192.             0,
  193.             strCurrency,
  194.             0
  195.         );

  196.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  197.             java.lang.String strFixedTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  198.                 astrMaturityTenor[i],
  199.                 "6M"
  200.             ) ? astrMaturityTenor[i] : "6M";

  201.             java.lang.String strFloatingTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  202.                 astrMaturityTenor[i],
  203.                 "3M"
  204.             ) ? astrMaturityTenor[i] : "3M";

  205.             ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  206.                 "ON",
  207.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_OVERNIGHT,
  208.                 null,
  209.                 null == fi ? OvernightLabel.Create (
  210.                     strCurrency
  211.                 ) : ForwardLabel.Create (
  212.                     fi,
  213.                     "ON"
  214.                 ),
  215.                 CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  216.                 0.
  217.             );

  218.             ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  219.                 strFixedTenor,
  220.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  221.                 null,
  222.                 adblCoupon[i],
  223.                 0.,
  224.                 strCurrency
  225.             );

  226.             CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  227.                 4,
  228.                 strFloatingTenor,
  229.                 strCurrency,
  230.                 null,
  231.                 -1.,
  232.                 null,
  233.                 null,
  234.                 null,
  235.                 null
  236.             );

  237.             CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  238.                 2,
  239.                 strFixedTenor,
  240.                 strCurrency,
  241.                 null,
  242.                 1.,
  243.                 null,
  244.                 null,
  245.                 null,
  246.                 null
  247.             );

  248.             List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  249.                 dtEffective,
  250.                 strFixedTenor,
  251.                 astrMaturityTenor[i],
  252.                 null
  253.             );

  254.             List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  255.                 dtEffective,
  256.                 strFloatingTenor,
  257.                 astrMaturityTenor[i],
  258.                 null
  259.             );

  260.             Stream floatingStream = new Stream (
  261.                 CompositePeriodBuilder.FloatingCompositeUnit (
  262.                     lsFloatingStreamEdgeDate,
  263.                     cpsFloating,
  264.                     cfusFloating
  265.                 )
  266.             );

  267.             Stream fixedStream = new Stream (
  268.                 CompositePeriodBuilder.FixedCompositeUnit (
  269.                     lsFixedStreamEdgeDate,
  270.                     cpsFixed,
  271.                     ucasFixed,
  272.                     cfusFixed
  273.                 )
  274.             );

  275.             FixFloatComponent ois = new FixFloatComponent (
  276.                 fixedStream,
  277.                 floatingStream,
  278.                 csp
  279.             );

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

  281.             aOIS[i] = ois;
  282.         }

  283.         return aOIS;
  284.     }

  285.     /*
  286.      * Construct the Array of Overnight Index Future Instruments from the given set of parameters
  287.      *
  288.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  289.      */

  290.     private static final FixFloatComponent[] OISFuturesFromMaturityTenor (
  291.         final JulianDate dtSpot,
  292.         final String strCurrency,
  293.         final String[] astrStartTenor,
  294.         final String[] astrMaturityTenor,
  295.         final double[] adblCoupon)
  296.         throws Exception
  297.     {
  298.         FixFloatComponent[] aOISFutures = new FixFloatComponent[astrMaturityTenor.length];

  299.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  300.             if (null == (aOISFutures[i] = OTCOISFixFloat (
  301.                 dtSpot.addTenor (astrStartTenor[i]),
  302.                 strCurrency,
  303.                 astrMaturityTenor[i],
  304.                 adblCoupon[i]
  305.             )))
  306.             return null;
  307.         }

  308.         return aOISFutures;
  309.     }

  310.     private static final FixFloatComponent[] OvernightIndexFutureFromMaturityTenor (
  311.         final JulianDate dtSpot,
  312.         final String strCurrency,
  313.         final String[] astrStartTenor,
  314.         final String[] astrMaturityTenor,
  315.         final double[] adblCoupon,
  316.         final FloaterIndex fi)
  317.         throws Exception
  318.     {
  319.         FixFloatComponent[] aOIS = new FixFloatComponent[astrStartTenor.length];

  320.         CashSettleParams csp = new CashSettleParams (
  321.             0,
  322.             strCurrency,
  323.             0
  324.         );

  325.         for (int i = 0; i < astrStartTenor.length; ++i) {
  326.             JulianDate dtEffective = dtSpot.addTenor (astrStartTenor[i]);

  327.             java.lang.String strFixedTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  328.                 astrMaturityTenor[i],
  329.                 "6M"
  330.             ) ? astrMaturityTenor[i] : "6M";

  331.             java.lang.String strFloatingTenor = Helper.LEFT_TENOR_LESSER == Helper.TenorCompare (
  332.                 astrMaturityTenor[i],
  333.                 "3M"
  334.             ) ? astrMaturityTenor[i] : "3M";

  335.             ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  336.                 strFixedTenor,
  337.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  338.                 null,
  339.                 adblCoupon[i],
  340.                 0.,
  341.                 strCurrency
  342.             );

  343.             UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  344.                 2,
  345.                 "Act/360",
  346.                 false,
  347.                 "Act/360",
  348.                 false,
  349.                 strCurrency,
  350.                 false,
  351.                 CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  352.             );

  353.             ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  354.                 "ON",
  355.                 CompositePeriodBuilder.EDGE_DATE_SEQUENCE_OVERNIGHT,
  356.                 null,
  357.                 null == fi ? OvernightLabel.Create (
  358.                     strCurrency
  359.                 ) : ForwardLabel.Create (
  360.                     fi,
  361.                     "ON"
  362.                 ),
  363.                 CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  364.                 0.
  365.             );

  366.             CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  367.                 4,
  368.                 strFloatingTenor,
  369.                 strCurrency,
  370.                 null,
  371.                 -1.,
  372.                 null,
  373.                 null,
  374.                 null,
  375.                 null
  376.             );

  377.             CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  378.                 2,
  379.                 strFixedTenor,
  380.                 strCurrency,
  381.                 null,
  382.                 1.,
  383.                 null,
  384.                 null,
  385.                 null,
  386.                 null
  387.             );

  388.             List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  389.                 dtEffective,
  390.                 "6M",
  391.                 astrMaturityTenor[i],
  392.                 null
  393.             );

  394.             List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  395.                 dtEffective,
  396.                 "3M",
  397.                 astrMaturityTenor[i],
  398.                 null
  399.             );

  400.             Stream floatingStream = new Stream (
  401.                 CompositePeriodBuilder.FloatingCompositeUnit (
  402.                     lsFloatingStreamEdgeDate,
  403.                     cpsFloating,
  404.                     cfusFloating
  405.                 )
  406.             );

  407.             Stream fixedStream = new Stream (
  408.                 CompositePeriodBuilder.FixedCompositeUnit (
  409.                     lsFixedStreamEdgeDate,
  410.                     cpsFixed,
  411.                     ucasFixed,
  412.                     cfusFixed
  413.                 )
  414.             );

  415.             FixFloatComponent ois = new FixFloatComponent (
  416.                 fixedStream,
  417.                 floatingStream,
  418.                 csp
  419.             );

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

  421.             aOIS[i] = ois;
  422.         }

  423.         return aOIS;
  424.     }

  425.     public static final MergedDiscountForwardCurve MakeDC (
  426.         final String strCurrency,
  427.         final JulianDate dtSpot,
  428.         final int[] aiDepositMaturityDays,
  429.         final double[] adblDepositQuote,
  430.         final String[] astrShortEndOISMaturityTenor,
  431.         final double[] adblShortEndOISQuote,
  432.         final String[] astrOISFutureTenor,
  433.         final String[] astrOISFutureMaturityTenor,
  434.         final double[] adblOISFutureQuote,
  435.         final String[] astrLongEndOISMaturityTenor,
  436.         final double[] adblLongEndOISQuote,
  437.         final SegmentCustomBuilderControl scbc,
  438.         final FloaterIndex fi)
  439.         throws Exception
  440.     {
  441.         /*
  442.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  443.          */

  444.         SingleStreamComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  445.             dtSpot,
  446.             strCurrency,
  447.             aiDepositMaturityDays,
  448.             fi
  449.         );

  450.         /*
  451.          * Construct the Deposit Instrument Set Stretch Builder
  452.          */

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

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

  462.         CalibratableComponent[] aShortEndOISComp = OISFromMaturityTenor (
  463.             dtSpot,
  464.             strCurrency,
  465.             new java.lang.String[] {
  466.                 "1W", "2W", "3W", "1M"
  467.             },
  468.             adblShortEndOISQuote
  469.         );

  470.         if (null == aShortEndOISComp)
  471.             aShortEndOISComp = OvernightIndexFromMaturityTenor (dtSpot,
  472.                 strCurrency,
  473.                 new java.lang.String[] {
  474.                     "1W", "2W", "3W", "1M"
  475.                 },
  476.                 adblShortEndOISQuote,
  477.                 fi
  478.             );

  479.         /*
  480.          * Construct the Short End OIS Instrument Set Stretch Builder
  481.          */

  482.         LatentStateStretchSpec oisShortEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  483.             "OIS_SHORT_END",
  484.             aShortEndOISComp,
  485.             "SwapRate",
  486.             adblShortEndOISQuote
  487.         );

  488.         /*
  489.          * Construct the Array of OIS Futures Instruments and their Quotes from the given set of parameters
  490.          */

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

  502.         if (null == aOISFutureComp)
  503.             aOISFutureComp = OvernightIndexFutureFromMaturityTenor (
  504.                 dtSpot,
  505.                 strCurrency,
  506.                 new java.lang.String[] {
  507.                     "1M", "2M", "3M", "4M", "5M"
  508.                 },
  509.                 new java.lang.String[] {
  510.                     "1M", "1M", "1M", "1M", "1M"
  511.                 },
  512.                 adblOISFutureQuote,
  513.                 fi
  514.             );

  515.         /*
  516.          * Construct the OIS Future Instrument Set Stretch Builder
  517.          */

  518.         LatentStateStretchSpec oisFutureStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  519.             "OIS_FUTURE",
  520.             aOISFutureComp,
  521.             "SwapRate",
  522.             adblOISFutureQuote
  523.         );

  524.         /*
  525.          * Construct the Array of Long End OIS Instruments and their Quotes from the given set of parameters
  526.          */

  527.         CalibratableComponent[] aLongEndOISComp = OISFromMaturityTenor (
  528.             dtSpot,
  529.             strCurrency,
  530.             new java.lang.String[] {
  531.                 "15M", "18M", "21M", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  532.             },
  533.             adblLongEndOISQuote
  534.         );

  535.         /*
  536.          * Construct the Long End OIS Instrument Set Stretch Builder
  537.          */

  538.         LatentStateStretchSpec oisLongEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  539.             "OIS_LONG_END",
  540.             aLongEndOISComp,
  541.             "SwapRate",
  542.             adblLongEndOISQuote
  543.         );

  544.         LatentStateStretchSpec[] aStretchSpec = new LatentStateStretchSpec[] {
  545.             depositStretch,
  546.             oisShortEndStretch,
  547.             oisFutureStretch,
  548.             oisLongEndStretch
  549.         };

  550.         /*
  551.          * Set up the Linear Curve Calibrator using the following parameters:
  552.          *  - Cubic Exponential Mixture Basis Spline Set
  553.          *  - Ck = 2, Segment Curvature Penalty = 2
  554.          *  - Quadratic Rational Shape Controller
  555.          *  - Natural Boundary Setting
  556.          */

  557.         LinearLatentStateCalibrator lcc = new LinearLatentStateCalibrator (
  558.             scbc,
  559.             BoundarySettings.NaturalStandard(),
  560.             MultiSegmentSequence.CALIBRATE,
  561.             null,
  562.             null
  563.         );

  564.         /*
  565.          * Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  566.          *  of Deposit and Swap Stretches.
  567.          */

  568.         return ScenarioDiscountCurveBuilder.ShapePreservingDFBuild (
  569.             strCurrency,
  570.             lcc,
  571.             aStretchSpec,
  572.             new ValuationParams (
  573.                 dtSpot,
  574.                 dtSpot,
  575.                 strCurrency
  576.             ),
  577.             null,
  578.             null,
  579.             null,
  580.             1.
  581.         );
  582.     }

  583.     /**
  584.      * Construct an elaborate EONIA Discount Curve
  585.      *
  586.      * @param dtSpot The Spot Date
  587.      * @param strCurrency The Currency
  588.      *
  589.      * @return Instance of the EONIA Discount Curve
  590.      *
  591.      * @throws Exception Thrown if the OIS Discount Curve Could not be created
  592.      */

  593.     public static final MergedDiscountForwardCurve MakeDC (
  594.         final JulianDate dtSpot,
  595.         final String strCurrency)
  596.         throws Exception
  597.     {
  598.         /*
  599.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  600.          */

  601.         int[] aiDepositMaturityDays = new int[] {
  602.             1,
  603.             2,
  604.             3
  605.         };

  606.         double[] adblDepositQuote = new double[] {
  607.             0.0004, // 1D
  608.             0.0004, // 2D
  609.             0.0004  // 3D
  610.         };

  611.         /*
  612.          * Construct the Array of Short End OIS Instruments and their Quotes from the given set of parameters
  613.          */

  614.         String[] astrShortEndOISMaturityTenor = new java.lang.String[] {
  615.             "1W",
  616.             "2W",
  617.             "3W",
  618.             "1M"
  619.         };

  620.         double[] adblShortEndOISQuote = new double[] {
  621.             0.00070,    //   1W
  622.             0.00069,    //   2W
  623.             0.00078,    //   3W
  624.             0.00074     //   1M
  625.         };

  626.         /*
  627.          * Construct the Array of OIS Futures Instruments and their Quotes from the given set of parameters
  628.          */

  629.         final String[] astrOISFutureTenor = new java.lang.String[] {
  630.             "1M",
  631.             "1M",
  632.             "1M",
  633.             "1M",
  634.             "1M"
  635.         };

  636.         final String[] astrOISFutureMaturityTenor = new java.lang.String[] {
  637.             "1M",
  638.             "2M",
  639.             "3M",
  640.             "4M",
  641.             "5M"
  642.         };

  643.         double[] adblOISFutureQuote = new double[] {
  644.              0.00046,    //   1M x 1M
  645.              0.00016,    //   2M x 1M
  646.             -0.00007,    //   3M x 1M
  647.             -0.00013,    //   4M x 1M
  648.             -0.00014     //   5M x 1M
  649.         };

  650.         /*
  651.          * Construct the Array of Long End OIS Instruments and their Quotes from the given set of parameters
  652.          */

  653.         String[] astrLongEndOISMaturityTenor = new java.lang.String[] {
  654.             "15M",
  655.             "18M",
  656.             "21M",
  657.             "2Y",
  658.             "3Y",
  659.             "4Y",
  660.             "5Y",
  661.             "6Y",
  662.             "7Y",
  663.             "8Y",
  664.             "9Y",
  665.             "10Y",
  666.             "11Y",
  667.             "12Y",
  668.             "15Y",
  669.             "20Y",
  670.             "25Y",
  671.             "30Y"
  672.         };

  673.         double[] adblLongEndOISQuote = new double[] {
  674.             0.00002,    //  15M
  675.             0.00008,    //  18M
  676.             0.00021,    //  21M
  677.             0.00036,    //   2Y
  678.             0.00127,    //   3Y
  679.             0.00274,    //   4Y
  680.             0.00456,    //   5Y
  681.             0.00647,    //   6Y
  682.             0.00827,    //   7Y
  683.             0.00996,    //   8Y
  684.             0.01147,    //   9Y
  685.             0.01280,    //  10Y
  686.             0.01404,    //  11Y
  687.             0.01516,    //  12Y
  688.             0.01764,    //  15Y
  689.             0.01939,    //  20Y
  690.             0.02003,    //  25Y
  691.             0.02038     //  30Y
  692.         };

  693.         SegmentCustomBuilderControl scbcCubic = new SegmentCustomBuilderControl (
  694.             MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  695.             new PolynomialFunctionSetParams (4),
  696.             SegmentInelasticDesignControl.Create (
  697.                 2,
  698.                 2
  699.             ),
  700.             new ResponseScalingShapeControl (
  701.                 true,
  702.                 new QuadraticRationalShapeControl (0.)
  703.             ),
  704.             null
  705.         );

  706.         return MakeDC (
  707.             strCurrency,
  708.             dtSpot,
  709.             aiDepositMaturityDays,
  710.             adblDepositQuote,
  711.             astrShortEndOISMaturityTenor,
  712.             adblShortEndOISQuote,
  713.             astrOISFutureTenor,
  714.             astrOISFutureMaturityTenor,
  715.             adblOISFutureQuote,
  716.             astrLongEndOISMaturityTenor,
  717.             adblLongEndOISQuote,
  718.             scbcCubic,
  719.             null
  720.         );
  721.     }
  722. }