TreasuryFixedBullet.java

  1. package org.drip.sample.treasury;

  2. import java.util.Map;

  3. import org.drip.analytics.date.*;
  4. import org.drip.analytics.output.BondRVMeasures;
  5. import org.drip.analytics.support.Helper;
  6. import org.drip.numerical.common.FormatUtil;
  7. import org.drip.param.creator.MarketParamsBuilder;
  8. import org.drip.param.market.CurveSurfaceQuoteContainer;
  9. import org.drip.param.quote.*;
  10. import org.drip.param.valuation.*;
  11. import org.drip.product.creator.BondBuilder;
  12. import org.drip.product.credit.BondComponent;
  13. import org.drip.product.definition.*;
  14. import org.drip.service.env.EnvManager;
  15. import org.drip.service.template.*;
  16. import org.drip.state.discount.MergedDiscountForwardCurve;
  17. import org.drip.state.govvie.GovvieCurve;

  18. /*
  19.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  20.  */

  21. /*!
  22.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  23.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  24.  *
  25.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  26.  *      libraries targeting analysts and developers
  27.  *      https://lakshmidrip.github.io/DRIP/
  28.  *  
  29.  *  DRIP is composed of four main libraries:
  30.  *  
  31.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  32.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  33.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  34.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  35.  *
  36.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  37.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  38.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  39.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  40.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  41.  *
  42.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  43.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  44.  *
  45.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  46.  *
  47.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  48.  *
  49.  *  Licensed under the Apache License, Version 2.0 (the "License");
  50.  *      you may not use this file except in compliance with the License.
  51.  *  
  52.  *  You may obtain a copy of the License at
  53.  *      http://www.apache.org/licenses/LICENSE-2.0
  54.  *  
  55.  *  Unless required by applicable law or agreed to in writing, software
  56.  *      distributed under the License is distributed on an "AS IS" BASIS,
  57.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  58.  *  
  59.  *  See the License for the specific language governing permissions and
  60.  *      limitations under the License.
  61.  */

  62. /**
  63.  * TreasuryFixedBullet demonstrates Non-EOS Fixed Coupon Treasury Bond Pricing and Relative Value Measure
  64.  *  Generation Functionality.
  65.  *
  66.  * @author Lakshmi Krishnamurthy
  67.  */

  68. public class TreasuryFixedBullet {

  69.     private static final MergedDiscountForwardCurve FundingCurve (
  70.         final JulianDate dtSpot,
  71.         final String strCurrency)
  72.         throws Exception
  73.     {
  74.         String[] astrDepositMaturityTenor = new String[] {
  75.             "2D"
  76.         };

  77.         double[] adblDepositQuote = new double[] {
  78.             0.0111956 // 2D
  79.         };

  80.         double[] adblFuturesQuote = new double[] {
  81.             0.011375,   // 98.8625
  82.             0.013350,   // 98.6650
  83.             0.014800,   // 98.5200
  84.             0.016450,   // 98.3550
  85.             0.017850,   // 98.2150
  86.             0.019300    // 98.0700
  87.         };

  88.         String[] astrFixFloatMaturityTenor = new String[] {
  89.             "02Y",
  90.             "03Y",
  91.             "04Y",
  92.             "05Y",
  93.             "06Y",
  94.             "07Y",
  95.             "08Y",
  96.             "09Y",
  97.             "10Y",
  98.             "11Y",
  99.             "12Y",
  100.             "15Y",
  101.             "20Y",
  102.             "25Y",
  103.             "30Y",
  104.             "40Y",
  105.             "50Y"
  106.         };

  107.         double[] adblFixFloatQuote = new double[] {
  108.             0.017029, //  2Y
  109.             0.019354, //  3Y
  110.             0.021044, //  4Y
  111.             0.022291, //  5Y
  112.             0.023240, //  6Y
  113.             0.024025, //  7Y
  114.             0.024683, //  8Y
  115.             0.025243, //  9Y
  116.             0.025720, // 10Y
  117.             0.026130, // 11Y
  118.             0.026495, // 12Y
  119.             0.027230, // 15Y
  120.             0.027855, // 20Y
  121.             0.028025, // 25Y
  122.             0.028028, // 30Y
  123.             0.027902, // 40Y
  124.             0.027655  // 50Y
  125.         };

  126.         MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve (
  127.             dtSpot,
  128.             strCurrency,
  129.             astrDepositMaturityTenor,
  130.             adblDepositQuote,
  131.             "ForwardRate",
  132.             adblFuturesQuote,
  133.             "ForwardRate",
  134.             astrFixFloatMaturityTenor,
  135.             adblFixFloatQuote,
  136.             "SwapRate"
  137.         );

  138.         Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit (
  139.             dtSpot,
  140.             strCurrency,
  141.             astrDepositMaturityTenor
  142.         );

  143.         Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack (
  144.             dtSpot,
  145.             adblFuturesQuote.length,
  146.             strCurrency
  147.         );

  148.         Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard (
  149.             dtSpot,
  150.             strCurrency,
  151.             "ALL",
  152.             astrFixFloatMaturityTenor,
  153.             "MAIN",
  154.             0.
  155.         );

  156.         ValuationParams valParams = new ValuationParams (
  157.             dtSpot,
  158.             dtSpot,
  159.             strCurrency
  160.         );

  161.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  162.             dcFunding,
  163.             null,
  164.             null,
  165.             null,
  166.             null,
  167.             null,
  168.             null
  169.         );

  170.         System.out.println();

  171.         System.out.println ("\t|-------------------------------------||");

  172.         System.out.println ("\t|        DEPOSIT INPUT vs. CALC       ||");

  173.         System.out.println ("\t|-------------------------------------||");

  174.         for (int i = 0; i < aDepositComp.length; ++i)
  175.             System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" +
  176.                 FormatUtil.FormatDouble (aDepositComp[i].measureValue (
  177.                     valParams,
  178.                     null,
  179.                     csqc,
  180.                     null,
  181.                     "ForwardRate"
  182.                 ), 1, 6, 1.) + " |" +
  183.                 FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||"
  184.             );

  185.         System.out.println ("\t|-------------------------------------||");

  186.         System.out.println();

  187.         System.out.println ("\t|-------------------------------------||");

  188.         System.out.println ("\t|        FUTURES INPUT vs. CALC       ||");

  189.         System.out.println ("\t|-------------------------------------||");

  190.         for (int i = 0; i < aFuturesComp.length; ++i)
  191.             System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" +
  192.                 FormatUtil.FormatDouble (aFuturesComp[i].measureValue (
  193.                     valParams,
  194.                     null,
  195.                     csqc,
  196.                     null,
  197.                     "ForwardRate"
  198.                 ), 1, 6, 1.) + " |" +
  199.                 FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||"
  200.             );

  201.         System.out.println ("\t|-------------------------------------||");

  202.         System.out.println();

  203.         System.out.println ("\t|------------------------------------------------|| ");

  204.         System.out.println ("\t|          FIX-FLOAT INPUTS vs CALIB             ||");

  205.         System.out.println ("\t|------------------------------------------------|| ");

  206.         for (int i = 0; i < aFixFloatComp.length; ++i)
  207.             System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" +
  208.                 FormatUtil.FormatDouble (aFixFloatComp[i].measureValue (
  209.                     valParams,
  210.                     null,
  211.                     csqc,
  212.                     null,
  213.                     "CalibSwapRate"
  214.                 ), 1, 6, 1.) + " |" +
  215.                 FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" +
  216.                 FormatUtil.FormatDouble (aFixFloatComp[i].measureValue (
  217.                     valParams,
  218.                     null,
  219.                     csqc,
  220.                     null,
  221.                     "FairPremium"
  222.                 ), 1, 6, 1.) + " ||"
  223.             );

  224.         System.out.println ("\t|------------------------------------------------||");

  225.         System.out.println();

  226.         return dcFunding;
  227.     }

  228.     private static final Map<String, GovvieCurve> GovvieCurve (
  229.         final JulianDate dtSpot,
  230.         final String strCode,
  231.         final double[] adblCoupon,
  232.         final double[] adblYield)
  233.         throws Exception
  234.     {
  235.         JulianDate[] adtEffective = new JulianDate[] {
  236.             dtSpot,
  237.             dtSpot,
  238.             dtSpot,
  239.             dtSpot,
  240.             dtSpot,
  241.             dtSpot,
  242.             dtSpot,
  243.             dtSpot
  244.         };

  245.         JulianDate[] adtMaturity = new JulianDate[] {
  246.             dtSpot.addTenor ("1Y"),
  247.             dtSpot.addTenor ("2Y"),
  248.             dtSpot.addTenor ("3Y"),
  249.             dtSpot.addTenor ("5Y"),
  250.             dtSpot.addTenor ("7Y"),
  251.             dtSpot.addTenor ("10Y"),
  252.             dtSpot.addTenor ("20Y"),
  253.             dtSpot.addTenor ("30Y")
  254.         };

  255.         Map<String, GovvieCurve> mapGovvieCurve = LatentMarketStateBuilder.BumpedGovvieCurve (
  256.             strCode,
  257.             dtSpot,
  258.             adtEffective,
  259.             adtMaturity,
  260.             adblCoupon,
  261.             adblYield,
  262.             "Yield",
  263.             LatentMarketStateBuilder.SHAPE_PRESERVING,
  264.             0.0001,
  265.             false
  266.         );

  267.         BondComponent[] aComp = TreasuryBuilder.FromCode (
  268.             strCode,
  269.             adtEffective,
  270.             adtMaturity,
  271.             adblCoupon
  272.         );

  273.         ValuationParams valParams = ValuationParams.Spot (dtSpot.julian());

  274.         CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer();

  275.         csqc.setGovvieState (mapGovvieCurve.get ("BASE"));

  276.         System.out.println();

  277.         System.out.println ("\t|-------------------------------------------||");

  278.         System.out.println ("\t|       TREASURY INPUT vs CALIB YIELD       ||");

  279.         System.out.println ("\t|-------------------------------------------||");

  280.         for (int i = 0; i < aComp.length; ++i)
  281.             System.out.println ("\t| " + aComp[i].name() + " | " +
  282.                 FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " +
  283.                 FormatUtil.FormatDouble (aComp[i].yieldFromPrice (
  284.                     valParams,
  285.                     null,
  286.                     null,
  287.                     aComp[i].maturityDate().julian(),
  288.                     1.,
  289.                     aComp[i].priceFromYield (
  290.                         valParams,
  291.                         null,
  292.                         null,
  293.                         mapGovvieCurve.get ("BASE").yield (aComp[i].maturityDate().julian())
  294.                     )
  295.                 ), 1, 3, 100.) + "% ||"
  296.             );

  297.         System.out.println ("\t|-------------------------------------------||");

  298.         return mapGovvieCurve;
  299.     }

  300.     private static final void AccumulateBondMarketQuote (
  301.         final CurveSurfaceQuoteContainer csqc,
  302.         final String[] astrOnTheRunCode,
  303.         final double[] adblYield)
  304.         throws Exception
  305.     {
  306.         for (int i = 0; i < astrOnTheRunCode.length; ++i) {
  307.             ProductMultiMeasure pmmq = new ProductMultiMeasure();

  308.             pmmq.addQuote (
  309.                 "Yield",
  310.                 new MultiSided (
  311.                     "mid",
  312.                     adblYield[i]
  313.                 ),
  314.                 true
  315.             );

  316.             csqc.setProductQuote (
  317.                 astrOnTheRunCode[i],
  318.                 pmmq
  319.             );
  320.         }
  321.     }

  322.     private static final Bond Corporate (
  323.         final String strName,
  324.         final JulianDate dtEffective,
  325.         final JulianDate dtMaturity,
  326.         final double dblCoupon,
  327.         final int iFreq,
  328.         final String strDayCount)
  329.         throws Exception
  330.     {
  331.         return BondBuilder.CreateSimpleFixed (
  332.             strName + FormatUtil.FormatDouble (dblCoupon, 1, 4, 100.) + " " + dtMaturity,
  333.             "USD",
  334.             "",
  335.             dblCoupon,
  336.             iFreq,
  337.             strDayCount,
  338.             dtEffective,
  339.             dtMaturity,
  340.             null,
  341.             null
  342.         );
  343.     }

  344.     private static final double[] RVMeasures (
  345.         final Bond[] aBond,
  346.         final JulianDate dtValue,
  347.         final CurveSurfaceQuoteContainer csqc,
  348.         final double[] adblCleanPrice)
  349.         throws Exception
  350.     {
  351.         JulianDate dtSettle = dtValue.addBusDays (
  352.             1,
  353.             aBond[0].currency()
  354.         );

  355.         ValuationParams valParams = new ValuationParams (
  356.             dtValue,
  357.             dtSettle,
  358.             aBond[0].currency()
  359.         );

  360.         System.out.println();

  361.         System.out.println ("\t|--------------------------------||");

  362.         System.out.println ("\t| Trade Date       : " + dtValue + " ||");

  363.         System.out.println ("\t| Cash Settle Date : " + dtSettle + " ||");

  364.         System.out.println ("\t|--------------------------------||");

  365.         System.out.println();

  366.         String strCurveMetrics = "";
  367.         String strSecularMetrics = "";
  368.         double[] adblOAS = new double[aBond.length];

  369.         for (int i = 0; i < aBond.length; ++i) {
  370.             System.out.println ("Doing " + aBond[i].name() + " @ " + dtSettle);

  371.             double dblCleanPriceOASUp = Double.NaN;
  372.             double dblCleanPriceOASDown = Double.NaN;

  373.             WorkoutInfo wi = aBond[i].exerciseYieldFromPrice (
  374.                 valParams,
  375.                 csqc,
  376.                 null,
  377.                 adblCleanPrice[i]
  378.             );

  379.             BondRVMeasures rvm = aBond[i].standardMeasures (
  380.                 valParams,
  381.                 null,
  382.                 csqc,
  383.                 null,
  384.                 wi,
  385.                 adblCleanPrice[i]
  386.             );

  387.             strSecularMetrics += "\t| " +
  388.                 aBond[i].name() + " | " +
  389.                 aBond[i].effectiveDate() + " | " +
  390.                 aBond[i].maturityDate() + " |  " +
  391.                 aBond[i].firstCouponDate() + "  |" +
  392.                 FormatUtil.FormatDouble (adblCleanPrice[i], 3, 3, 100.) + " |" +
  393.                 FormatUtil.FormatDouble (aBond[i].accrued (dtSettle.julian(), csqc), 1, 5, 100.) + " |" +
  394.                 FormatUtil.FormatDouble (wi.yield(), 1, 2, 100.) + "% | " +
  395.                 FormatUtil.FormatDouble (rvm.macaulayDuration(), 2, 2, 1.) + "  | " +
  396.                 FormatUtil.FormatDouble (rvm.modifiedDuration(), 2, 2, 10000.) + "  |  " +
  397.                 FormatUtil.FormatDouble (rvm.yield01(), 2, 2, 10000.) + "  |" +
  398.                 FormatUtil.FormatDouble (rvm.yield01(), 4, 0, 1000000.) + " |" +
  399.                 FormatUtil.FormatDouble (rvm.convexity(), 1, 2, 1000000.) + " |" +
  400.                 FormatUtil.FormatDouble (aBond[i].weightedAverageLife (valParams, csqc), 2, 2, 1.) + " |   " +
  401.                 FormatUtil.FormatDouble (rvm.bondBasis(), 3, 0, 10000.) + "     ||" + "\n";

  402.             adblOAS[i] = rvm.oas();

  403.             try {
  404.                 dblCleanPriceOASUp = aBond[i].priceFromOAS (
  405.                     valParams,
  406.                     csqc,
  407.                     null,
  408.                     adblOAS[i] + 0.0001
  409.                 );

  410.                 dblCleanPriceOASDown = aBond[i].priceFromOAS (
  411.                     valParams,
  412.                     csqc,
  413.                     null,
  414.                     adblOAS[i] - 0.0001
  415.                 );
  416.             } catch (Exception e) {
  417.                 // e.printStackTrace();
  418.             }

  419.             strCurveMetrics += "\t| " +
  420.                 aBond[i].name() + " |" +
  421.                 FormatUtil.FormatDouble (adblCleanPrice[i], 3, 3, 100.) + " |" +
  422.                 FormatUtil.FormatDouble (wi.yield(), 1, 2, 100.) + "% |   " +
  423.                 FormatUtil.FormatDouble (rvm.zSpread(), 3, 0, 10000.) + "   |" +
  424.                 FormatUtil.FormatDouble (adblOAS[i], 3, 0, 10000.) + " | " +
  425.                 FormatUtil.FormatDouble (0.5 * (dblCleanPriceOASDown - dblCleanPriceOASUp) / adblCleanPrice[i], 2, 2, 10000.) + "  |  " +
  426.                 FormatUtil.FormatDouble ((dblCleanPriceOASDown + dblCleanPriceOASUp - 2. * adblCleanPrice[i]) / adblCleanPrice[i], 2, 2, 1000000.) + "   |" +
  427.                 FormatUtil.FormatDouble (rvm.asw(), 3, 0, 10000.) + " |  " +
  428.                 FormatUtil.FormatDouble (rvm.gSpread(), 3, 0, 10000.) + "    |   " +
  429.                 FormatUtil.FormatDouble (rvm.iSpread(), 3, 0, 10000.) + "   |    " +
  430.                 FormatUtil.FormatDouble (rvm.tsySpread(), 3, 0, 10000.) + "    |  " +
  431.                 Helper.BaseTsyBmk (
  432.                     dtValue.julian(),
  433.                     aBond[i].maturityDate().julian()
  434.                 ) + "  ||" + "\n";
  435.         }

  436.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  437.         System.out.println ("\t|             BOND           |  EFFECTIVE  |   MATURITY  |  FIRST COUPON |  PRICE  | ACCRUED | YIELD | MAC DUR | MOD DUR | YIELD 01 | DV01 | CONV |  WAL  | BOND BASIS ||");

  438.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  439.         System.out.print (strSecularMetrics);

  440.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  441.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------||");

  442.         System.out.println ("\t|             BOND           |  PRICE  | YIELD | Z SPREAD | OAS | OAS DUR |  OAS CONV | ASW | G SPREAD | I SPREAD | TSY SPREAD | TSY BMK ||");

  443.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------||");

  444.         System.out.print (strCurveMetrics);

  445.         System.out.println ("\t|----------------------------------------------------------------------------------------------------------------------------------------||");

  446.         return adblOAS;
  447.     }

  448.     public static final void main (
  449.         final String[] astrArgs)
  450.         throws Exception
  451.     {
  452.         EnvManager.InitEnv ("");

  453.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  454.             2017,
  455.             DateUtil.MARCH,
  456.             10
  457.         );

  458.         String strCurrency = "USD";
  459.         String strTreasuryCode = "UST";

  460.         MergedDiscountForwardCurve dcFunding = FundingCurve (
  461.             dtSpot,
  462.             strCurrency
  463.         );

  464.         double[] adblTreasuryCoupon = new double[] {
  465.             0.0100,
  466.             0.0100,
  467.             0.0125,
  468.             0.0150,
  469.             0.0200,
  470.             0.0225,
  471.             0.0250,
  472.             0.0300
  473.         };

  474.         double[] adblTreasuryYield = new double[] {
  475.             0.0104, //  1Y
  476.             0.0137, //  2Y
  477.             0.0167, //  3Y
  478.             0.0213, //  5Y
  479.             0.0243, //  7Y
  480.             0.0260, // 10Y
  481.             0.0294, // 20Y
  482.             0.0319  // 30Y
  483.         };

  484.         Map<String, GovvieCurve> mapGovvieCurve = GovvieCurve (
  485.             dtSpot,
  486.             strTreasuryCode,
  487.             adblTreasuryCoupon,
  488.             adblTreasuryYield
  489.         );

  490.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  491.             dcFunding,
  492.             null,
  493.             null,
  494.             null,
  495.             null,
  496.             null,
  497.             null
  498.         );

  499.         csqc.setGovvieState (mapGovvieCurve.get ("BASE"));

  500.         AccumulateBondMarketQuote (
  501.             csqc,
  502.             new String[] {
  503.                 "01YON",
  504.                 "02YON",
  505.                 "03YON",
  506.                 "05YON",
  507.                 "07YON",
  508.                 "10YON",
  509.                 "20YON",
  510.                 "30YON"
  511.             },
  512.             adblTreasuryYield
  513.         );

  514.         Bond[] aCorporateBond = new Bond[] {
  515.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (2012,  7,  2), DateUtil.CreateFromYMD (2017,  6, 30), 0.00750, 2, "ACT/ACT"),
  516.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (2011,  6, 30), DateUtil.CreateFromYMD (2017,  6, 30), 0.02500, 2, "ACT/ACT"),
  517.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (2015,  1, 15), DateUtil.CreateFromYMD (2018,  1, 15), 0.00875, 2, "ACT/ACT"),
  518.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (2011,  9, 30), DateUtil.CreateFromYMD (2018,  9, 30), 0.01375, 2, "ACT/ACT"),
  519.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (1989,  8, 15), DateUtil.CreateFromYMD (2019,  8, 15), 0.08125, 2, "ACT/ACT"),
  520.             Corporate ("AGENCY ", DateUtil.CreateFromYMD (2016, 11, 15), DateUtil.CreateFromYMD (2046, 11, 15), 0.02875, 2, "ACT/ACT"),
  521.         };

  522.         double[] adblCleanPrice = new double[] {
  523.             0.999921875,    // (2017,  6, 30)
  524.             1.005312500,    // (2017,  6, 30)
  525.             0.998515625,    // (2018,  1, 15)
  526.             1.001875000,    // (2018,  9, 30)
  527.             1.158125000,    // (2019,  8, 15)
  528.             0.943281250,    // (2046, 11, 15)
  529.         };

  530.         double[] adblOAS = RVMeasures (
  531.             aCorporateBond,
  532.             dtSpot,
  533.             csqc,
  534.             adblCleanPrice
  535.         );

  536.         ValuationParams valParams = new ValuationParams (
  537.             dtSpot,
  538.             dtSpot.addBusDays (
  539.                 3,
  540.                 dcFunding.currency()
  541.             ),
  542.             dcFunding.currency()
  543.         );

  544.         System.out.println();

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

  546.         System.out.print ("\t|             BOND          ");

  547.         for (Map.Entry<String, GovvieCurve> meGovvieCurve : mapGovvieCurve.entrySet()) {
  548.             if ("BASE".equalsIgnoreCase (meGovvieCurve.getKey()) || "BUMP".equalsIgnoreCase (meGovvieCurve.getKey()))
  549.                 continue;

  550.             System.out.print (" | " + meGovvieCurve.getKey());
  551.         }

  552.         System.out.println (" ||");

  553.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  554.         for (int i = 0; i < adblOAS.length; ++i) {
  555.             System.out.print ("\t| " + aCorporateBond[i].name());

  556.             for (Map.Entry<String, GovvieCurve> meGovvieCurve : mapGovvieCurve.entrySet()) {
  557.                 if ("BASE".equalsIgnoreCase (meGovvieCurve.getKey()) || "BUMP".equalsIgnoreCase (meGovvieCurve.getKey()))
  558.                     continue;

  559.                 csqc.setGovvieState (meGovvieCurve.getValue());

  560.                 String strDump = " |           ";

  561.                 try {
  562.                     strDump = " |      " +
  563.                         FormatUtil.FormatDouble (
  564.                             (adblCleanPrice[i] - aCorporateBond[i].priceFromOAS (
  565.                                 valParams,
  566.                                 csqc,
  567.                                 null,
  568.                                 adblOAS[i]
  569.                             )) / adblCleanPrice[i],
  570.                         2, 2, 10000.
  571.                     ) + "     ";
  572.                 } catch (Exception e) {
  573.                     // e.printStackTrace();
  574.                 }

  575.                 System.out.print (strDump);
  576.             }

  577.             System.out.println (" ||");
  578.         }

  579.         System.out.println ("\t|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------||");

  580.         System.out.println();
  581.     }
  582. }