LongTenorSwap.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.FormatUtil;
  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>LongTenorSwap</i> demonstrates the Construction and Valuation of In-Advance and In-Arrears Long Tenor
  89.  * Swap.
  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 LongTenorSwap {

  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.         final int iRefPeriodType)
  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.             iRefPeriodType,
  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 String[] astrMaturityTenor,
  174.         final int iRefPeriodType,
  175.         final String strFloatingTenor,
  176.         final String strCompositeTenor)
  177.         throws Exception
  178.     {
  179.         FixFloatComponent[] aIRS = new FixFloatComponent[astrMaturityTenor.length];

  180.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  181.             Helper.TenorToFreq (strCompositeTenor),
  182.             "Act/360",
  183.             false,
  184.             "Act/360",
  185.             false,
  186.             strCurrency,
  187.             true,
  188.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  189.         );

  190.         ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  191.             strCompositeTenor,
  192.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  193.             null,
  194.             ForwardLabel.Create (
  195.                 strCurrency,
  196.                 strFloatingTenor
  197.             ),
  198.             iRefPeriodType,
  199.             0.
  200.         );

  201.         ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  202.             strCompositeTenor,
  203.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  204.             null,
  205.             0.,
  206.             0.,
  207.             strCurrency
  208.         );

  209.         CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  210.             Helper.TenorToFreq (strCompositeTenor),
  211.             strCompositeTenor,
  212.             strCurrency,
  213.             null,
  214.             -1.,
  215.             null,
  216.             null,
  217.             null,
  218.             null
  219.         );

  220.         CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  221.             Helper.TenorToFreq (strCompositeTenor),
  222.             strCompositeTenor,
  223.             strCurrency,
  224.             null,
  225.             1.,
  226.             null,
  227.             null,
  228.             null,
  229.             null
  230.         );

  231.         CashSettleParams csp = new CashSettleParams (
  232.             0,
  233.             strCurrency,
  234.             0
  235.         );

  236.         for (int i = 0; i < astrMaturityTenor.length; ++i) {
  237.             List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  238.                 dtEffective,
  239.                 strCompositeTenor,
  240.                 astrMaturityTenor[i],
  241.                 null
  242.             );

  243.             List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  244.                 dtEffective,
  245.                 strCompositeTenor,
  246.                 astrMaturityTenor[i],
  247.                 null
  248.             );

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

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

  264.             FixFloatComponent irs = new FixFloatComponent (
  265.                 fixedStream,
  266.                 floatingStream,
  267.                 csp
  268.             );

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

  270.             aIRS[i] = irs;
  271.         }

  272.         return aIRS;
  273.     }

  274.     /*
  275.      * This sample demonstrates discount curve calibration and input instrument calibration quote recovery.
  276.      *  It shows the following:
  277.      *  - Construct the Array of Cash/Swap Instruments and their Quotes from the given set of parameters.
  278.      *  - Construct the Cash/Swap Instrument Set Stretch Builder.
  279.      *  - Set up the Linear Curve Calibrator using the following parameters:
  280.      *      - Cubic Exponential Mixture Basis Spline Set
  281.      *      - Ck = 2, Segment Curvature Penalty = 2
  282.      *      - Quadratic Rational Shape Controller
  283.      *      - Natural Boundary Setting
  284.      *  - Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  285.      *      of Cash and Swap Stretches.
  286.      *  - Cross-Comparison of the Cash/Swap Calibration Instrument "Rate" metric across the different curve
  287.      *      construction methodologies.
  288.      *
  289.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  290.      */

  291.     private static final void CustomDiscountCurveBuilderSample (
  292.         final JulianDate dtSpot,
  293.         final String strCurrency)
  294.         throws Exception
  295.     {
  296.         /*
  297.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  298.          */

  299.         SingleStreamComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  300.             dtSpot,
  301.             strCurrency,
  302.             new int[] {
  303.                 1, 2, 7, 14, 30, 60
  304.             },
  305.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE
  306.         );

  307.         double[] adblDepositQuote = new double[] {
  308.             0.0013, 0.0017, 0.0017, 0.0018, 0.0020, 0.0023
  309.         };

  310.         /*
  311.          * Construct the Deposit Instrument Set Stretch Builder
  312.          */

  313.         LatentStateStretchSpec depositStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  314.             "DEPOSIT",
  315.             aDepositComp,
  316.             "ForwardRate",
  317.             adblDepositQuote
  318.         );

  319.         /*
  320.          * Construct the Array of EDF Instruments and their Quotes from the given set of parameters
  321.          */

  322.         SingleStreamComponent[] aEDFComp = SingleStreamComponentBuilder.ForwardRateFuturesPack (
  323.             dtSpot,
  324.             8,
  325.             strCurrency
  326.         );

  327.         double[] adblEDFQuote = new double[] {
  328.             0.0027, 0.0032, 0.0041, 0.0054, 0.0077, 0.0104, 0.0134, 0.0160
  329.         };

  330.         /*
  331.          * Construct the EDF Instrument Set Stretch Builder
  332.          */

  333.         LatentStateStretchSpec edfStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  334.             "EDF",
  335.             aEDFComp,
  336.             "ForwardRate",
  337.             adblEDFQuote
  338.         );

  339.         /*
  340.          * Construct the Array of Swap Instruments and their Quotes from the given set of parameters
  341.          */

  342.         FixFloatComponent[] aSwapInAdvance = SwapInstrumentsFromMaturityTenor (
  343.             dtSpot,
  344.             strCurrency,
  345.             new java.lang.String[] {
  346.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  347.             },
  348.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  349.             "6M",
  350.             "6M"
  351.         );

  352.         FixFloatComponent[] aSwapInAdvanceLongTenor = SwapInstrumentsFromMaturityTenor (
  353.             dtSpot,
  354.             strCurrency,
  355.             new java.lang.String[] {
  356.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  357.             },
  358.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  359.             "3M",
  360.             "12M"
  361.         );

  362.         FixFloatComponent[] aSwapInArrearsLongTenor = SwapInstrumentsFromMaturityTenor (
  363.             dtSpot,
  364.             strCurrency,
  365.             new java.lang.String[] {
  366.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  367.             },
  368.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ARREARS,
  369.             "3M",
  370.             "12M"
  371.         );

  372.         double[] adblSwapQuote = new double[] {
  373.             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
  374.         };

  375.         /*
  376.          * Construct the Swap Instrument Set Stretch Builder
  377.          */

  378.         LatentStateStretchSpec swapStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  379.             "SWAP",
  380.             aSwapInAdvance,
  381.             "SwapRate",
  382.             adblSwapQuote
  383.         );

  384.         LatentStateStretchSpec[] aStretchSpec = new LatentStateStretchSpec[] {
  385.             depositStretch,
  386.             edfStretch,
  387.             swapStretch
  388.         };

  389.         /*
  390.          * Set up the Linear Curve Calibrator using the following parameters:
  391.          *  - Cubic Exponential Mixture Basis Spline Set
  392.          *  - Ck = 2, Segment Curvature Penalty = 2
  393.          *  - Quadratic Rational Shape Controller
  394.          *  - Natural Boundary Setting
  395.          */

  396.         LinearLatentStateCalibrator lcc = new LinearLatentStateCalibrator (
  397.             new SegmentCustomBuilderControl (
  398.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  399.                 new PolynomialFunctionSetParams (4),
  400.                 SegmentInelasticDesignControl.Create (
  401.                     2,
  402.                     2
  403.                 ),
  404.                 new ResponseScalingShapeControl (
  405.                     true,
  406.                     new QuadraticRationalShapeControl (0.)
  407.                 ),
  408.                 null
  409.             ),
  410.             BoundarySettings.NaturalStandard(),
  411.             MultiSegmentSequence.CALIBRATE,
  412.             null,
  413.             null
  414.         );

  415.         ValuationParams valParams = new ValuationParams (
  416.             dtSpot,
  417.             dtSpot,
  418.             strCurrency
  419.         );

  420.         /*
  421.          * Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  422.          *  of Deposit, Futures, and Swap Stretches.
  423.          */

  424.         MergedDiscountForwardCurve dc = ScenarioDiscountCurveBuilder.ShapePreservingDFBuild (
  425.             strCurrency,
  426.             lcc,
  427.             aStretchSpec,
  428.             valParams,
  429.             null,
  430.             null,
  431.             null,
  432.             1.
  433.         );

  434.         CurveSurfaceQuoteContainer csqs = MarketParamsBuilder.Create (
  435.             dc,
  436.             null,
  437.             null,
  438.             null,
  439.             null,
  440.             null,
  441.             null
  442.         );

  443.         /*
  444.          * Cross-Comparison of the In-Advance/Arrears Swap "Rate" metric across the different curve
  445.          *  construction methodologies.
  446.          */

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

  448.         System.out.println ("\t            IN-ADVANCE/IN-ARREARS LONG TENOR SWAP METRIC COMPARISON");

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

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

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

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

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

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

  455.         System.out.println ("\t\t\t - In Advance Long Tenor Swap Rate");

  456.         System.out.println ("\t\t\t - In Arrears Long Tenor Swap Rate");

  457.         System.out.println ("\t\t\t - In Advance Long Tenor Swap Rate Shift");

  458.         System.out.println ("\t\t\t - In Arrears Long Tenor Swap Rate Shift");

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

  460.         for (int i = 0; i < aSwapInAdvance.length; ++i) {
  461.             double dblInAdvanceLongTenorFairPremium = aSwapInAdvanceLongTenor[i].measureValue (
  462.                 valParams,
  463.                 null,
  464.                 csqs,
  465.                 null,
  466.                 "FairPremium"
  467.             );

  468.             double dblInArrearsLongTenorFairPremium = aSwapInArrearsLongTenor[i].measureValue (
  469.                 valParams,
  470.                 null,
  471.                 csqs,
  472.                 null,
  473.                 "FairPremium"
  474.             );

  475.             System.out.println ("\t[" + aSwapInAdvance[i].maturityDate() + "] = " +
  476.                 FormatUtil.FormatDouble (aSwapInAdvance[i].measureValue (valParams, null, csqs, null, "CalibSwapRate"), 1, 4, 100.) + "% | " +
  477.                 FormatUtil.FormatDouble (adblSwapQuote[i], 1, 4, 100.) + "% | " +
  478.                 FormatUtil.FormatDouble (aSwapInAdvance[i].measureValue (valParams, null, csqs, null, "FairPremium"), 1, 4, 100.) + "% | " +
  479.                 FormatUtil.FormatDouble (dblInAdvanceLongTenorFairPremium, 1, 4, 100.) + "% | " +
  480.                 FormatUtil.FormatDouble (dblInArrearsLongTenorFairPremium, 1, 4, 100.) + "% | " +
  481.                 FormatUtil.FormatDouble (dblInAdvanceLongTenorFairPremium - adblSwapQuote[i], 1, 0, 10000.) + " | " +
  482.                 FormatUtil.FormatDouble (dblInArrearsLongTenorFairPremium - adblSwapQuote[i], 1, 0, 10000.)
  483.             );
  484.         }

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

  486.         System.out.println ("\t            IN-ADVANCE/IN-ARREARS LONG TENOR SWAP DV01 COMPARISON");

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

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

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

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

  491.         System.out.println ("\t\t\t - In Advance Long Tenor Swap DV01");

  492.         System.out.println ("\t\t\t - In Arrears Long Tenor Swap DV01");

  493.         System.out.println ("\t\t\t - In Advance Long Tenor Swap DV01 Shift");

  494.         System.out.println ("\t\t\t - In Arrears Long Tenor Swap DV01 Shift");

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

  496.         for (int i = 0; i < aSwapInAdvance.length; ++i) {
  497.             double dblInAdvanceDV01 = aSwapInAdvance[i].measureValue (
  498.                 valParams,
  499.                 null,
  500.                 csqs,
  501.                 null,
  502.                 "FixedDV01"
  503.             );

  504.             double dblInAdvanceLongTenorDV01 = aSwapInAdvanceLongTenor[i].measureValue (
  505.                 valParams,
  506.                 null,
  507.                 csqs,
  508.                 null,
  509.                 "FixedDV01"
  510.             );

  511.             double dblInArrearsLongTenorDV01 = aSwapInAdvanceLongTenor[i].measureValue (
  512.                 valParams,
  513.                 null,
  514.                 csqs,
  515.                 null,
  516.                 "FixedDV01"
  517.             );

  518.             System.out.println ("\t[" + aSwapInAdvance[i].maturityDate() + "] = " +
  519.                 FormatUtil.FormatDouble (dblInAdvanceDV01, 2, 1, 10000.) + " | " +
  520.                 FormatUtil.FormatDouble (dblInAdvanceLongTenorDV01, 2, 1, 10000.) + " | " +
  521.                 FormatUtil.FormatDouble (dblInArrearsLongTenorDV01, 2, 1, 10000.) + " | " +
  522.                 FormatUtil.FormatDouble (dblInAdvanceLongTenorDV01 - dblInAdvanceDV01, 1, 2, 10000.) + " | " +
  523.                 FormatUtil.FormatDouble (dblInArrearsLongTenorDV01 - dblInAdvanceDV01, 1, 2, 10000.)
  524.             );
  525.         }

  526.         System.out.println ("\t-------------------------------------------------------------------------------");
  527.     }

  528.     public static final void main (
  529.         final String[] astrArgs)
  530.         throws Exception
  531.     {
  532.         /*
  533.          * Initialize the Credit Analytics Library
  534.          */

  535.         EnvManager.InitEnv ("");

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

  537.         String strCurrency = "USD";

  538.         CustomDiscountCurveBuilderSample (
  539.             dtToday,
  540.             strCurrency
  541.         );

  542.         EnvManager.TerminateEnv();
  543.     }
  544. }