FRAStandardOption.java

  1. package org.drip.sample.fra;

  2. import java.util.*;

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

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

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

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

  104. public class FRAStandardOption {

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

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

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

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

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

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

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

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

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

  173.         return aCalibComp;
  174.     }

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

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

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

  195.         return aIRS;
  196.     }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  319.         return aFFC;
  320.     }

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

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

  339.         String strBasisTenor = iTenorInMonths + "M";

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

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

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

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

  355.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  356.             dc,
  357.             null,
  358.             null,
  359.             null,
  360.             null,
  361.             null,
  362.             null
  363.         );

  364.         /*
  365.          * Construct the shape preserving forward curve off of Quartic Polynomial Basis Spline.
  366.          */

  367.         return ScenarioForwardCurveBuilder.ShapePreservingForwardCurve (
  368.             "QUARTIC_FWD" + strBasisTenor,
  369.             ForwardLabel.Create (
  370.                 strCurrency,
  371.                 strBasisTenor
  372.             ),
  373.             valParams,
  374.             null,
  375.             mktParams,
  376.             null,
  377.             MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  378.             new PolynomialFunctionSetParams (5),
  379.             aFFC,
  380.             "DerivedParBasisSpread",
  381.             adblxM6MBasisSwapQuote,
  382.             dblStartingFwd
  383.         );
  384.     }

  385.     private static final Map<String, ForwardCurve> MakeFC (
  386.         final JulianDate dt,
  387.         final String strCurrency,
  388.         final MergedDiscountForwardCurve dc)
  389.         throws Exception
  390.     {
  391.         Map<String, ForwardCurve> mapFC = new HashMap<String, ForwardCurve>();

  392.         /*
  393.          * Build and run the sampling for the 1M-6M Tenor Basis Swap from its instruments and quotes.
  394.          */

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

  422.         mapFC.put (
  423.             "1M",
  424.             fc1M
  425.         );

  426.         /*
  427.          * Build and run the sampling for the 3M-6M Tenor Basis Swap from its instruments and quotes.
  428.          */

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

  456.         mapFC.put (
  457.             "3M",
  458.             fc3M
  459.         );

  460.         /*
  461.          * Build and run the sampling for the 12M-6M Tenor Basis Swap from its instruments and quotes.
  462.          */

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

  492.         mapFC.put (
  493.             "12M",
  494.             fc12M
  495.         );

  496.         return mapFC;
  497.     }

  498.     public static final void main (
  499.         final String[] astrArgs)
  500.         throws Exception
  501.     {
  502.         /*
  503.          * Initialize the Credit Analytics Library
  504.          */

  505.         EnvManager.InitEnv ("");

  506.         String strTenor = "3M";
  507.         String strCurrency = "USD";
  508.         String strManifestMeasure = "QuantoAdjustedParForward";
  509.         double dblForwardVol = 0.3;
  510.         double dblFundingVol = 0.1;
  511.         double dblForwardFundingCorr = 0.2;
  512.         double dblCorrMeanReverterHazard = 0.4 / 365.25;

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

  514.         /*
  515.          * Construct the Discount Curve using its instruments and quotes
  516.          */

  517.         MergedDiscountForwardCurve dc = MakeDC (
  518.             dtToday,
  519.             strCurrency
  520.         );

  521.         Map<String, ForwardCurve> mapFC = MakeFC (
  522.             dtToday,
  523.             strCurrency,
  524.             dc
  525.         );

  526.         ForwardLabel fri = ForwardLabel.Create (
  527.             strCurrency,
  528.             strTenor
  529.         );

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

  531.         FRAStandardComponent fra = SingleStreamComponentBuilder.FRAStandard (
  532.             dtForwardStart,
  533.             fri,
  534.             0.006
  535.         );

  536.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  537.             dc,
  538.             mapFC.get (strTenor),
  539.             null,
  540.             null,
  541.             null,
  542.             null,
  543.             null,
  544.             null
  545.         );

  546.         ValuationParams valParams = new ValuationParams (
  547.             dtToday,
  548.             dtToday,
  549.             strCurrency
  550.         );

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

  552.         mktParams.setForwardVolatility (
  553.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  554.                 dtToday.julian(),
  555.                 VolatilityLabel.Standard (fri),
  556.                 fri.currency(),
  557.                 dblForwardVol
  558.             )
  559.         );

  560.         mktParams.setFundingVolatility (
  561.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  562.                 dtToday.julian(),
  563.                 VolatilityLabel.Standard (fundingLabel),
  564.                 fri.currency(),
  565.                 dblFundingVol
  566.             )
  567.         );

  568.         mktParams.setForwardFundingCorrelation (
  569.             fri,
  570.             fundingLabel,
  571.             new AndersenPiterbargMeanReverter (
  572.                 new ExponentialDecay (
  573.                     dtToday.julian(),
  574.                     dblCorrMeanReverterHazard),
  575.                 new FlatUnivariate (dblForwardFundingCorr)
  576.             )
  577.         );

  578.         Map<String, Double> mapFRAOutput = fra.value (
  579.             valParams,
  580.             null,
  581.             mktParams,
  582.             null
  583.         );

  584.         double dblStrike = 1.01 * mapFRAOutput.get (strManifestMeasure);

  585.         FRAStandardCapFloorlet fraCaplet = new FRAStandardCapFloorlet (
  586.             fra.name() + "::CAPLET",
  587.             fra,
  588.             strManifestMeasure,
  589.             true,
  590.             dblStrike,
  591.             1.,
  592.             new LastTradingDateSetting (
  593.                 LastTradingDateSetting.MID_CURVE_OPTION_QUARTERLY,
  594.                 "",
  595.                 Integer.MIN_VALUE
  596.             ),
  597.             new BlackScholesAlgorithm(),
  598.             null
  599.         );

  600.         Map<String, Double> mapFRACapletOutput = fraCaplet.value (
  601.             valParams,
  602.             null,
  603.             mktParams,
  604.             null
  605.         );

  606.         System.out.println ("\n------------------------------------------------------------------");

  607.         System.out.println ("------------------------------------------------------------------\n");

  608.         for (Map.Entry<String, Double> me : mapFRACapletOutput.entrySet())
  609.             System.out.println ("\t" + me.getKey() + " => " + me.getValue());

  610.         System.out.println ("\n------------------------------------------------------------------");

  611.         System.out.println ("------------------------------------------------------------------\n");

  612.         FRAStandardCapFloorlet fraFloorlet = new FRAStandardCapFloorlet (
  613.             fra.name() + "::FLOORLET",
  614.             fra,
  615.             strManifestMeasure,
  616.             false,
  617.             dblStrike,
  618.             1.,
  619.             new LastTradingDateSetting (
  620.                 LastTradingDateSetting.MID_CURVE_OPTION_QUARTERLY,
  621.                 "",
  622.                 Integer.MIN_VALUE
  623.             ),
  624.             new BlackScholesAlgorithm(),
  625.             null
  626.         );

  627.         Map<String, Double> mapFRAFloorletOutput = fraFloorlet.value (
  628.             valParams,
  629.             null,
  630.             mktParams,
  631.             null
  632.         );

  633.         for (Map.Entry<String, Double> me : mapFRAFloorletOutput.entrySet())
  634.             System.out.println ("\t" + me.getKey() + " => " + me.getValue());

  635.         System.out.println ("\n------------------------------------------------------------------");

  636.         System.out.println ("------------------------------------------------------------------\n");

  637.         System.out.println (
  638.             "\tPrice Implied FRA Caplet Vol       : " +
  639.             FormatUtil.FormatDouble (fraCaplet.implyVolatility (
  640.                 valParams,
  641.                 null,
  642.                 mktParams,
  643.                 null,
  644.                 "Price",
  645.                 mapFRACapletOutput.get ("Price")
  646.             ), 1, 2, 100.) + "%"
  647.         );

  648.         System.out.println (
  649.             "\tATM Price Implied FRA Caplet Vol   : " +
  650.             FormatUtil.FormatDouble (fraCaplet.implyVolatility (
  651.                 valParams,
  652.                 null,
  653.                 mktParams,
  654.                 null,
  655.                 "ATMPrice",
  656.                 mapFRACapletOutput.get ("ATMPrice")
  657.             ), 1, 2, 100.) + "%"
  658.         );

  659.         System.out.println (
  660.             "\tPrice Implied FRA Floorlet Vol     : " +
  661.             FormatUtil.FormatDouble (fraFloorlet.implyVolatility (
  662.                 valParams,
  663.                 null,
  664.                 mktParams,
  665.                 null,
  666.                 "Price",
  667.                 mapFRAFloorletOutput.get ("Price")
  668.             ), 1, 2, 100.) + "%"
  669.         );

  670.         System.out.println (
  671.             "\tATM Price Implied FRA Floorlet Vol : " +
  672.             FormatUtil.FormatDouble (fraFloorlet.implyVolatility (
  673.                 valParams,
  674.                 null,
  675.                 mktParams,
  676.                 null,
  677.                 "ATMPrice",
  678.                 mapFRAFloorletOutput.get ("ATMPrice")
  679.             ), 1, 2, 100.) + "%"
  680.         );

  681.         EnvManager.TerminateEnv();
  682.     }
  683. }