CorporateIssueMetrics.java

  1. package org.drip.sample.bond;

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

  94. /**
  95.  * <i>CorporateIssueMetrics</i> demonstrates the Corporate Bond Pricing and Relative Value Measure Generation
  96.  * Functionality.
  97.  *  
  98.  * <br><br>
  99.  *  <ul>
  100.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  101.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  102.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">DROP API Construction and Usage</a></li>
  103.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/bond/README.md">Bullet, EOS Bond Metrics + Curve</a></li>
  104.  *  </ul>
  105.  * <br><br>
  106.  *
  107.  * @author Lakshmi Krishnamurthy
  108.  */

  109. public class CorporateIssueMetrics {

  110.     private static final MergedDiscountForwardCurve FundingCurve (
  111.         final JulianDate dtSpot,
  112.         final String strCurrency)
  113.         throws Exception
  114.     {
  115.         String[] astrDepositMaturityTenor = new String[] {
  116.             "2D",
  117.             "1W",
  118.             "1M",
  119.             "2M",
  120.             "3M"
  121.         };

  122.         double[] adblDepositQuote = new double[] {
  123.             0.00195, // 2D
  124.             0.00176, // 1W
  125.             0.00301, // 1M
  126.             0.00401, // 2M
  127.             0.00492  // 3M
  128.         };

  129.         double[] adblFuturesQuote = new double[] {
  130.             0.00609,
  131.             0.00687
  132.         };

  133.         String[] astrFixFloatMaturityTenor = new String[] {
  134.             "01Y",
  135.             "02Y",
  136.             "03Y",
  137.             "04Y",
  138.             "05Y",
  139.             "06Y",
  140.             "07Y",
  141.             "08Y",
  142.             "09Y",
  143.             "10Y",
  144.             "11Y",
  145.             "12Y",
  146.             "15Y",
  147.             "20Y",
  148.             "25Y",
  149.             "30Y",
  150.             "40Y",
  151.             "50Y"
  152.         };

  153.         double[] adblFixFloatQuote = new double[] {
  154.             0.00762, //  1Y
  155.             0.01055, //  2Y
  156.             0.01300, //  3Y
  157.             0.01495, //  4Y
  158.             0.01651, //  5Y
  159.             0.01787, //  6Y
  160.             0.01904, //  7Y
  161.             0.02005, //  8Y
  162.             0.02090, //  9Y
  163.             0.02166, // 10Y
  164.             0.02231, // 11Y
  165.             0.02289, // 12Y
  166.             0.02414, // 15Y
  167.             0.02570, // 20Y
  168.             0.02594, // 25Y
  169.             0.02627, // 30Y
  170.             0.02648, // 40Y
  171.             0.02632  // 50Y
  172.         };

  173.         MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve (
  174.             dtSpot,
  175.             strCurrency,
  176.             astrDepositMaturityTenor,
  177.             adblDepositQuote,
  178.             "ForwardRate",
  179.             adblFuturesQuote,
  180.             "ForwardRate",
  181.             astrFixFloatMaturityTenor,
  182.             adblFixFloatQuote,
  183.             "SwapRate"
  184.         );

  185.         Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit (
  186.             dtSpot,
  187.             strCurrency,
  188.             astrDepositMaturityTenor
  189.         );

  190.         Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack (
  191.             dtSpot,
  192.             adblFuturesQuote.length,
  193.             strCurrency
  194.         );

  195.         Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard (
  196.             dtSpot,
  197.             strCurrency,
  198.             "ALL",
  199.             astrFixFloatMaturityTenor,
  200.             "MAIN",
  201.             0.
  202.         );

  203.         ValuationParams valParams = new ValuationParams (
  204.             dtSpot,
  205.             dtSpot,
  206.             strCurrency
  207.         );

  208.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  209.             dcFunding,
  210.             null,
  211.             null,
  212.             null,
  213.             null,
  214.             null,
  215.             null
  216.         );

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

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

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

  220.         for (int i = 0; i < aDepositComp.length; ++i)
  221.             System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" +
  222.                 FormatUtil.FormatDouble (aDepositComp[i].measureValue (
  223.                     valParams,
  224.                     null,
  225.                     csqc,
  226.                     null,
  227.                     "ForwardRate"
  228.                 ), 1, 6, 1.) + " |" +
  229.                 FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||"
  230.             );

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

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

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

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

  235.         for (int i = 0; i < aFuturesComp.length; ++i)
  236.             System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" +
  237.                 FormatUtil.FormatDouble (aFuturesComp[i].measureValue (
  238.                     valParams,
  239.                     null,
  240.                     csqc,
  241.                     null,
  242.                     "ForwardRate"
  243.                 ), 1, 6, 1.) + " |" +
  244.                 FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||"
  245.             );

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

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

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

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

  250.         for (int i = 0; i < aFixFloatComp.length; ++i)
  251.             System.out.println ("\t| [" + aFixFloatComp[i].maturityDate() + "] =" +
  252.                 FormatUtil.FormatDouble (aFixFloatComp[i].measureValue (
  253.                     valParams,
  254.                     null,
  255.                     csqc,
  256.                     null,
  257.                     "CalibSwapRate"
  258.                 ), 1, 6, 1.) + " |" +
  259.                 FormatUtil.FormatDouble (adblFixFloatQuote[i], 1, 6, 1.) + " |" +
  260.                 FormatUtil.FormatDouble (aFixFloatComp[i].measureValue (
  261.                     valParams,
  262.                     null,
  263.                     csqc,
  264.                     null,
  265.                     "FairPremium"
  266.                 ), 1, 6, 1.) + " ||"
  267.             );

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

  269.         return dcFunding;
  270.     }

  271.     private static final void AccumulateBondMarketQuote (
  272.         final CurveSurfaceQuoteContainer csqc,
  273.         final String[] astrOnTheRunCode,
  274.         final double[] adblYield)
  275.         throws Exception
  276.     {
  277.         for (int i = 0; i < astrOnTheRunCode.length; ++i) {
  278.             ProductMultiMeasure pmmq = new ProductMultiMeasure();

  279.             pmmq.addQuote (
  280.                 "Yield",
  281.                 new MultiSided (
  282.                     "mid",
  283.                     adblYield[i]
  284.                 ),
  285.                 true
  286.             );

  287.             csqc.setProductQuote (
  288.                 astrOnTheRunCode[i],
  289.                 pmmq
  290.             );
  291.         }
  292.     }

  293.     private static final Map<String, GovvieCurve> GovvieCurve (
  294.         final JulianDate dtSpot,
  295.         final String strCode,
  296.         final double[] adblCoupon,
  297.         final double[] adblYield)
  298.         throws Exception
  299.     {
  300.         JulianDate[] adtEffective = new JulianDate[] {
  301.             dtSpot,
  302.             dtSpot,
  303.             dtSpot,
  304.             dtSpot,
  305.             dtSpot,
  306.             dtSpot,
  307.             dtSpot
  308.         };

  309.         JulianDate[] adtMaturity = new JulianDate[] {
  310.             dtSpot.addTenor ("1Y"),
  311.             dtSpot.addTenor ("2Y"),
  312.             dtSpot.addTenor ("3Y"),
  313.             dtSpot.addTenor ("5Y"),
  314.             dtSpot.addTenor ("7Y"),
  315.             dtSpot.addTenor ("10Y"),
  316.             dtSpot.addTenor ("30Y")
  317.         };

  318.         Map<String, GovvieCurve> mapGovvieCurve = LatentMarketStateBuilder.BumpedGovvieCurve (
  319.             strCode,
  320.             dtSpot,
  321.             adtEffective,
  322.             adtMaturity,
  323.             adblCoupon,
  324.             adblYield,
  325.             "Yield",
  326.             LatentMarketStateBuilder.SHAPE_PRESERVING,
  327.             0.0001,
  328.             false
  329.         );

  330.         BondComponent[] aComp = TreasuryBuilder.FromCode (
  331.             strCode,
  332.             adtEffective,
  333.             adtMaturity,
  334.             adblCoupon
  335.         );

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

  337.         CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer();

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

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

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

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

  342.         for (int i = 0; i < aComp.length; ++i)
  343.             System.out.println ("\t| " + aComp[i].name() + " | " +
  344.                 FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " +
  345.                 FormatUtil.FormatDouble (aComp[i].yieldFromPrice (
  346.                     valParams,
  347.                     null,
  348.                     null,
  349.                     aComp[i].maturityDate().julian(),
  350.                     1.,
  351.                     aComp[i].priceFromYield (
  352.                         valParams,
  353.                         null,
  354.                         null,
  355.                         mapGovvieCurve.get ("BASE").yield (aComp[i].maturityDate().julian())
  356.                     )
  357.                 ), 1, 3, 100.) + "% ||"
  358.             );

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

  360.         return mapGovvieCurve;
  361.     }

  362.     private static final Bond USDCorporate (
  363.         final JulianDate dtEffective,
  364.         final JulianDate dtMaturity,
  365.         final double dblCoupon)
  366.         throws Exception
  367.     {
  368.         return BondBuilder.CreateSimpleFixed (
  369.             "JPM " + FormatUtil.FormatDouble (dblCoupon, 1, 4, 100.) + " " + dtMaturity,
  370.             "USD",
  371.             "",
  372.             dblCoupon,
  373.             2,
  374.             "30/360",
  375.             dtEffective,
  376.             dtMaturity,
  377.             null,
  378.             null
  379.         );
  380.     }

  381.     private static final double[] RVMeasures (
  382.         final Bond[] aBond,
  383.         final JulianDate dtValue,
  384.         final CurveSurfaceQuoteContainer csqc,
  385.         final double[] adblCleanPrice)
  386.         throws Exception
  387.     {
  388.         JulianDate dtSettle = dtValue.addBusDays (
  389.             3,
  390.             aBond[0].currency()
  391.         );

  392.         ValuationParams valParams = new ValuationParams (
  393.             dtValue,
  394.             dtSettle,
  395.             aBond[0].currency()
  396.         );

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

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

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

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

  401.         String strCurveMetrics = "";
  402.         String strSecularMetrics = "";
  403.         double[] adblOAS = new double[aBond.length];

  404.         for (int i = 0; i < aBond.length; ++i) {
  405.             WorkoutInfo wi = aBond[i].exerciseYieldFromPrice (
  406.                 valParams,
  407.                 csqc,
  408.                 null,
  409.                 adblCleanPrice[i]
  410.             );

  411.             BondRVMeasures rvm = aBond[i].standardMeasures (
  412.                 valParams,
  413.                 null,
  414.                 csqc,
  415.                 null,
  416.                 wi,
  417.                 adblCleanPrice[i]
  418.             );

  419.             strSecularMetrics += "\t| " +
  420.                 aBond[i].name() + " | " +
  421.                 aBond[i].effectiveDate() + " | " +
  422.                 aBond[i].maturityDate() + " |  " +
  423.                 aBond[i].firstCouponDate() + "  |" +
  424.                 FormatUtil.FormatDouble (adblCleanPrice[i], 3, 3, 100.) + " |" +
  425.                 FormatUtil.FormatDouble (wi.yield(), 1, 2, 100.) + "% | " +
  426.                 FormatUtil.FormatDouble (rvm.macaulayDuration(), 2, 2, 1.) + "  | " +
  427.                 FormatUtil.FormatDouble (rvm.modifiedDuration(), 2, 2, 10000.) + "  |  " +
  428.                 FormatUtil.FormatDouble (rvm.yield01(), 2, 2, 10000.) + "  |" +
  429.                 FormatUtil.FormatDouble (rvm.yield01(), 4, 0, 1000000.) + " |" +
  430.                 FormatUtil.FormatDouble (rvm.convexity(), 1, 2, 1000000.) + " |   " +
  431.                 FormatUtil.FormatDouble (rvm.bondBasis(), 3, 0, 10000.) + "     ||" + "\n";

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

  433.             double dblCleanPriceOASUp = aBond[i].priceFromOAS (
  434.                 valParams,
  435.                 csqc,
  436.                 null,
  437.                 adblOAS[i] + 0.0001
  438.             );

  439.             double dblCleanPriceOASDown = aBond[i].priceFromOAS (
  440.                 valParams,
  441.                 csqc,
  442.                 null,
  443.                 adblOAS[i] - 0.0001
  444.             );

  445.             strCurveMetrics += "\t| " +
  446.                 aBond[i].name() + " |" +
  447.                 FormatUtil.FormatDouble (adblCleanPrice[i], 3, 3, 100.) + " |" +
  448.                 FormatUtil.FormatDouble (wi.yield(), 1, 2, 100.) + "% |   " +
  449.                 FormatUtil.FormatDouble (rvm.zSpread(), 3, 0, 10000.) + "   |" +
  450.                 FormatUtil.FormatDouble (adblOAS[i], 3, 0, 10000.) + " | " +
  451.                 FormatUtil.FormatDouble (0.5 * (dblCleanPriceOASDown - dblCleanPriceOASUp) / adblCleanPrice[i], 2, 2, 10000.) + "  |  " +
  452.                 FormatUtil.FormatDouble ((dblCleanPriceOASDown + dblCleanPriceOASUp - 2. * adblCleanPrice[i]) / adblCleanPrice[i], 2, 2, 1000000.) + "   |" +
  453.                 FormatUtil.FormatDouble (rvm.asw(), 3, 0, 10000.) + " |  " +
  454.                 FormatUtil.FormatDouble (rvm.gSpread(), 3, 0, 10000.) + "    |   " +
  455.                 FormatUtil.FormatDouble (rvm.iSpread(), 3, 0, 10000.) + "   |    " +
  456.                 FormatUtil.FormatDouble (rvm.tsySpread(), 3, 0, 10000.) + "    |  " +
  457.                 Helper.BaseTsyBmk (
  458.                     dtValue.julian(),
  459.                     aBond[i].maturityDate().julian()
  460.                 ) + "  ||" + "\n";
  461.         }

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

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

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

  465.         System.out.print (strSecularMetrics);

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

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

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

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

  470.         System.out.print (strCurveMetrics);

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

  472.         return adblOAS;
  473.     }

  474.     public static final void main (
  475.         final String[] astrArgs)
  476.         throws Exception
  477.     {
  478.         EnvManager.InitEnv (
  479.             "",
  480.             true
  481.         );

  482.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  483.             2015,
  484.             DateUtil.DECEMBER,
  485.             8
  486.         );

  487.         String strCurrency = "USD";
  488.         String strTreasuryCode = "UST";

  489.         MergedDiscountForwardCurve dcFunding = FundingCurve (
  490.             dtSpot,
  491.             strCurrency
  492.         );

  493.         double[] adblTreasuryCoupon = new double[] {
  494.             0.0100,
  495.             0.0100,
  496.             0.0125,
  497.             0.0150,
  498.             0.0200,
  499.             0.0225,
  500.             0.0300
  501.         };

  502.         double[] adblTreasuryYield = new double[] {
  503.             0.00692,
  504.             0.00945,
  505.             0.01257,
  506.             0.01678,
  507.             0.02025,
  508.             0.02235,
  509.             0.02972
  510.         };

  511.         Map<String, GovvieCurve> mapGovvieCurve = GovvieCurve (
  512.             dtSpot,
  513.             strTreasuryCode,
  514.             adblTreasuryCoupon,
  515.             adblTreasuryYield
  516.         );

  517.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  518.             dcFunding,
  519.             null,
  520.             null,
  521.             null,
  522.             null,
  523.             null,
  524.             null
  525.         );

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

  527.         AccumulateBondMarketQuote (
  528.             csqc,
  529.             new String[] {
  530.                 "01YON",
  531.                 "02YON",
  532.                 "03YON",
  533.                 "05YON",
  534.                 "07YON",
  535.                 "10YON",
  536.                 "30YON"
  537.             },
  538.             adblTreasuryYield
  539.         );

  540.         Bond[] aCorporateBond = new Bond[] {
  541.             USDCorporate (DateUtil.CreateFromYMD (2007, 12, 20), DateUtil.CreateFromYMD (2018,  1, 15), 0.06000),
  542.             USDCorporate (DateUtil.CreateFromYMD (1996,  7, 25), DateUtil.CreateFromYMD (2025,  7, 15), 0.07750),
  543.             USDCorporate (DateUtil.CreateFromYMD (1996, 10, 29), DateUtil.CreateFromYMD (2026, 10, 15), 0.07625),
  544.             USDCorporate (DateUtil.CreateFromYMD (2014, 12,  9), DateUtil.CreateFromYMD (2026, 12, 15), 0.04125),
  545.             USDCorporate (DateUtil.CreateFromYMD (1997,  4, 29), DateUtil.CreateFromYMD (2027,  4, 29), 0.08000),
  546.             USDCorporate (DateUtil.CreateFromYMD (2014,  9, 25), DateUtil.CreateFromYMD (2027, 10,  1), 0.04250),
  547.             USDCorporate (DateUtil.CreateFromYMD (2008,  5, 22), DateUtil.CreateFromYMD (2038,  5, 15), 0.06400),
  548.             USDCorporate (DateUtil.CreateFromYMD (2011,  7, 21), DateUtil.CreateFromYMD (2041,  7, 15), 0.05600)
  549.         };

  550.         double[] adblCleanPrice = new double[] {
  551.             1.08529,
  552.             1.27021,
  553.             1.27274,
  554.             1.01235,
  555.             1.31537,
  556.             1.02263,
  557.             1.27570,
  558.             1.17460
  559.         };

  560.         double[] adblOAS = RVMeasures (
  561.             aCorporateBond,
  562.             dtSpot,
  563.             csqc,
  564.             adblCleanPrice
  565.         );

  566.         ValuationParams valParams = new ValuationParams (
  567.             dtSpot,
  568.             dtSpot.addBusDays (
  569.                 3,
  570.                 dcFunding.currency()
  571.             ),
  572.             dcFunding.currency()
  573.         );

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

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

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

  579.             System.out.print (" | " + meGovvieCurve.getKey());
  580.         }

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

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

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

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

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

  589.                 System.out.print (" |     " +
  590.                     FormatUtil.FormatDouble (
  591.                         (adblCleanPrice[i] - aCorporateBond[i].priceFromOAS (
  592.                             valParams,
  593.                             csqc,
  594.                             null,
  595.                             adblOAS[i]
  596.                         )) / adblCleanPrice[i],
  597.                     2, 2, 10000.) + "     "
  598.                 );
  599.             }

  600.             System.out.println (" ||");
  601.         }

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

  603.         EnvManager.TerminateEnv();
  604.     }
  605. }