LatamCorp.java

  1. package org.drip.sample.cma;

  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>LatamCorp</i> demonstrates LATAM Corporate Bond Pricing and Relative Value Measure Generation
  94.  * 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/cma/README.md">LATAM Corporate and Sovereign Bonds</a></li>
  102.  *  </ul>
  103.  * <br><br>
  104.  *
  105.  * @author Lakshmi Krishnamurthy
  106.  */

  107. public class LatamCorp {

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

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

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

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

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

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

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

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

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

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

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

  208.         System.out.println();

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

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

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

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

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

  224.         System.out.println();

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

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

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

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

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

  240.         System.out.println();

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

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

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

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

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

  263.         System.out.println();

  264.         return dcFunding;
  265.     }

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

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

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

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

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

  312.         CurveSurfaceQuoteContainer csqc = new CurveSurfaceQuoteContainer();

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

  314.         System.out.println();

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

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

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

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

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

  336.         return mapGovvieCurve;
  337.     }

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

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

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

  360.     private static final Bond Corporate (
  361.         final String strName,
  362.         final JulianDate dtEffective,
  363.         final JulianDate dtMaturity,
  364.         final double dblCoupon,
  365.         final int iFreq,
  366.         final String strDayCount)
  367.         throws Exception
  368.     {
  369.         return BondBuilder.CreateSimpleFixed (
  370.             strName + FormatUtil.FormatDouble (dblCoupon, 1, 4, 100.) + " " + dtMaturity,
  371.             "USD",
  372.             "",
  373.             dblCoupon,
  374.             iFreq,
  375.             strDayCount,
  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.             2,
  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.             WorkoutInfo wi = aBond[i].exerciseYieldFromPrice (
  409.                 valParams,
  410.                 csqc,
  411.                 null,
  412.                 adblCleanPrice[i]
  413.             );

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

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

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

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

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

  448.             strCurveMetrics += "\t| " +
  449.                 aBond[i].name() + " |" +
  450.                 FormatUtil.FormatDouble (adblCleanPrice[i], 3, 3, 100.) + " |" +
  451.                 FormatUtil.FormatDouble (wi.yield(), 2, 2, 100.) + "% |   " +
  452.                 FormatUtil.FormatDouble (rvm.zSpread(), 4, 0, 10000.) + "   |" +
  453.                 FormatUtil.FormatDouble (adblOAS[i], 4, 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(), 4, 0, 10000.) + " |  " +
  457.                 FormatUtil.FormatDouble (rvm.gSpread(), 4, 0, 10000.) + "    |   " +
  458.                 FormatUtil.FormatDouble (rvm.iSpread(), 4, 0, 10000.) + "   |    " +
  459.                 FormatUtil.FormatDouble (rvm.tsySpread(), 4, 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.println (strSecularMetrics);

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

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

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

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

  473.         System.out.println (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.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  483.             2017,
  484.             DateUtil.MAY,
  485.             9
  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.0250,
  501.             0.0300
  502.         };

  503.         double[] adblTreasuryYield = new double[] {
  504.             0.01109, //  1Y
  505.             0.01345, //  2Y
  506.             0.01552, //  3Y
  507.             0.01925, //  5Y
  508.             0.02205, //  7Y
  509.             0.02406, // 10Y
  510.             0.02717, // 20Y
  511.             0.03028  // 30Y
  512.         };

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

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

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

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

  543.         Bond[] aCorporateBond = new Bond[] {
  544.             Corporate (" PDVSA ", DateUtil.CreateFromYMD (2013, 11, 15), DateUtil.CreateFromYMD (2026, 11, 15), 0.06000, 2, "ISMA 30/360"),
  545.             Corporate (" PDVSA ", DateUtil.CreateFromYMD (2012,  4, 12), DateUtil.CreateFromYMD (2027,  4, 12), 0.05375, 2, "ISMA 30/360"),
  546.             Corporate (" PDVSA ", DateUtil.CreateFromYMD (2012,  5, 17), DateUtil.CreateFromYMD (2035,  5, 17), 0.09750, 2, "ISMA 30/360"),
  547.             Corporate (" PDVSA ", DateUtil.CreateFromYMD (2012,  4, 12), DateUtil.CreateFromYMD (2037,  4, 12), 0.05500, 2, "ISMA 30/360"),
  548.             Corporate ("  URU  ", DateUtil.CreateFromYMD (2014,  1, 15), DateUtil.CreateFromYMD (2033,  1, 15), 0.07875, 2, "ISMA 30/360"),
  549.         };

  550.         double[] adblCleanPrice = new double[] {
  551.             0.3850000,  // (2026, 11, 15)
  552.             0.3823900,  // (2027,  4, 12)
  553.             0.4550000,  // (2035,  5, 17)
  554.             0.3850000,  // (2037,  4, 12)
  555.             1.3315000,  // (2033,  1, 15)
  556.         };

  557.         double[] adblOAS = RVMeasures (
  558.             aCorporateBond,
  559.             dtSpot,
  560.             csqc,
  561.             adblCleanPrice
  562.         );

  563.         ValuationParams valParams = new ValuationParams (
  564.             dtSpot,
  565.             dtSpot.addBusDays (
  566.                 2,
  567.                 dcFunding.currency()
  568.             ),
  569.             dcFunding.currency()
  570.         );

  571.         System.out.println();

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

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

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

  577.             System.out.print (" | " + meGovvieCurve.getKey());
  578.         }

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

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

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

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

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

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

  598.             System.out.println (" ||");
  599.         }

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

  601.         System.out.println();

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