BulletLIBORCorporate.java

  1. package org.drip.sample.bondfloat;

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

  92. /**
  93.  * <i>BulletLIBORCorporate</i> demonstrates Non-EOS Floating Coupon Corporate Bond Pricing and Relative Value
  94.  * Measure Generation Functionality.
  95.  *  
  96.  * <br><br>
  97.  *  <ul>
  98.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  99.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  100.  *      <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>
  101.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/bondfloat/README.md">Floating Coupon Bullet Corporate Bond</a></li>
  102.  *  </ul>
  103.  * <br><br>
  104.  *
  105.  * @author Lakshmi Krishnamurthy
  106.  */

  107. public class BulletLIBORCorporate
  108. {

  109.     private static final MergedDiscountForwardCurve FundingCurve (
  110.         final JulianDate dtSpot,
  111.         final String strCurrency)
  112.         throws Exception
  113.     {
  114.         String[] astrDepositMaturityTenor = new String[] {
  115.             "2D"
  116.         };

  117.         double[] adblDepositQuote = new double[] {
  118.             0.0103456 // 2D
  119.         };

  120.         double[] adblFuturesQuote = new double[] {
  121.             0.01070,
  122.             0.01235,
  123.             0.01360
  124.         };

  125.         String[] astrFixFloatMaturityTenor = new String[] {
  126.             "01Y",
  127.             "02Y",
  128.             "03Y",
  129.             "04Y",
  130.             "05Y",
  131.             "06Y",
  132.             "07Y",
  133.             "08Y",
  134.             "09Y",
  135.             "10Y",
  136.             "11Y",
  137.             "12Y",
  138.             "15Y",
  139.             "20Y",
  140.             "25Y",
  141.             "30Y",
  142.             "40Y",
  143.             "50Y"
  144.         };

  145.         double[] adblFixFloatQuote = new double[] {
  146.             0.012484, //  1Y
  147.             0.014987, //  2Y
  148.             0.017036, //  3Y
  149.             0.018624, //  4Y
  150.             0.019868, //  5Y
  151.             0.020921, //  6Y
  152.             0.021788, //  7Y
  153.             0.022530, //  8Y
  154.             0.023145, //  9Y
  155.             0.023685, // 10Y
  156.             0.024153, // 11Y
  157.             0.024562, // 12Y
  158.             0.025389, // 15Y
  159.             0.026118, // 20Y
  160.             0.026368, // 25Y
  161.             0.026432, // 30Y
  162.             0.026339, // 40Y
  163.             0.026122  // 50Y
  164.         };

  165.         MergedDiscountForwardCurve dcFunding = LatentMarketStateBuilder.SmoothFundingCurve (
  166.             dtSpot,
  167.             strCurrency,
  168.             astrDepositMaturityTenor,
  169.             adblDepositQuote,
  170.             "ForwardRate",
  171.             adblFuturesQuote,
  172.             "ForwardRate",
  173.             astrFixFloatMaturityTenor,
  174.             adblFixFloatQuote,
  175.             "SwapRate"
  176.         );

  177.         Component[] aDepositComp = OTCInstrumentBuilder.FundingDeposit (
  178.             dtSpot,
  179.             strCurrency,
  180.             astrDepositMaturityTenor
  181.         );

  182.         Component[] aFuturesComp = ExchangeInstrumentBuilder.ForwardRateFuturesPack (
  183.             dtSpot,
  184.             adblFuturesQuote.length,
  185.             strCurrency
  186.         );

  187.         Component[] aFixFloatComp = OTCInstrumentBuilder.FixFloatStandard (
  188.             dtSpot,
  189.             strCurrency,
  190.             "ALL",
  191.             astrFixFloatMaturityTenor,
  192.             "MAIN",
  193.             0.
  194.         );

  195.         ValuationParams valParams = new ValuationParams (
  196.             dtSpot,
  197.             dtSpot,
  198.             strCurrency
  199.         );

  200.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  201.             dcFunding,
  202.             null,
  203.             null,
  204.             null,
  205.             null,
  206.             null,
  207.             null
  208.         );

  209.         System.out.println();

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

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

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

  213.         for (int i = 0; i < aDepositComp.length; ++i)
  214.             System.out.println ("\t| [" + aDepositComp[i].maturityDate() + "] =" +
  215.                 FormatUtil.FormatDouble (aDepositComp[i].measureValue (
  216.                     valParams,
  217.                     null,
  218.                     csqc,
  219.                     null,
  220.                     "ForwardRate"
  221.                 ), 1, 6, 1.) + " |" +
  222.                 FormatUtil.FormatDouble (adblDepositQuote[i], 1, 6, 1.) + " ||"
  223.             );

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

  225.         System.out.println();

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

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

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

  229.         for (int i = 0; i < aFuturesComp.length; ++i)
  230.             System.out.println ("\t| [" + aFuturesComp[i].maturityDate() + "] =" +
  231.                 FormatUtil.FormatDouble (aFuturesComp[i].measureValue (
  232.                     valParams,
  233.                     null,
  234.                     csqc,
  235.                     null,
  236.                     "ForwardRate"
  237.                 ), 1, 6, 1.) + " |" +
  238.                 FormatUtil.FormatDouble (adblFuturesQuote[i], 1, 6, 1.) + " ||"
  239.             );

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

  241.         System.out.println();

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

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

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

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

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

  264.         System.out.println();

  265.         return dcFunding;
  266.     }

  267.     private static final Map<String, GovvieCurve> GovvieCurve (
  268.         final JulianDate dtSpot,
  269.         final String strCode,
  270.         final double[] adblCoupon,
  271.         final double[] adblYield)
  272.         throws Exception
  273.     {
  274.         JulianDate[] adtEffective = new JulianDate[] {
  275.             dtSpot,
  276.             dtSpot,
  277.             dtSpot,
  278.             dtSpot,
  279.             dtSpot,
  280.             dtSpot,
  281.             dtSpot,
  282.             dtSpot
  283.         };

  284.         JulianDate[] adtMaturity = new JulianDate[] {
  285.             dtSpot.addTenor ("1Y"),
  286.             dtSpot.addTenor ("2Y"),
  287.             dtSpot.addTenor ("3Y"),
  288.             dtSpot.addTenor ("5Y"),
  289.             dtSpot.addTenor ("7Y"),
  290.             dtSpot.addTenor ("10Y"),
  291.             dtSpot.addTenor ("20Y"),
  292.             dtSpot.addTenor ("30Y")
  293.         };

  294.         Map<String, GovvieCurve> mapGovvieCurve = LatentMarketStateBuilder.BumpedGovvieCurve (
  295.             strCode,
  296.             dtSpot,
  297.             adtEffective,
  298.             adtMaturity,
  299.             adblCoupon,
  300.             adblYield,
  301.             "Yield",
  302.             LatentMarketStateBuilder.SHAPE_PRESERVING,
  303.             0.0001,
  304.             false
  305.         );

  306.         BondComponent[] aComp = TreasuryBuilder.FromCode (
  307.             strCode,
  308.             adtEffective,
  309.             adtMaturity,
  310.             adblCoupon
  311.         );

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

  313.         CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer();

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

  315.         System.out.println();

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

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

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

  319.         for (int i = 0; i < aComp.length; ++i)
  320.             System.out.println ("\t| " + aComp[i].name() + " | " +
  321.                 FormatUtil.FormatDouble (adblYield[i], 1, 3, 100.) + "% | " +
  322.                 FormatUtil.FormatDouble (aComp[i].yieldFromPrice (
  323.                     valParams,
  324.                     null,
  325.                     null,
  326.                     aComp[i].maturityDate().julian(),
  327.                     1.,
  328.                     aComp[i].priceFromYield (
  329.                         valParams,
  330.                         null,
  331.                         null,
  332.                         mapGovvieCurve.get ("BASE").yield (aComp[i].maturityDate().julian())
  333.                     )
  334.                 ), 1, 3, 100.) + "% ||"
  335.             );

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

  337.         return mapGovvieCurve;
  338.     }

  339.     private static final void AccumulateBondMarketQuote (
  340.         final CurveSurfaceQuoteContainer csqc,
  341.         final String[] astrOnTheRunCode,
  342.         final double[] adblYield)
  343.         throws Exception
  344.     {
  345.         for (int i = 0; i < astrOnTheRunCode.length; ++i) {
  346.             ProductMultiMeasure pmmq = new ProductMultiMeasure();

  347.             pmmq.addQuote (
  348.                 "Yield",
  349.                 new MultiSided (
  350.                     "mid",
  351.                     adblYield[i]
  352.                 ),
  353.                 true
  354.             );

  355.             csqc.setProductQuote (
  356.                 astrOnTheRunCode[i],
  357.                 pmmq
  358.             );
  359.         }
  360.     }

  361.     private static final Bond Corporate (
  362.         final String strRateIndex,
  363.         final JulianDate dtEffective,
  364.         final JulianDate dtMaturity,
  365.         final double dblSpread)
  366.         throws Exception
  367.     {
  368.         return BondBuilder.CreateSimpleFloater (
  369.             strRateIndex + " +" + FormatUtil.FormatDouble (dblSpread, 3, 0, 10000.) + " bp " + dtMaturity,
  370.             "USD",
  371.             strRateIndex,
  372.             "",
  373.             dblSpread,
  374.             2,
  375.             "30/360",
  376.             dtEffective,
  377.             dtMaturity,
  378.             null,
  379.             null
  380.         );
  381.     }

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

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

  398.         System.out.println();

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

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

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

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

  403.         System.out.println();

  404.         String strCurveMetrics = "";
  405.         String strSecularMetrics = "";
  406.         double[] adblOAS = new double[aBond.length];

  407.         for (int i = 0; i < aBond.length; ++i) {
  408.             // System.out.println ("Doing " + aBond[i].name());

  409.             WorkoutInfo wi = aBond[i].exerciseYieldFromPrice (
  410.                 valParams,
  411.                 csqc,
  412.                 null,
  413.                 adblCleanPrice[i]
  414.             );

  415.             BondRVMeasures rvm = aBond[i].standardMeasures (
  416.                 valParams,
  417.                 null,
  418.                 csqc,
  419.                 null,
  420.                 wi,
  421.                 adblCleanPrice[i]
  422.             );

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

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

  437.             double dblCleanPriceOASUp = aBond[i].priceFromOAS (
  438.                 valParams,
  439.                 csqc,
  440.                 null,
  441.                 adblOAS[i] + 0.0001
  442.             );

  443.             double dblCleanPriceOASDown = aBond[i].priceFromOAS (
  444.                 valParams,
  445.                 csqc,
  446.                 null,
  447.                 adblOAS[i] - 0.0001
  448.             );

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

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

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

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

  468.         System.out.print (strSecularMetrics);

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

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

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

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

  473.         System.out.print (strCurveMetrics);

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

  475.         return adblOAS;
  476.     }

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

  485.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  486.             2017,
  487.             DateUtil.FEBRUARY,
  488.             2
  489.         );

  490.         String strCurrency = "USD";
  491.         String strTreasuryCode = "UST";

  492.         MergedDiscountForwardCurve dcFunding = FundingCurve (
  493.             dtSpot,
  494.             strCurrency
  495.         );

  496.         double[] adblTreasuryCoupon = new double[] {
  497.             0.0100,
  498.             0.0100,
  499.             0.0125,
  500.             0.0150,
  501.             0.0200,
  502.             0.0225,
  503.             0.0250,
  504.             0.0300
  505.         };

  506.         double[] adblTreasuryYield = new double[] {
  507.             0.0083, //  1Y
  508.             0.0122, //  2Y
  509.             0.0149, //  3Y
  510.             0.0193, //  5Y
  511.             0.0227, //  7Y
  512.             0.0248, // 10Y
  513.             0.0280, // 20Y
  514.             0.0308  // 30Y
  515.         };

  516.         Map<String, GovvieCurve> mapGovvieCurve = GovvieCurve (
  517.             dtSpot,
  518.             strTreasuryCode,
  519.             adblTreasuryCoupon,
  520.             adblTreasuryYield
  521.         );

  522.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  523.             dcFunding,
  524.             null,
  525.             null,
  526.             null,
  527.             null,
  528.             null,
  529.             null
  530.         );

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

  532.         AccumulateBondMarketQuote (
  533.             csqc,
  534.             new String[] {
  535.                 "01YON",
  536.                 "02YON",
  537.                 "03YON",
  538.                 "05YON",
  539.                 "07YON",
  540.                 "10YON",
  541.                 "20YON",
  542.                 "30YON"
  543.             },
  544.             adblTreasuryYield
  545.         );

  546.         double dblUSD3MLIBOR = dcFunding.libor (
  547.             dtSpot,
  548.             "3M"
  549.         );

  550.         Bond[] aAgencyBond = new Bond[] {
  551.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2014,  3, 24), DateUtil.CreateFromYMD (2017,  3, 24), 0.0178706 - dblUSD3MLIBOR),
  552.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2015,  8,  3), DateUtil.CreateFromYMD (2017,  8,  3), 0.0150904 - dblUSD3MLIBOR),
  553.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  6,  9), DateUtil.CreateFromYMD (2017, 12,  8), 0.0160083 - dblUSD3MLIBOR),
  554.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2013,  4, 30), DateUtil.CreateFromYMD (2018,  4, 30), 0.0208733 - dblUSD3MLIBOR),
  555.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016, 10, 19), DateUtil.CreateFromYMD (2018, 10, 19), 0.0169483 - dblUSD3MLIBOR),
  556.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2015, 12, 14), DateUtil.CreateFromYMD (2018, 12, 14), 0.0179872 - dblUSD3MLIBOR),
  557.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  1, 14), DateUtil.CreateFromYMD (2019,  1, 14), 0.0180317 - dblUSD3MLIBOR),
  558.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  1, 15), DateUtil.CreateFromYMD (2019,  1, 15), 0.0220317 - dblUSD3MLIBOR),
  559.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  1, 22), DateUtil.CreateFromYMD (2019,  1, 22), 0.0204122 - dblUSD3MLIBOR),
  560.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  1, 27), DateUtil.CreateFromYMD (2019,  2,  1), 0.0226094 - dblUSD3MLIBOR),
  561.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  2, 23), DateUtil.CreateFromYMD (2019,  2, 22), 0.0173983 - dblUSD3MLIBOR),
  562.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  3,  4), DateUtil.CreateFromYMD (2019,  3, 14), 0.0243872 - dblUSD3MLIBOR),
  563.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  3, 15), DateUtil.CreateFromYMD (2019,  3, 15), 0.0165344 - dblUSD3MLIBOR),
  564.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  5, 13), DateUtil.CreateFromYMD (2019,  5, 13), 0.0161206 - dblUSD3MLIBOR),
  565.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  6,  2), DateUtil.CreateFromYMD (2019,  5, 24), 0.0153011 - dblUSD3MLIBOR),
  566.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  6, 14), DateUtil.CreateFromYMD (2019,  6, 14), 0.0161872 - dblUSD3MLIBOR),
  567.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  9,  8), DateUtil.CreateFromYMD (2019,  9,  6), 0.0152639 - dblUSD3MLIBOR),
  568.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016,  9, 30), DateUtil.CreateFromYMD (2019,  9, 30), 0.0161817 - dblUSD3MLIBOR),
  569.             Corporate ("USD-3M", DateUtil.CreateFromYMD (2016, 10, 18), DateUtil.CreateFromYMD (2019, 10, 18), 0.0193372 - dblUSD3MLIBOR),
  570.         };

  571.         double[] adblCleanPrice = new double[] {
  572.             1.0006750,  // (2017,  3, 24)
  573.             1.0027220,  // (2017,  8,  3)
  574.             1.0050000,  // (2017, 12,  8)
  575.             1.0091000,  // (2018,  4, 30)
  576.             1.0016000,  // (2018, 10, 19)
  577.             1.0053430,  // (2018, 12, 14)
  578.             1.0051600,  // (2019,  1, 14)
  579.             1.0075900,  // (2019,  1, 15)
  580.             1.0085700,  // (2019,  1, 22)
  581.             1.0174100,  // (2019,  2,  1)
  582.             1.0144650,  // (2019,  2, 22)
  583.             1.0152950,  // (2019,  3, 14)
  584.             1.0106700,  // (2019,  3, 15)
  585.             1.0045400,  // (2019,  5, 13)
  586.             1.0025140,  // (2019,  5, 24)
  587.             1.0027120,  // (2019,  6, 14)
  588.             1.0012000,  // (2019,  9,  6)
  589.             1.0022590,  // (2019,  9, 30)
  590.             1.0003480,  // (2019, 10, 18)
  591.         };

  592.         double[] adblOAS = RVMeasures (
  593.             aAgencyBond,
  594.             dtSpot,
  595.             csqc,
  596.             adblCleanPrice
  597.         );

  598.         ValuationParams valParams = new ValuationParams (
  599.             dtSpot,
  600.             dtSpot.addBusDays (
  601.                 3,
  602.                 dcFunding.currency()
  603.             ),
  604.             dcFunding.currency()
  605.         );

  606.         System.out.println();

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

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

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

  612.             System.out.print (" | " + meGovvieCurve.getKey());
  613.         }

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

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

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

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

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

  622.                 System.out.print (" |      " +
  623.                     FormatUtil.FormatDouble (
  624.                         (adblCleanPrice[i] - aAgencyBond[i].priceFromOAS (
  625.                             valParams,
  626.                             csqc,
  627.                             null,
  628.                             adblOAS[i]
  629.                         )) / adblCleanPrice[i],
  630.                     2, 2, 10000.) + "     "
  631.                 );
  632.             }

  633.             System.out.println (" ||");
  634.         }

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

  636.         EnvManager.TerminateEnv();
  637.     }
  638. }