RollerCoasterSwap.java

  1. package org.drip.sample.fixfloat;

  2. import java.util.List;

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

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

  25. /*!
  26.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  27.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  28.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  29.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  30.  * Copyright (C) 2015 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>RollerCoasterSwap</i> demonstrates the construction and Valuation of In-Advance Roller-Coaster Swap.
  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/fixfloat/README.md">Fix Float Swap Analytics</a></li>
  96.  *  </ul>
  97.  * <br><br>
  98.  *
  99.  * @author Lakshmi Krishnamurthy
  100.  */

  101. public class RollerCoasterSwap {

  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.         throws Exception
  112.     {
  113.         SingleStreamComponent[] aDeposit = new SingleStreamComponent[aiDay.length];

  114.         ComposableFloatingUnitSetting cfus = new ComposableFloatingUnitSetting (
  115.             "3M",
  116.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_SINGLE,
  117.             null,
  118.             ForwardLabel.Create (
  119.                 strCurrency,
  120.                 "3M"
  121.             ),
  122.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  123.             0.
  124.         );

  125.         CompositePeriodSetting cps = new CompositePeriodSetting (
  126.             4,
  127.             "3M",
  128.             strCurrency,
  129.             null,
  130.             1.,
  131.             null,
  132.             null,
  133.             null,
  134.             null
  135.         );

  136.         CashSettleParams csp = new CashSettleParams (
  137.             0,
  138.             strCurrency,
  139.             0
  140.         );

  141.         for (int i = 0; i < aiDay.length; ++i) {
  142.             aDeposit[i] = new SingleStreamComponent (
  143.                 "DEPOSIT_" + aiDay[i],
  144.                 new Stream (
  145.                     CompositePeriodBuilder.FloatingCompositeUnit (
  146.                         CompositePeriodBuilder.EdgePair (
  147.                             dtEffective,
  148.                             dtEffective.addBusDays (
  149.                                 aiDay[i],
  150.                                 strCurrency
  151.                             )
  152.                         ),
  153.                         cps,
  154.                         cfus
  155.                     )
  156.                 ),
  157.                 csp
  158.             );

  159.             aDeposit[i].setPrimaryCode (aiDay[i] + "D");
  160.         }

  161.         return aDeposit;
  162.     }

  163.     /*
  164.      * Construct the Array of Swap Instruments from the given set of parameters
  165.      *
  166.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  167.      */

  168.     private static final FixFloatComponent[] SwapInstrumentsFromMaturityTenor (
  169.         final JulianDate dtEffective,
  170.         final String strCurrency,
  171.         final Array2D fsNotional,
  172.         final String[] astrMaturityTenor)
  173.         throws Exception
  174.     {
  175.         FixFloatComponent[] aIRS = new FixFloatComponent[astrMaturityTenor.length];

  176.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  177.             2,
  178.             "Act/360",
  179.             false,
  180.             "Act/360",
  181.             false,
  182.             strCurrency,
  183.             true,
  184.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  185.         );

  186.         ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  187.             "6M",
  188.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  189.             null,
  190.             ForwardLabel.Create (
  191.                 strCurrency,
  192.                 "6M"
  193.             ),
  194.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  195.             0.
  196.         );

  197.         ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  198.             "6M",
  199.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  200.             null,
  201.             0.,
  202.             0.,
  203.             strCurrency
  204.         );

  205.         CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  206.             2,
  207.             "6M",
  208.             strCurrency,
  209.             null,
  210.             -1.,
  211.             null,
  212.             fsNotional,
  213.             null,
  214.             null
  215.         );

  216.         CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  217.             2,
  218.             "6M",
  219.             strCurrency,
  220.             null,
  221.             1.,
  222.             null,
  223.             fsNotional,
  224.             null,
  225.             null
  226.         );

  227.         CashSettleParams csp = new CashSettleParams (
  228.             0,
  229.             strCurrency,
  230.             0
  231.         );

  232.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  233.             List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  234.                 dtEffective,
  235.                 "6M",
  236.                 astrMaturityTenor[i],
  237.                 null
  238.             );

  239.             List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  240.                 dtEffective,
  241.                 "6M",
  242.                 astrMaturityTenor[i],
  243.                 null
  244.             );

  245.             Stream floatingStream = new Stream (
  246.                 CompositePeriodBuilder.FloatingCompositeUnit (
  247.                     lsFloatingStreamEdgeDate,
  248.                     cpsFloating,
  249.                     cfusFloating
  250.                 )
  251.             );

  252.             Stream fixedStream = new Stream (
  253.                 CompositePeriodBuilder.FixedCompositeUnit (
  254.                     lsFixedStreamEdgeDate,
  255.                     cpsFixed,
  256.                     ucasFixed,
  257.                     cfusFixed
  258.                 )
  259.             );

  260.             FixFloatComponent irs = new FixFloatComponent (
  261.                 fixedStream,
  262.                 floatingStream,
  263.                 csp
  264.             );

  265.             irs.setPrimaryCode ("IRS." + astrMaturityTenor[i] + "." + strCurrency);

  266.             aIRS[i] = irs;
  267.         }

  268.         return aIRS;
  269.     }

  270.     private static final Array2D RollerCoaster1 (
  271.         final JulianDate dtSpot)
  272.     {
  273.         return Array2D.FromArray (
  274.             new double[] {
  275.                 dtSpot.julian(),
  276.                 dtSpot.addYears (2).julian(),
  277.                 dtSpot.addYears (4).julian(),
  278.                 dtSpot.addYears (6).julian(),
  279.                 dtSpot.addYears (10).julian(),
  280.                 dtSpot.addYears (15).julian(),
  281.                 dtSpot.addYears (21).julian(),
  282.                 dtSpot.addYears (29).julian(),
  283.                 dtSpot.addYears (36).julian(),
  284.                 dtSpot.addYears (51).julian()
  285.             },
  286.             new double[] {
  287.                 1.00,
  288.                 0.98,
  289.                 0.94,
  290.                 0.88,
  291.                 0.80,
  292.                 0.70,
  293.                 0.81,
  294.                 0.90,
  295.                 0.96,
  296.                 1.00
  297.             }
  298.         );
  299.     }

  300.     private static final Array2D RollerCoaster2 (
  301.         final JulianDate dtSpot)
  302.     {
  303.         return Array2D.FromArray (
  304.             new double[] {
  305.                 dtSpot.julian(),
  306.                 dtSpot.addYears (2).julian(),
  307.                 dtSpot.addYears (4).julian(),
  308.                 dtSpot.addYears (6).julian(),
  309.                 dtSpot.addYears (10).julian(),
  310.                 dtSpot.addYears (15).julian(),
  311.                 dtSpot.addYears (21).julian(),
  312.                 dtSpot.addYears (29).julian(),
  313.                 dtSpot.addYears (36).julian(),
  314.                 dtSpot.addYears (51).julian()
  315.             },
  316.             new double[] {
  317.                 1.00,
  318.                 1.02,
  319.                 1.06,
  320.                 1.12,
  321.                 1.20,
  322.                 1.30,
  323.                 1.19,
  324.                 1.10,
  325.                 1.04,
  326.                 1.00
  327.             }
  328.         );
  329.     }

  330.     /*
  331.      * This sample demonstrates discount curve calibration and input instrument calibration quote recovery.
  332.      *  It shows the following:
  333.      *  - Construct the Array of Cash/Swap Instruments and their Quotes from the given set of parameters.
  334.      *  - Construct the Cash/Swap Instrument Set Stretch Builder.
  335.      *  - Set up the Linear Curve Calibrator using the following parameters:
  336.      *      - Cubic Exponential Mixture Basis Spline Set
  337.      *      - Ck = 2, Segment Curvature Penalty = 2
  338.      *      - Quadratic Rational Shape Controller
  339.      *      - Natural Boundary Setting
  340.      *  - Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  341.      *      of Cash and Swap Stretches.
  342.      *  - Cross-Comparison of the Cash/Swap Calibration Instrument "Rate" metric across the different curve
  343.      *      construction methodologies.
  344.      *
  345.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  346.      */

  347.     private static final void CustomDiscountCurveBuilderSample (
  348.         final JulianDate dtSpot,
  349.         final String strCurrency)
  350.         throws Exception
  351.     {
  352.         /*
  353.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  354.          */

  355.         SingleStreamComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  356.             dtSpot,
  357.             strCurrency,
  358.             new int[] {
  359.                 1, 2, 7, 14, 30, 60
  360.             }
  361.         );

  362.         double[] adblDepositQuote = new double[] {
  363.             0.0013, 0.0017, 0.0017, 0.0018, 0.0020, 0.0023
  364.         };

  365.         /*
  366.          * Construct the Deposit Instrument Set Stretch Builder
  367.          */

  368.         LatentStateStretchSpec depositStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  369.             "DEPOSIT",
  370.             aDepositComp,
  371.             "ForwardRate",
  372.             adblDepositQuote
  373.         );

  374.         /*
  375.          * Construct the Array of EDF Instruments and their Quotes from the given set of parameters
  376.          */

  377.         SingleStreamComponent[] aEDFComp = SingleStreamComponentBuilder.ForwardRateFuturesPack (
  378.             dtSpot,
  379.             8,
  380.             strCurrency
  381.         );

  382.         double[] adblEDFQuote = new double[] {
  383.             0.0027, 0.0032, 0.0041, 0.0054, 0.0077, 0.0104, 0.0134, 0.0160
  384.         };

  385.         /*
  386.          * Construct the EDF Instrument Set Stretch Builder
  387.          */

  388.         LatentStateStretchSpec edfStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  389.             "EDF",
  390.             aEDFComp,
  391.             "ForwardRate",
  392.             adblEDFQuote
  393.         );

  394.         /*
  395.          * Construct the Array of Swap Instruments and their Quotes from the given set of parameters
  396.          */

  397.         FixFloatComponent[] aSwapInAdvance = SwapInstrumentsFromMaturityTenor (
  398.             dtSpot,
  399.             strCurrency,
  400.             null,
  401.             new java.lang.String[] {
  402.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  403.             }
  404.         );

  405.         FixFloatComponent[] aSwapInAdvanceRollerCoaster1 = SwapInstrumentsFromMaturityTenor (
  406.             dtSpot,
  407.             strCurrency,
  408.             RollerCoaster1 (dtSpot),
  409.             new java.lang.String[] {
  410.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  411.             }
  412.         );

  413.         FixFloatComponent[] aSwapInAdvanceRollerCoaster2 = SwapInstrumentsFromMaturityTenor (
  414.             dtSpot,
  415.             strCurrency,
  416.             RollerCoaster2 (dtSpot),
  417.             new java.lang.String[] {
  418.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  419.             }
  420.         );

  421.         double[] adblSwapQuote = new double[] {
  422.             0.0166, 0.0206, 0.0241, 0.0269, 0.0292, 0.0311, 0.0326, 0.0340, 0.0351, 0.0375, 0.0393, 0.0402, 0.0407, 0.0409, 0.0409
  423.         };

  424.         /*
  425.          * Construct the Swap Instrument Set Stretch Builder
  426.          */

  427.         LatentStateStretchSpec swapStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  428.             "SWAP",
  429.             aSwapInAdvance,
  430.             "SwapRate",
  431.             adblSwapQuote
  432.         );

  433.         LatentStateStretchSpec[] aStretchSpec = new LatentStateStretchSpec[] {
  434.             depositStretch,
  435.             edfStretch,
  436.             swapStretch
  437.         };

  438.         /*
  439.          * Set up the Linear Curve Calibrator using the following parameters:
  440.          *  - Cubic Exponential Mixture Basis Spline Set
  441.          *  - Ck = 2, Segment Curvature Penalty = 2
  442.          *  - Quadratic Rational Shape Controller
  443.          *  - Natural Boundary Setting
  444.          */

  445.         LinearLatentStateCalibrator lcc = new LinearLatentStateCalibrator (
  446.             new SegmentCustomBuilderControl (
  447.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  448.                 new PolynomialFunctionSetParams (4),
  449.                 SegmentInelasticDesignControl.Create (
  450.                     2,
  451.                     2
  452.                 ),
  453.                 new ResponseScalingShapeControl (
  454.                     true,
  455.                     new QuadraticRationalShapeControl (0.)
  456.                 ),
  457.                 null
  458.             ),
  459.             BoundarySettings.NaturalStandard(),
  460.             MultiSegmentSequence.CALIBRATE,
  461.             null,
  462.             null
  463.         );

  464.         ValuationParams valParams = new ValuationParams (
  465.             dtSpot,
  466.             dtSpot,
  467.             strCurrency
  468.         );

  469.         /*
  470.          * Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  471.          *  of Deposit, Futures, and Swap Stretches.
  472.          */

  473.         MergedDiscountForwardCurve dc = ScenarioDiscountCurveBuilder.ShapePreservingDFBuild (
  474.             strCurrency,
  475.             lcc,
  476.             aStretchSpec,
  477.             valParams,
  478.             null,
  479.             null,
  480.             null,
  481.             1.
  482.         );

  483.         CurveSurfaceQuoteContainer csqs = MarketParamsBuilder.Create (
  484.             dc,
  485.             null,
  486.             null,
  487.             null,
  488.             null,
  489.             null,
  490.             null
  491.         );

  492.         /*
  493.          * Cross-Comparison of the In-Advance/Arrears Swap "Rate" metric across the different curve
  494.          *  construction methodologies.
  495.          */

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

  497.         System.out.println ("\t     IN-ADVANCE ROLLER COASTER SWAP METRIC COMPARISON");

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

  499.         System.out.println ("\t\tL -> R:");

  500.         System.out.println ("\t\t\t - Swap Maturity");

  501.         System.out.println ("\t\t\t - In Advance Calibration Quote");

  502.         System.out.println ("\t\t\t - In Advance Fair Premium");

  503.         System.out.println ("\t\t\t - In Advance Swap Rate");

  504.         System.out.println ("\t\t\t - In Advance Roller Coaster #1 Swap Rate");

  505.         System.out.println ("\t\t\t - In Advance Roller Coaster #2 Swap Rate");

  506.         System.out.println ("\t\t\t - In Advance Roller Coaster #1 Swap Rate Shift");

  507.         System.out.println ("\t\t\t - In Advance Roller Coaster #2 Swap Rate Shift");

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

  509.         for (int i = 0; i < aSwapInAdvance.length; ++i) {
  510.             double dblInAdvanceRollerCoaster1FairPremium = aSwapInAdvanceRollerCoaster1[i].measureValue (
  511.                 valParams,
  512.                 null,
  513.                 csqs,
  514.                 null,
  515.                 "FairPremium"
  516.             );

  517.             double dblInAdvanceRollerCoaster2FairPremium = aSwapInAdvanceRollerCoaster2[i].measureValue (
  518.                 valParams,
  519.                 null,
  520.                 csqs,
  521.                 null,
  522.                 "FairPremium"
  523.             );

  524.             System.out.println ("\t[" + aSwapInAdvance[i].maturityDate() + "] = " +
  525.                 FormatUtil.FormatDouble (aSwapInAdvance[i].measureValue (valParams, null, csqs, null, "CalibSwapRate"), 1, 4, 100.) + "% | " +
  526.                 FormatUtil.FormatDouble (adblSwapQuote[i], 1, 4, 100.) + "% | " +
  527.                 FormatUtil.FormatDouble (aSwapInAdvance[i].measureValue (valParams, null, csqs, null, "FairPremium"), 1, 4, 100.) + "% | " +
  528.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster1FairPremium, 1, 4, 100.) + "% | " +
  529.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster1FairPremium - adblSwapQuote[i], 1, 0, 10000.) + " | " +
  530.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster2FairPremium, 1, 4, 100.) + "% | " +
  531.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster2FairPremium - adblSwapQuote[i], 1, 0, 10000.)
  532.             );
  533.         }

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

  535.         System.out.println ("\t     IN-ADVANCE ROLLER COASTER SWAP DV01 COMPARISON");

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

  537.         System.out.println ("\t\tL -> R:");

  538.         System.out.println ("\t\t\t - Swap Maturity");

  539.         System.out.println ("\t\t\t - In Advance Swap DV01");

  540.         System.out.println ("\t\t\t - In Advance Roller Coaster #1 DV01");

  541.         System.out.println ("\t\t\t - In Advance Roller Coaster #1 DV01 Shift");

  542.         System.out.println ("\t\t\t - In Advance Roller Coaster #2 DV01");

  543.         System.out.println ("\t\t\t - In Advance Roller Coaster #2 DV01 Shift");

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

  545.         for (int i = 0; i < aSwapInAdvance.length; ++i) {
  546.             double dblInAdvanceDV01 = aSwapInAdvance[i].measureValue (
  547.                 valParams,
  548.                 null,
  549.                 csqs,
  550.                 null,
  551.                 "FixedDV01"
  552.             );

  553.             double dblInAdvanceRollerCoaster1DV01 = aSwapInAdvanceRollerCoaster1[i].measureValue (
  554.                 valParams,
  555.                 null,
  556.                 csqs,
  557.                 null,
  558.                 "FixedDV01"
  559.             );

  560.             double dblInAdvanceRollerCoaster2DV01 = aSwapInAdvanceRollerCoaster2[i].measureValue (
  561.                 valParams,
  562.                 null,
  563.                 csqs,
  564.                 null,
  565.                 "FixedDV01"
  566.             );

  567.             System.out.println ("\t[" + aSwapInAdvance[i].maturityDate() + "] = " +
  568.                 FormatUtil.FormatDouble (dblInAdvanceDV01, 2, 1, 10000.) + " | " +
  569.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster1DV01, 2, 1, 10000.) + " | " +
  570.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster1DV01 - dblInAdvanceDV01, 1, 2, 10000.) + " | " +
  571.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster2DV01, 2, 1, 10000.) + " | " +
  572.                 FormatUtil.FormatDouble (dblInAdvanceRollerCoaster2DV01 - dblInAdvanceDV01, 1, 2, 10000.)
  573.             );
  574.         }

  575.         System.out.println ("\t-------------------------------------------------------------------------------");
  576.     }

  577.     public static final void main (
  578.         final String[] astrArgs)
  579.         throws Exception
  580.     {
  581.         /*
  582.          * Initialize the Credit Analytics Library
  583.          */

  584.         EnvManager.InitEnv ("");

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

  586.         String strCurrency = "USD";

  587.         CustomDiscountCurveBuilderSample (
  588.             dtToday,
  589.             strCurrency
  590.         );

  591.         EnvManager.TerminateEnv();
  592.     }
  593. }