MunicipalFixedBullet1.java

  1. package org.drip.sample.municipal;

  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.  * MunicipalFixedBullet1 demonstrates Non-EOS Fixed Coupon Agency Bond Pricing and Relative Value Measure
  64.  *  Generation Functionality.
  65.  *
  66.  * @author Lakshmi Krishnamurthy
  67.  */

  68. public class MunicipalFixedBullet1 {

  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.             0,
  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.             double dblCleanPriceOASUp = Double.NaN;
  371.             double dblCleanPriceOASDown = Double.NaN;

  372.             System.out.println ("Doing " + aBond[i].name());

  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.             15
  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 ("MUNICI ", DateUtil.CreateFromYMD (2011, 12, 20), DateUtil.CreateFromYMD (2021,  2,  1), 0.04400, 2, "US MUNI: 30/360"),
  516.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2011,  5, 11), DateUtil.CreateFromYMD (2022, 12,  1), 0.05210, 2, "US MUNI: 30/360"),
  517.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2009, 12, 10), DateUtil.CreateFromYMD (2025,  2,  1), 0.01180, 2, "US MUNI: 30/360"),
  518.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2012,  7, 30), DateUtil.CreateFromYMD (2025, 12, 15), 0.04676, 2, "US MUNI: 30/360"),
  519.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2011,  4, 12), DateUtil.CreateFromYMD (2026,  2,  1), 0.05400, 2, "US MUNI: 30/360"),
  520.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 12, 16), DateUtil.CreateFromYMD (2028,  3, 15), 0.06817, 2, "US MUNI: 30/360"),
  521.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2007,  6, 30), DateUtil.CreateFromYMD (2028,  6, 30), 0.05617, 2, "US MUNI: 30/360"),
  522.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 10, 28), DateUtil.CreateFromYMD (2029,  5,  1), 0.06645, 2, "US MUNI: 30/360"),
  523.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 12,  7), DateUtil.CreateFromYMD (2029,  9,  1), 0.06850, 2, "US MUNI: 30/360"),
  524.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  8, 26), DateUtil.CreateFromYMD (2031,  8,  1), 0.04500, 2, "US MUNI: 30/360"),
  525.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  2, 11), DateUtil.CreateFromYMD (2031, 11, 15), 0.06548, 2, "US MUNI: 30/360"),
  526.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 12, 22), DateUtil.CreateFromYMD (2032,  4,  1), 0.07099, 2, "US MUNI: 30/360"),
  527.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2012,  5,  3), DateUtil.CreateFromYMD (2034,  4,  1), 0.05900, 2, "US MUNI: 30/360"),
  528.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  2,  4), DateUtil.CreateFromYMD (2035,  2,  1), 0.06630, 2, "US MUNI: 30/360"),
  529.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  7, 21), DateUtil.CreateFromYMD (2035,  7,  1), 0.07350, 2, "US MUNI: 30/360"),
  530.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2011,  6, 15), DateUtil.CreateFromYMD (2037,  7,  1), 0.06352, 2, "US MUNI: 30/360"),
  531.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2009,  4, 30), DateUtil.CreateFromYMD (2039, 11, 15), 0.07336, 2, "US MUNI: 30/360"),
  532.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  6, 30), DateUtil.CreateFromYMD (2040,  3, 15), 0.05600, 2, "US MUNI: 30/360"),
  533.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 10, 14), DateUtil.CreateFromYMD (2040,  3, 15), 0.05389, 2, "US MUNI: 30/360"),
  534.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010,  2, 11), DateUtil.CreateFromYMD (2040,  6,  1), 0.07000, 2, "US MUNI: 30/360"),
  535.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 11, 30), DateUtil.CreateFromYMD (2040,  7,  1), 0.06790, 2, "US MUNI: 30/360"),
  536.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 11, 17), DateUtil.CreateFromYMD (2040,  7,  1), 0.07328, 2, "US MUNI: 30/360"),
  537.             Corporate ("MUNICI ", DateUtil.CreateFromYMD (2010, 12, 15), DateUtil.CreateFromYMD (2041,  1,  1), 0.07102, 2, "US MUNI: 30/360"),
  538.         };

  539.         double[] adblCleanPrice = new double[] {
  540.             1.0691325,  // (2021,  2,  1)
  541.             1.1132945,  // (2022, 12,  1)
  542.             0.8904175,  // (2025,  2,  1)
  543.             1.0308015,  // (2025, 12, 15)
  544.             1.1301335,  // (2026,  2,  1)
  545.             1.2589000,  // (2028,  3, 15)
  546.             1.1364350,  // (2028,  6, 30)
  547.             1.1066300,  // (2029,  5,  1)
  548.             1.1926305,  // (2029,  9,  1)
  549.             1.1093100,  // (2031,  8,  1)
  550.             1.2622500,  // (2031, 11, 15)
  551.             1.3176500,  // (2032,  4,  1)
  552.             1.0540000,  // (2034,  4,  1)
  553.             0.9937500,  // (2035,  2,  1)
  554.             1.0838400,  // (2035,  7,  1)
  555.             1.1831155,  // (2037,  7,  1)
  556.             1.4259900,  // (2039, 11, 15)
  557.             1.2079250,  // (2040,  3, 15)
  558.             1.1851900,  // (2040,  3, 15)
  559.             1.2583300,  // (2040,  6,  1)
  560.             1.2679600,  // (2040,  7,  1)
  561.             1.2184495,  // (2040,  7,  1)
  562.             1.3770600,  // (2041,  1,  1)
  563.         };

  564.         double[] adblOAS = RVMeasures (
  565.             aCorporateBond,
  566.             dtSpot,
  567.             csqc,
  568.             adblCleanPrice
  569.         );

  570.         ValuationParams valParams = new ValuationParams (
  571.             dtSpot,
  572.             dtSpot.addBusDays (
  573.                 3,
  574.                 dcFunding.currency()
  575.             ),
  576.             dcFunding.currency()
  577.         );

  578.         System.out.println();

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

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

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

  584.             System.out.print (" | " + meGovvieCurve.getKey());
  585.         }

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

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

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

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

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

  594.                 String strDump = " |                ";

  595.                 try {
  596.                     strDump = " |      " +
  597.                         FormatUtil.FormatDouble (
  598.                             (adblCleanPrice[i] - aCorporateBond[i].priceFromOAS (
  599.                                 valParams,
  600.                                 csqc,
  601.                                 null,
  602.                                 adblOAS[i]
  603.                             )) / adblCleanPrice[i],
  604.                         2, 2, 10000.
  605.                     ) + "     ";
  606.                 } catch (Exception e) {
  607.                     // e.printStackTrace();
  608.                 }

  609.                 System.out.print (strDump);
  610.             }

  611.             System.out.println (" ||");
  612.         }

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

  614.         System.out.println();
  615.     }
  616. }