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

  102. public class AmortizingCapitalizingAccruingSwap {

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

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

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

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

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

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

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

  162.         return aDeposit;
  163.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  269.         return aIRS;
  270.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  498.         System.out.println ("\t     IN-ADVANCE AMORTIZING/ACCRUING SWAP METRIC COMPARISON");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  536.         System.out.println ("\t     IN-ADVANCE AMORTIZING/ACCRUING SWAP DV01 COMPARISON");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  585.         EnvManager.InitEnv ("");

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

  587.         String strCurrency = "USD";

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

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