StepUpStepDown.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.Array2D;
  7. import org.drip.numerical.common.FormatUtil;
  8. import org.drip.param.creator.*;
  9. import org.drip.param.market.CurveSurfaceQuoteContainer;
  10. import org.drip.param.period.*;
  11. import org.drip.param.valuation.*;
  12. import org.drip.product.creator.*;
  13. import org.drip.product.rates.*;
  14. import org.drip.service.env.EnvManager;
  15. import org.drip.spline.basis.PolynomialFunctionSetParams;
  16. import org.drip.spline.params.*;
  17. import org.drip.spline.stretch.*;
  18. import org.drip.state.creator.ScenarioDiscountCurveBuilder;
  19. import org.drip.state.discount.*;
  20. import org.drip.state.estimator.LatentStateStretchBuilder;
  21. import org.drip.state.identifier.*;
  22. import org.drip.state.inference.*;

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

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

  88. /**
  89.  * <i>StepUpStepDown</i> demonstrates the construction and Valuation of in-advance step-up and step-down
  90.  * swaps.
  91.  *  
  92.  * <br><br>
  93.  *  <ul>
  94.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  95.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  96.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  97.  *      <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>
  98.  *  </ul>
  99.  * <br><br>
  100.  *
  101.  * @author Lakshmi Krishnamurthy
  102.  */

  103. public class StepUpStepDown {

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

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

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

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

  138.         CashSettleParams csp = new CashSettleParams (
  139.             0,
  140.             strCurrency,
  141.             0
  142.         );

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

  161.             aDeposit[i].setPrimaryCode (aiDay[i] + "D");
  162.         }

  163.         return aDeposit;
  164.     }

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

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

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

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

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

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

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

  229.         CashSettleParams csp = new CashSettleParams (
  230.             0,
  231.             strCurrency,
  232.             0
  233.         );

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

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

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

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

  262.             FixFloatComponent irs = new FixFloatComponent (
  263.                 fixedStream,
  264.                 floatingStream,
  265.                 csp
  266.             );

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

  268.             aIRS[i] = irs;
  269.         }

  270.         return aIRS;
  271.     }

  272.     private static final Array2D StepDown (
  273.         final JulianDate dtSpot)
  274.     {
  275.         return Array2D.FromArray (
  276.             new double[] {
  277.                 dtSpot.julian(),
  278.                 dtSpot.addYears (2).julian(),
  279.                 dtSpot.addYears (4).julian(),
  280.                 dtSpot.addYears (6).julian(),
  281.                 dtSpot.addYears (10).julian(),
  282.                 dtSpot.addYears (15).julian(),
  283.                 dtSpot.addYears (21).julian(),
  284.                 dtSpot.addYears (29).julian(),
  285.                 dtSpot.addYears (36).julian(),
  286.                 dtSpot.addYears (51).julian()
  287.             },
  288.             new double[] {
  289.                 1.00,
  290.                 0.99,
  291.                 0.97,
  292.                 0.94,
  293.                 0.90,
  294.                 0.85,
  295.                 0.78,
  296.                 0.70,
  297.                 0.61,
  298.                 0.51
  299.             }
  300.         );
  301.     }

  302.     private static final Array2D StepUp (
  303.         final JulianDate dtSpot)
  304.     {
  305.         return Array2D.FromArray (
  306.             new double[] {
  307.                 dtSpot.julian(),
  308.                 dtSpot.addYears (2).julian(),
  309.                 dtSpot.addYears (4).julian(),
  310.                 dtSpot.addYears (6).julian(),
  311.                 dtSpot.addYears (10).julian(),
  312.                 dtSpot.addYears (15).julian(),
  313.                 dtSpot.addYears (21).julian(),
  314.                 dtSpot.addYears (29).julian(),
  315.                 dtSpot.addYears (36).julian(),
  316.                 dtSpot.addYears (51).julian()
  317.             },
  318.             new double[] {
  319.                 1.00,
  320.                 1.01,
  321.                 1.03,
  322.                 1.06,
  323.                 1.10,
  324.                 1.15,
  325.                 1.21,
  326.                 1.28,
  327.                 1.36,
  328.                 1.45
  329.             }
  330.         );
  331.     }

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

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

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

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

  367.         /*
  368.          * Construct the Deposit Instrument Set Stretch Builder
  369.          */

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

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

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

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

  387.         /*
  388.          * Construct the EDF Instrument Set Stretch Builder
  389.          */

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

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

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

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

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

  423.         double[] adblSwapQuote = new double[] {
  424.             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
  425.         };

  426.         /*
  427.          * Construct the Swap Instrument Set Stretch Builder
  428.          */

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

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

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

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

  466.         ValuationParams valParams = new ValuationParams (
  467.             dtSpot,
  468.             dtSpot,
  469.             strCurrency
  470.         );

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

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

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

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

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

  499.         System.out.println ("\t     IN-ADVANCE STEP UP/DOWN SWAP METRIC COMPARISON");

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

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

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

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

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

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

  506.         System.out.println ("\t\t\t - In Advance Step Up Swap Rate");

  507.         System.out.println ("\t\t\t - In Advance Step Down Swap Rate");

  508.         System.out.println ("\t\t\t - In Advance Step Up Swap Rate Shift");

  509.         System.out.println ("\t\t\t - In Advance Step Down Swap Rate Shift");

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

  511.         for (int i = 0; i < aSwapInAdvance.length; ++i) {
  512.             double dblInAdvanceStepUpFairPremium = aSwapInAdvanceStepUp[i].measureValue (
  513.                 valParams,
  514.                 null,
  515.                 csqs,
  516.                 null,
  517.                 "FairPremium"
  518.             );

  519.             double dblInAdvanceStepDownFairPremium = aSwapInAdvanceStepDown[i].measureValue (
  520.                 valParams,
  521.                 null,
  522.                 csqs,
  523.                 null,
  524.                 "FairPremium"
  525.             );

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

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

  537.         System.out.println ("\t     IN-ADVANCE STEP UP/DOWN SWAP DV01 COMPARISON");

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

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

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

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

  542.         System.out.println ("\t\t\t - In Advance Step Up Swap DV01");

  543.         System.out.println ("\t\t\t - In Advance Step Up Swap DV01 Shift");

  544.         System.out.println ("\t\t\t - In Advance Step Down Swap DV01");

  545.         System.out.println ("\t\t\t - In Advance Step Down Swap DV01 Shift");

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

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

  555.             double dblInAdvanceStepUpDV01 = aSwapInAdvanceStepUp[i].measureValue (
  556.                 valParams,
  557.                 null,
  558.                 csqs,
  559.                 null,
  560.                 "FixedDV01"
  561.             );

  562.             double dblInAdvanceStepDownDV01 = aSwapInAdvanceStepDown[i].measureValue (
  563.                 valParams,
  564.                 null,
  565.                 csqs,
  566.                 null,
  567.                 "FixedDV01"
  568.             );

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

  577.         System.out.println ("\t-------------------------------------------------------------------------------");
  578.     }

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

  586.         EnvManager.InitEnv ("");

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

  588.         String strCurrency = "USD";

  589.         CustomDiscountCurveBuilderSample (
  590.             dtToday,
  591.             strCurrency
  592.         );

  593.         EnvManager.TerminateEnv();
  594.     }
  595. }