FRAStandardOptionAnalysis.java

  1. package org.drip.sample.fra;

  2. import java.util.*;

  3. import org.drip.analytics.date.*;
  4. import org.drip.function.r1tor1.FlatUnivariate;
  5. import org.drip.market.otc.*;
  6. import org.drip.param.creator.*;
  7. import org.drip.param.market.CurveSurfaceQuoteContainer;
  8. import org.drip.param.valuation.*;
  9. import org.drip.pricer.option.BlackScholesAlgorithm;
  10. import org.drip.product.creator.*;
  11. import org.drip.product.definition.*;
  12. import org.drip.product.fra.*;
  13. import org.drip.product.params.LastTradingDateSetting;
  14. import org.drip.product.rates.*;
  15. import org.drip.service.env.EnvManager;
  16. import org.drip.spline.basis.PolynomialFunctionSetParams;
  17. import org.drip.spline.stretch.MultiSegmentSequenceBuilder;
  18. import org.drip.state.creator.*;
  19. import org.drip.state.discount.*;
  20. import org.drip.state.forward.ForwardCurve;
  21. import org.drip.state.identifier.*;

  22. /*
  23.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  24.  */

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

  88. /**
  89.  * <i>FRAStandardOptionAnalysis</i> contains the demonstration of the custom volatility-correlation analysis
  90.  * of Option on a Standard Multi-Curve FRA.
  91.  *  
  92.  * <br><br>
  93.  *  <ul>
  94.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  95.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  96.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  97.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/fra/README.md">FRA Analytics</a></li>
  98.  *  </ul>
  99.  * <br><br>
  100.  *
  101.  * @author Lakshmi Krishnamurthy
  102.  */

  103. public class FRAStandardOptionAnalysis {

  104.     private static final FixFloatComponent OTCFixFloat (
  105.         final JulianDate dtSpot,
  106.         final String strCurrency,
  107.         final String strMaturityTenor,
  108.         final double dblCoupon)
  109.     {
  110.         FixedFloatSwapConvention ffConv = IBORFixedFloatContainer.ConventionFromJurisdiction (
  111.             strCurrency,
  112.             "ALL",
  113.             strMaturityTenor,
  114.             "MAIN"
  115.         );

  116.         return ffConv.createFixFloatComponent (
  117.             dtSpot,
  118.             strMaturityTenor,
  119.             dblCoupon,
  120.             0.,
  121.             1.
  122.         );
  123.     }

  124.     private static final FloatFloatComponent OTCFloatFloat (
  125.         final JulianDate dtSpot,
  126.         final String strCurrency,
  127.         final String strDerivedTenor,
  128.         final String strMaturityTenor,
  129.         final double dblBasis)
  130.     {
  131.         FloatFloatSwapConvention ffConv = IBORFloatFloatContainer.ConventionFromJurisdiction (strCurrency);

  132.         return ffConv.createFloatFloatComponent (
  133.             dtSpot,
  134.             strDerivedTenor,
  135.             strMaturityTenor,
  136.             dblBasis,
  137.             1.
  138.         );
  139.     }

  140.     /*
  141.      * Construct the Array of Deposit Instruments from the given set of parameters
  142.      *
  143.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  144.      */

  145.     private static final CalibratableComponent[] DepositInstrumentsFromMaturityDays (
  146.         final JulianDate dtEffective,
  147.         final int[] aiDay,
  148.         final int iNumFuture,
  149.         final String strCurrency)
  150.         throws Exception
  151.     {
  152.         CalibratableComponent[] aCalibComp = new CalibratableComponent[aiDay.length + iNumFuture];

  153.         for (int i = 0; i < aiDay.length; ++i)
  154.             aCalibComp[i] = SingleStreamComponentBuilder.Deposit (
  155.                 dtEffective,
  156.                 dtEffective.addBusDays (
  157.                     aiDay[i],
  158.                     strCurrency
  159.                 ),
  160.                 ForwardLabel.Create (
  161.                     strCurrency,
  162.                     "3M"
  163.                 )
  164.             );

  165.         CalibratableComponent[] aEDF = SingleStreamComponentBuilder.ForwardRateFuturesPack (
  166.             dtEffective,
  167.             iNumFuture,
  168.             strCurrency
  169.         );

  170.         for (int i = aiDay.length; i < aiDay.length + iNumFuture; ++i)
  171.             aCalibComp[i] = aEDF[i - aiDay.length];

  172.         return aCalibComp;
  173.     }

  174.     /*
  175.      * Construct the Array of Swap Instruments from the given set of parameters
  176.      *
  177.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  178.      */

  179.     private static final FixFloatComponent[] SwapInstrumentsFromMaturityTenor (
  180.         final JulianDate dtSpot,
  181.         final String strCurrency,
  182.         final String[] astrMaturityTenor,
  183.         final double[] adblCoupon)
  184.         throws Exception
  185.     {
  186.         FixFloatComponent[] aIRS = new FixFloatComponent[astrMaturityTenor.length];

  187.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  188.             aIRS[i] = OTCFixFloat (
  189.                 dtSpot,
  190.                 strCurrency,
  191.                 astrMaturityTenor[i],
  192.                 adblCoupon[i]
  193.             );

  194.         return aIRS;
  195.     }

  196.     /*
  197.      * Construct the discount curve using the following steps:
  198.      *  - Construct the array of cash instruments and their quotes.
  199.      *  - Construct the array of swap instruments and their quotes.
  200.      *  - Construct a shape preserving and smoothing KLK Hyperbolic Spline from the cash/swap instruments.
  201.      *
  202.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  203.      */

  204.     private static final MergedDiscountForwardCurve MakeDC (
  205.         final JulianDate dtSpot,
  206.         final String strCurrency)
  207.         throws Exception
  208.     {
  209.         /*
  210.          * Construct the array of Deposit instruments and their quotes.
  211.          */

  212.         CalibratableComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  213.             dtSpot,
  214.             new int[] {
  215.                 1, 2, 3, 7, 14, 21, 30, 60
  216.             },
  217.             0,
  218.             strCurrency
  219.         );

  220.         double[] adblDepositQuote = new double[] {
  221.             0.01200, 0.01200, 0.01200, 0.01450, 0.01550, 0.01600, 0.01660, 0.01850
  222.         };

  223.         String[] astrDepositManifestMeasure = new String[] {
  224.             "ForwardRate",
  225.             "ForwardRate",
  226.             "ForwardRate",
  227.             "ForwardRate",
  228.             "ForwardRate",
  229.             "ForwardRate",
  230.             "ForwardRate",
  231.             "ForwardRate"
  232.         };

  233.         /*
  234.          * Construct the array of Swap instruments and their quotes.
  235.          */

  236.         double[] adblSwapQuote = new double[] {
  237.             0.02604,    //  4Y
  238.             0.02808,    //  5Y
  239.             0.02983,    //  6Y
  240.             0.03136,    //  7Y
  241.             0.03268,    //  8Y
  242.             0.03383,    //  9Y
  243.             0.03488,    // 10Y
  244.             0.03583,    // 11Y
  245.             0.03668,    // 12Y
  246.             0.03833,    // 15Y
  247.             0.03854,    // 20Y
  248.             0.03672,    // 25Y
  249.             0.03510,    // 30Y
  250.             0.03266,    // 40Y
  251.             0.03145     // 50Y
  252.         };

  253.         String[] astrSwapManifestMeasure = new String[] {
  254.             "SwapRate",    //  4Y
  255.             "SwapRate",    //  5Y
  256.             "SwapRate",    //  6Y
  257.             "SwapRate",    //  7Y
  258.             "SwapRate",    //  8Y
  259.             "SwapRate",    //  9Y
  260.             "SwapRate",    // 10Y
  261.             "SwapRate",    // 11Y
  262.             "SwapRate",    // 12Y
  263.             "SwapRate",    // 15Y
  264.             "SwapRate",    // 20Y
  265.             "SwapRate",    // 25Y
  266.             "SwapRate",    // 30Y
  267.             "SwapRate",    // 40Y
  268.             "SwapRate"     // 50Y
  269.         };

  270.         CalibratableComponent[] aSwapComp = SwapInstrumentsFromMaturityTenor (
  271.             dtSpot,
  272.             strCurrency,
  273.             new java.lang.String[] {
  274.                 "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "40Y", "50Y"
  275.             },
  276.             adblSwapQuote
  277.         );

  278.         /*
  279.          * Construct a shape preserving and smoothing KLK Hyperbolic Spline from the cash/swap instruments.
  280.          */

  281.         return ScenarioDiscountCurveBuilder.CubicKLKHyperbolicDFRateShapePreserver (
  282.             "KLK_HYPERBOLIC_SHAPE_TEMPLATE",
  283.             new ValuationParams (
  284.                 dtSpot,
  285.                 dtSpot,
  286.                 strCurrency
  287.             ),
  288.             aDepositComp,
  289.             adblDepositQuote,
  290.             astrDepositManifestMeasure,
  291.             aSwapComp,
  292.             adblSwapQuote,
  293.             astrSwapManifestMeasure,
  294.             false
  295.         );
  296.     }

  297.     /*
  298.      * Construct an array of float-float swaps from the corresponding reference (6M) and the derived legs.
  299.      *
  300.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  301.      */

  302.     private static final FloatFloatComponent[] MakexM6MBasisSwap (
  303.         final JulianDate dtSpot,
  304.         final String strCurrency,
  305.         final String[] astrMaturityTenor,
  306.         final int iTenorInMonths)
  307.         throws Exception
  308.     {
  309.         FloatFloatComponent[] aFFC = new FloatFloatComponent[astrMaturityTenor.length];

  310.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  311.             aFFC[i] = OTCFloatFloat (
  312.                 dtSpot,
  313.                 strCurrency,
  314.                 iTenorInMonths + "M",
  315.                 astrMaturityTenor[i],
  316.                 0.
  317.             );

  318.         return aFFC;
  319.     }

  320.     private static final ForwardCurve MakeFC (
  321.         final JulianDate dtSpot,
  322.         final String strCurrency,
  323.         final MergedDiscountForwardCurve dc,
  324.         final int iTenorInMonths,
  325.         final String[] astrxM6MFwdTenor,
  326.         final double[] adblxM6MBasisSwapQuote)
  327.         throws Exception
  328.     {
  329.         /*
  330.          * Construct the 6M-xM float-float basis swap.
  331.          */

  332.         FloatFloatComponent[] aFFC = MakexM6MBasisSwap (
  333.             dtSpot,
  334.             strCurrency,
  335.             astrxM6MFwdTenor,
  336.             iTenorInMonths
  337.         );

  338.         String strBasisTenor = iTenorInMonths + "M";

  339.         ValuationParams valParams = new ValuationParams (
  340.             dtSpot,
  341.             dtSpot,
  342.             strCurrency
  343.         );

  344.         /*
  345.          * Calculate the starting forward rate off of the discount curve.
  346.          */

  347.         double dblStartingFwd = dc.forward (
  348.             dtSpot.julian(),
  349.             dtSpot.addTenor (strBasisTenor).julian()
  350.         );

  351.         /*
  352.          * Set the discount curve based component market parameters.
  353.          */

  354.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (dc, null, null, null, null, null, null);

  355.         /*
  356.          * Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  357.          */

  358.         return ScenarioForwardCurveBuilder.ShapePreservingForwardCurve (
  359.             "QUARTIC_FWD" + strBasisTenor,
  360.             ForwardLabel.Create (
  361.                 strCurrency,
  362.                 strBasisTenor
  363.             ),
  364.             valParams,
  365.             null,
  366.             mktParams,
  367.             null,
  368.             MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  369.             new PolynomialFunctionSetParams (5),
  370.             aFFC,
  371.             "DerivedParBasisSpread",
  372.             adblxM6MBasisSwapQuote,
  373.             dblStartingFwd
  374.         );
  375.     }

  376.     private static final Map<String, ForwardCurve> MakeFC (
  377.         final JulianDate dt,
  378.         final String strCurrency,
  379.         final MergedDiscountForwardCurve dc)
  380.         throws Exception
  381.     {
  382.         Map<String, ForwardCurve> mapFC = new HashMap<String, ForwardCurve>();

  383.         /*
  384.          * Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  385.          */

  386.         ForwardCurve fc1M = MakeFC (
  387.             dt,
  388.             strCurrency,
  389.             dc,
  390.             1,
  391.             new String[] {
  392.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  393.             },
  394.             new double[] {
  395.                 0.00551,    //  1Y
  396.                 0.00387,    //  2Y
  397.                 0.00298,    //  3Y
  398.                 0.00247,    //  4Y
  399.                 0.00211,    //  5Y
  400.                 0.00185,    //  6Y
  401.                 0.00165,    //  7Y
  402.                 0.00150,    //  8Y
  403.                 0.00137,    //  9Y
  404.                 0.00127,    // 10Y
  405.                 0.00119,    // 11Y
  406.                 0.00112,    // 12Y
  407.                 0.00096,    // 15Y
  408.                 0.00079,    // 20Y
  409.                 0.00069,    // 25Y
  410.                 0.00062     // 30Y
  411.             }
  412.         );

  413.         mapFC.put (
  414.             "1M",
  415.             fc1M
  416.         );

  417.         /*
  418.          * Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  419.          */

  420.         ForwardCurve fc3M = MakeFC (
  421.             dt,
  422.             strCurrency,
  423.             dc,
  424.             3,
  425.             new String[] {
  426.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  427.             },
  428.             new double[] {
  429.                 0.00186,    //  1Y
  430.                 0.00127,    //  2Y
  431.                 0.00097,    //  3Y
  432.                 0.00080,    //  4Y
  433.                 0.00067,    //  5Y
  434.                 0.00058,    //  6Y
  435.                 0.00051,    //  7Y
  436.                 0.00046,    //  8Y
  437.                 0.00042,    //  9Y
  438.                 0.00038,    // 10Y
  439.                 0.00035,    // 11Y
  440.                 0.00033,    // 12Y
  441.                 0.00028,    // 15Y
  442.                 0.00022,    // 20Y
  443.                 0.00020,    // 25Y
  444.                 0.00018     // 30Y
  445.             }
  446.         );

  447.         mapFC.put (
  448.             "3M",
  449.             fc3M
  450.         );

  451.         /*
  452.          * Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  453.          */

  454.         ForwardCurve fc12M = MakeFC (
  455.             dt,
  456.             strCurrency,
  457.             dc,
  458.             12,
  459.             new String[] {
  460.                 "1Y", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y", "35Y", "40Y"
  461.             },
  462.             new double[] {
  463.                 -0.00212,    //  1Y
  464.                 -0.00152,    //  2Y
  465.                 -0.00117,    //  3Y
  466.                 -0.00097,    //  4Y
  467.                 -0.00082,    //  5Y
  468.                 -0.00072,    //  6Y
  469.                 -0.00063,    //  7Y
  470.                 -0.00057,    //  8Y
  471.                 -0.00051,    //  9Y
  472.                 -0.00047,    // 10Y
  473.                 -0.00044,    // 11Y
  474.                 -0.00041,    // 12Y
  475.                 -0.00035,    // 15Y
  476.                 -0.00028,    // 20Y
  477.                 -0.00025,    // 25Y
  478.                 -0.00022,    // 30Y
  479.                 -0.00022,    // 35Y Extrapolated
  480.                 -0.00022,    // 40Y Extrapolated
  481.             }
  482.         );

  483.         mapFC.put (
  484.             "12M",
  485.             fc12M
  486.         );

  487.         return mapFC;
  488.     }

  489.     private static final void VolCorrScenario (
  490.         final FRAStandardComponent fra,
  491.         final ValuationParams valParams,
  492.         final CurveSurfaceQuoteContainer mktParams,
  493.         final double dblForwardVol,
  494.         final double dblFundingVol,
  495.         final double dblForwardFundingCorr)
  496.         throws Exception
  497.     {
  498.         ForwardLabel fri = fra.forwardLabel().get ("DERIVED");

  499.         FundingLabel fundingLabel = FundingLabel.Standard (fri.currency());

  500.         mktParams.setForwardVolatility (
  501.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  502.                 valParams.valueDate(),
  503.                 VolatilityLabel.Standard (fri),
  504.                 fri.currency(),
  505.                 dblForwardVol
  506.             )
  507.         );

  508.         mktParams.setFundingVolatility (
  509.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  510.                 valParams.valueDate(),
  511.                 VolatilityLabel.Standard (fundingLabel),
  512.                 fri.currency(),
  513.                 dblFundingVol
  514.             )
  515.         );

  516.         mktParams.setForwardFundingCorrelation (
  517.             fri,
  518.             fundingLabel,
  519.             new FlatUnivariate (dblForwardFundingCorr)
  520.         );

  521.         double dblStrike = 0.0189;
  522.         String strManifestMeasure = "QuantoAdjustedParForward";

  523.         FRAStandardCapFloorlet fraCaplet = new FRAStandardCapFloorlet (
  524.             fra.name() + "::CAPLET",
  525.             fra,
  526.             strManifestMeasure,
  527.             true,
  528.             dblStrike,
  529.             1.,
  530.             new LastTradingDateSetting (
  531.                 LastTradingDateSetting.MID_CURVE_OPTION_QUARTERLY,
  532.                 "",
  533.                 Integer.MIN_VALUE
  534.             ),
  535.             new BlackScholesAlgorithm(),
  536.             null
  537.         );

  538.         FRAStandardCapFloorlet fraFloorlet = new FRAStandardCapFloorlet (
  539.             fra.name() + "::FLOORLET",
  540.             fra,
  541.             strManifestMeasure,
  542.             false,
  543.             dblStrike,
  544.             1.,
  545.             new LastTradingDateSetting (
  546.                 LastTradingDateSetting.MID_CURVE_OPTION_QUARTERLY,
  547.                 "",
  548.                 Integer.MIN_VALUE
  549.             ),
  550.             new BlackScholesAlgorithm(),
  551.             null
  552.         );

  553.         Map<String, Double> mapFRACapletOutput = fraCaplet.value (
  554.             valParams,
  555.             null,
  556.             mktParams,
  557.             null
  558.         );

  559.         Map<String, Double> mapFRAFloorletOutput = fraFloorlet.value (
  560.             valParams,
  561.             null,
  562.             mktParams,
  563.             null
  564.         );

  565.         double dblATMFRA = mapFRACapletOutput.get ("ATMFRA");

  566.         double dblManifestMeasureIntrinsic = mapFRACapletOutput.get ("ManifestMeasureIntrinsic");

  567.         double dblManifestMeasureIntrinsicValue = mapFRACapletOutput.get ("ManifestMeasureIntrinsicValue");

  568.         double dblForwardATMCapletPrice = mapFRACapletOutput.get ("ForwardATMIntrinsic");

  569.         double dblSpotCapletPrice = mapFRACapletOutput.get ("SpotPrice");

  570.         double dblForwardATMFloorletPrice = mapFRAFloorletOutput.get ("ForwardATMIntrinsic");

  571.         double dblSpotFloorletPrice = mapFRAFloorletOutput.get ("SpotPrice");

  572.         System.out.println ("\t[" +
  573.             org.drip.numerical.common.FormatUtil.FormatDouble (dblForwardVol, 2, 0, 100.) + "%," +
  574.             org.drip.numerical.common.FormatUtil.FormatDouble (dblFundingVol, 2, 0, 100.) + "%," +
  575.             org.drip.numerical.common.FormatUtil.FormatDouble (dblForwardFundingCorr, 2, 0, 100.) + "%] =" +
  576.             org.drip.numerical.common.FormatUtil.FormatDouble (dblATMFRA, 1, 4, 100.) + "% | " +
  577.             org.drip.numerical.common.FormatUtil.FormatDouble (dblManifestMeasureIntrinsic, 1, 1, 10000.) + " | " +
  578.             org.drip.numerical.common.FormatUtil.FormatDouble (dblManifestMeasureIntrinsicValue, 1, 1, 10000.) + " | " +
  579.             org.drip.numerical.common.FormatUtil.FormatDouble (dblForwardATMCapletPrice, 1, 1, 10000.) + " | " +
  580.             org.drip.numerical.common.FormatUtil.FormatDouble (dblSpotCapletPrice, 1, 1, 10000.) + " | " +
  581.             org.drip.numerical.common.FormatUtil.FormatDouble (dblForwardATMFloorletPrice, 1, 1, 10000.) + " | " +
  582.             org.drip.numerical.common.FormatUtil.FormatDouble (dblSpotFloorletPrice, 1, 1, 10000.));
  583.     }

  584.     public static final void main (
  585.         final String[] astrArgs)
  586.         throws Exception
  587.     {
  588.         /*
  589.          * Initialize the Credit Analytics Library
  590.          */

  591.         EnvManager.InitEnv ("");

  592.         String strTenor = "3M";
  593.         String strCurrency = "USD";

  594.         JulianDate dtToday = DateUtil.Today().addTenor ("0D");

  595.         /*
  596.          * Construct the Discount Curve using its instruments and quotes
  597.          */

  598.         MergedDiscountForwardCurve dc = MakeDC (
  599.             dtToday,
  600.             strCurrency
  601.         );

  602.         Map<String, ForwardCurve> mapFC = MakeFC (
  603.             dtToday,
  604.             strCurrency,
  605.             dc
  606.         );

  607.         ForwardLabel fri = ForwardLabel.Create (strCurrency, strTenor);

  608.         JulianDate dtForwardStart = dtToday.addTenor (strTenor);

  609.         FRAStandardComponent fra = SingleStreamComponentBuilder.FRAStandard (
  610.             dtForwardStart,
  611.             fri,
  612.             0.006
  613.         );

  614.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  615.             dc,
  616.             mapFC.get (strTenor),
  617.             null,
  618.             null,
  619.             null,
  620.             null,
  621.             null,
  622.             null
  623.         );

  624.         ValuationParams valParams = new ValuationParams (
  625.             dtToday,
  626.             dtToday,
  627.             strCurrency
  628.         );

  629.         double[] adblSigmaFwd = new double[] {0.1, 0.2, 0.3, 0.4, 0.5};
  630.         double[] adblSigmaFwd2DomX = new double[] {0.10, 0.15, 0.20, 0.25, 0.30};
  631.         double[] adblCorrFwdFwd2DomX = new double[] {-0.99, -0.50, 0.00, 0.50, 0.99};

  632.         System.out.println ("\tPrinting the IRS Output in Order (Left -> Right):");

  633.         System.out.println ("\t\tFRA ATM (%)");

  634.         System.out.println ("\t\tManifest Measure Instrinsic (bp)");

  635.         System.out.println ("\t\tManifest Measure Instrinsic Value");

  636.         System.out.println ("\t\tForward Caplet ATM Price");

  637.         System.out.println ("\t\tSpot Caplet Price");

  638.         System.out.println ("\t\tForward Floorlet ATM Price");

  639.         System.out.println ("\t\tSpot Floorlet Price");

  640.         System.out.println ("\t-------------------------------------------------------------");

  641.         System.out.println ("\t-------------------------------------------------------------");

  642.         for (double dblSigmaFwd : adblSigmaFwd) {
  643.             for (double dblSigmaFwd2DomX : adblSigmaFwd2DomX) {
  644.                 for (double dblCorrFwdFwd2DomX : adblCorrFwdFwd2DomX)
  645.                     VolCorrScenario (
  646.                         fra,
  647.                         valParams,
  648.                         mktParams,
  649.                         dblSigmaFwd,
  650.                         dblSigmaFwd2DomX,
  651.                         dblCorrFwdFwd2DomX
  652.                     );
  653.             }
  654.         }

  655.         EnvManager.TerminateEnv();
  656.     }
  657. }