FedFundOvernightCompounding.java

  1. package org.drip.sample.fedfund;

  2. import java.util.*;

  3. import org.drip.analytics.cashflow.CompositePeriod;
  4. import org.drip.analytics.date.*;
  5. import org.drip.analytics.daycount.Convention;
  6. import org.drip.analytics.output.CompositePeriodCouponMetrics;
  7. import org.drip.analytics.support.*;
  8. import org.drip.function.r1tor1.*;
  9. import org.drip.market.definition.OvernightIndex;
  10. import org.drip.market.otc.*;
  11. import org.drip.param.creator.*;
  12. import org.drip.param.market.*;
  13. import org.drip.param.period.*;
  14. import org.drip.param.valuation.*;
  15. import org.drip.product.creator.*;
  16. import org.drip.product.definition.CalibratableComponent;
  17. import org.drip.product.rates.*;
  18. import org.drip.service.env.EnvManager;
  19. import org.drip.spline.basis.PolynomialFunctionSetParams;
  20. import org.drip.spline.params.*;
  21. import org.drip.spline.stretch.*;
  22. import org.drip.state.creator.*;
  23. import org.drip.state.discount.*;
  24. import org.drip.state.estimator.LatentStateStretchBuilder;
  25. import org.drip.state.identifier.*;
  26. import org.drip.state.inference.*;

  27. /*
  28.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  29.  */

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

  93. /**
  94.  * <i>FedFundOvernightCompounding</i> demonstrates in detail the methodology behind the overnight compounding
  95.  * used in the Overnight fund Floating Stream Accrual.
  96.  *  
  97.  * <br><br>
  98.  *  <ul>
  99.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  100.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  101.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  102.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/fedfund/README.md">Fed Fund Analytics</a></li>
  103.  *  </ul>
  104.  * <br><br>
  105.  *
  106.  * @author Lakshmi Krishnamurthy
  107.  */

  108. public class FedFundOvernightCompounding {

  109.     private static final FixFloatComponent OTCOISFixFloat (
  110.         final JulianDate dtSpot,
  111.         final String strCurrency,
  112.         final String strMaturityTenor,
  113.         final double dblCoupon)
  114.     {
  115.         FixedFloatSwapConvention ffConv = OvernightFixedFloatContainer.FundConventionFromJurisdiction (
  116.             strCurrency
  117.         );

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

  126.     /*
  127.      * Construct the Array of Deposit Instruments from the given set of parameters
  128.      *
  129.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  130.      */

  131.     private static final SingleStreamComponent[] DepositInstrumentsFromMaturityDays (
  132.         final JulianDate dtEffective,
  133.         final String strCurrency,
  134.         final int[] aiDay)
  135.         throws Exception
  136.     {
  137.         SingleStreamComponent[] aDeposit = new SingleStreamComponent[aiDay.length];

  138.         for (int i = 0; i < aiDay.length; ++i)
  139.             aDeposit[i] = SingleStreamComponentBuilder.Deposit (
  140.                 dtEffective,
  141.                 dtEffective.addBusDays (
  142.                     aiDay[i],
  143.                     strCurrency
  144.                 ),
  145.                 OvernightLabel.Create (
  146.                     strCurrency
  147.                 )
  148.             );

  149.         return aDeposit;
  150.     }

  151.     /*
  152.      * Construct the Array of Overnight Index Instruments from the given set of parameters
  153.      *
  154.      *      USE WITH CARE: This sample ignores errors and does not handle exceptions.
  155.      */

  156.     private static final FixFloatComponent[] OISFromMaturityTenor (
  157.         final JulianDate dtSpot,
  158.         final String strCurrency,
  159.         final String[] astrMaturityTenor,
  160.         final double[] adblCoupon)
  161.         throws Exception
  162.     {
  163.         FixFloatComponent[] aOIS = new FixFloatComponent[astrMaturityTenor.length];

  164.         for (int i = 0; i < astrMaturityTenor.length; ++i)
  165.             aOIS[i] = OTCOISFixFloat (
  166.                 dtSpot,
  167.                 strCurrency,
  168.                 astrMaturityTenor[i],
  169.                 adblCoupon[i]
  170.             );

  171.         return aOIS;
  172.     }

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

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

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

  194.         return aOISFutures;
  195.     }

  196.     private static final MergedDiscountForwardCurve CustomOISCurveBuilderSample (
  197.         final JulianDate dtSpot,
  198.         final String strCurrency)
  199.         throws Exception
  200.     {
  201.         /*
  202.          * Construct the Array of Deposit Instruments and their Quotes from the given set of parameters
  203.          */

  204.         SingleStreamComponent[] aDepositComp = DepositInstrumentsFromMaturityDays (
  205.             dtSpot,
  206.             strCurrency,
  207.             new int[] {
  208.                 1, 2, 3
  209.             }
  210.         );

  211.         double[] adblDepositQuote = new double[] {
  212.             0.0004, 0.0004, 0.0004       // Deposit
  213.         };

  214.         /*
  215.          * Construct the Deposit Instrument Set Stretch Builder
  216.          */

  217.         LatentStateStretchSpec depositStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  218.             "   DEPOSIT   ",
  219.             aDepositComp,
  220.             "ForwardRate",
  221.             adblDepositQuote
  222.         );

  223.         /*
  224.          * Construct the Array of Short End OIS Instruments and their Quotes from the given set of parameters
  225.          */

  226.         double[] adblShortEndOISQuote = new double[] {
  227.             0.00070,    //   1W
  228.             0.00069,    //   2W
  229.             0.00078,    //   3W
  230.             0.00074     //   1M
  231.         };

  232.         CalibratableComponent[] aShortEndOISComp = OISFromMaturityTenor (
  233.             dtSpot,
  234.             strCurrency,
  235.             new java.lang.String[] {
  236.                 "1W", "2W", "3W", "1M"
  237.             },
  238.             adblShortEndOISQuote
  239.         );

  240.         /*
  241.          * Construct the Short End OIS Instrument Set Stretch Builder
  242.          */

  243.         LatentStateStretchSpec oisShortEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  244.             "SHORT END OIS",
  245.             aShortEndOISComp,
  246.             "SwapRate",
  247.             adblShortEndOISQuote
  248.         );

  249.         /*
  250.          * Construct the Array of OIS Futures Instruments and their Quotes from the given set of parameters
  251.          */

  252.         double[] adblOISFutureQuote = new double[] {
  253.              0.00046,    //   1M x 1M
  254.              0.00016,    //   2M x 1M
  255.             -0.00007,    //   3M x 1M
  256.             -0.00013,    //   4M x 1M
  257.             -0.00014     //   5M x 1M
  258.         };

  259.         CalibratableComponent[] aOISFutureComp = OISFuturesFromMaturityTenor (
  260.             dtSpot,
  261.             strCurrency,
  262.             new java.lang.String[] {
  263.                 "1M", "2M", "3M", "4M", "5M"
  264.             },
  265.             new java.lang.String[] {
  266.                 "1M", "1M", "1M", "1M", "1M"
  267.             },
  268.             adblOISFutureQuote
  269.         );

  270.         /*
  271.          * Construct the OIS Future Instrument Set Stretch Builder
  272.          */

  273.         LatentStateStretchSpec oisFutureStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  274.             " OIS FUTURE  ",
  275.             aOISFutureComp,
  276.             "SwapRate",
  277.             adblOISFutureQuote
  278.         );

  279.         /*
  280.          * Construct the Array of Long End OIS Instruments and their Quotes from the given set of parameters
  281.          */

  282.         double[] adblLongEndOISQuote = new double[] {
  283.             0.00002,    //  15M
  284.             0.00008,    //  18M
  285.             0.00021,    //  21M
  286.             0.00036,    //   2Y
  287.             0.00127,    //   3Y
  288.             0.00274,    //   4Y
  289.             0.00456,    //   5Y
  290.             0.00647,    //   6Y
  291.             0.00827,    //   7Y
  292.             0.00996,    //   8Y
  293.             0.01147,    //   9Y
  294.             0.01280,    //  10Y
  295.             0.01404,    //  11Y
  296.             0.01516,    //  12Y
  297.             0.01764,    //  15Y
  298.             0.01939,    //  20Y
  299.             0.02003,    //  25Y
  300.             0.02038     //  30Y
  301.         };

  302.         CalibratableComponent[] aLongEndOISComp = OISFromMaturityTenor (
  303.             dtSpot,
  304.             strCurrency,
  305.             new java.lang.String[] {
  306.                 "15M", "18M", "21M", "2Y", "3Y", "4Y", "5Y", "6Y", "7Y", "8Y", "9Y", "10Y", "11Y", "12Y", "15Y", "20Y", "25Y", "30Y"
  307.             },
  308.             adblLongEndOISQuote
  309.         );

  310.         /*
  311.          * Construct the Long End OIS Instrument Set Stretch Builder
  312.          */

  313.         LatentStateStretchSpec oisLongEndStretch = LatentStateStretchBuilder.ForwardFundingStretchSpec (
  314.             "LONG END OIS ",
  315.             aLongEndOISComp,
  316.             "SwapRate",
  317.             adblLongEndOISQuote
  318.         );

  319.         LatentStateStretchSpec[] aStretchSpec = new LatentStateStretchSpec[] {
  320.             depositStretch,
  321.             oisShortEndStretch,
  322.             oisFutureStretch,
  323.             oisLongEndStretch
  324.         };

  325.         /*
  326.          * Set up the Linear Curve Calibrator using the following parameters:
  327.          *  - Cubic Exponential Mixture Basis Spline Set
  328.          *  - Ck = 2, Segment Curvature Penalty = 2
  329.          *  - Quadratic Rational Shape Controller
  330.          *  - Natural Boundary Setting
  331.          */

  332.         LinearLatentStateCalibrator lcc = new LinearLatentStateCalibrator (
  333.             new SegmentCustomBuilderControl (
  334.                 MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL,
  335.                 new PolynomialFunctionSetParams (4),
  336.                 SegmentInelasticDesignControl.Create (
  337.                     2,
  338.                     2
  339.                 ),
  340.                 new ResponseScalingShapeControl (
  341.                     true,
  342.                     new QuadraticRationalShapeControl (0.)
  343.                 ),
  344.                 null
  345.             ),
  346.             BoundarySettings.NaturalStandard(),
  347.             MultiSegmentSequence.CALIBRATE,
  348.             null,
  349.             null
  350.         );

  351.         /*
  352.          * Construct the Shape Preserving Discount Curve by applying the linear curve calibrator to the array
  353.          *  of Cash and Swap Stretches.
  354.          */

  355.         return ScenarioDiscountCurveBuilder.ShapePreservingDFBuild (
  356.             strCurrency,
  357.             lcc,
  358.             aStretchSpec,
  359.             new ValuationParams (
  360.                 dtSpot,
  361.                 dtSpot,
  362.                 strCurrency
  363.             ),
  364.             null,
  365.             null,
  366.             null,
  367.             1.
  368.         );
  369.     }

  370.     private static final LatentStateFixingsContainer SetFlatOvernightFixings (
  371.         final JulianDate dtStart,
  372.         final JulianDate dtEnd,
  373.         final JulianDate dtValue,
  374.         final ForwardLabel fri,
  375.         final double dblFlatFixing,
  376.         final double dblNotional)
  377.         throws Exception
  378.     {
  379.         LatentStateFixingsContainer lsfc = new LatentStateFixingsContainer();

  380.         double dblAccount = 1.;

  381.         lsfc.add (
  382.             dtStart,
  383.             fri,
  384.             dblFlatFixing
  385.         );

  386.         int iPrevDate = dtStart.julian();

  387.         JulianDate dt = dtStart.addDays (1);

  388.         while (dt.julian() <= dtEnd.julian()) {
  389.             lsfc.add (
  390.                 dt,
  391.                 fri,
  392.                 dblFlatFixing
  393.             );

  394.             if (dt.julian() <= dtValue.julian()) {
  395.                 double dblAccrualFraction = Convention.YearFraction (
  396.                     iPrevDate,
  397.                     dt.julian(),
  398.                     "Act/360",
  399.                     false,
  400.                     null,
  401.                     "USD"
  402.                 );

  403.                 dblAccount *= (1. + dblFlatFixing * dblAccrualFraction);
  404.             }

  405.             iPrevDate = dt.julian();

  406.             dt = dt.addBusDays (
  407.                 1,
  408.                 "USD"
  409.             );
  410.         }

  411.         System.out.println ("\tManual Calc Float Accrued (Geometric Compounding): " + (dblAccount - 1.) * dblNotional);

  412.         double dblDCF = (dtValue.julian() - dtStart.julian()) / 360.;

  413.         System.out.println ("\tManual Calc Float Accrued (Arithmetic Compounding): " +
  414.             (dblDCF * dblNotional * dblFlatFixing));

  415.         System.out.println ("\tManual Calc Float Accrued DCF (Arithmetic Compounding): " + dblDCF);

  416.         return lsfc;
  417.     }

  418.     public static final void main (
  419.         final String[] astrArgs)
  420.         throws Exception
  421.     {
  422.         /*
  423.          * Initialize the Credit Analytics Library
  424.          */

  425.         EnvManager.InitEnv ("");

  426.         String strCurrency = "USD";

  427.         JulianDate dtToday = DateUtil.CreateFromYMD (
  428.             2015,
  429.             DateUtil.JANUARY,
  430.             5
  431.         );

  432.         MergedDiscountForwardCurve dc = CustomOISCurveBuilderSample (
  433.             dtToday,
  434.             strCurrency
  435.         );

  436.         JulianDate dtCustomOISStart = dtToday.subtractTenor ("2M");

  437.         JulianDate dtCustomOISMaturity = dtToday.addTenor ("4M");

  438.         OvernightLabel fri = OvernightLabel.Create (
  439.             strCurrency
  440.         );

  441.         FundingLabel fundingLabel = FundingLabel.Standard (strCurrency);

  442.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  443.             360,
  444.             "Act/360",
  445.             false,
  446.             "Act/360",
  447.             false,
  448.             strCurrency,
  449.             false,
  450.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  451.         );

  452.         ComposableFloatingUnitSetting cfusFloatingArithmetic = new ComposableFloatingUnitSetting (
  453.             "ON",
  454.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_OVERNIGHT,
  455.             null,
  456.             OvernightLabel.Create (
  457.                 strCurrency
  458.             ),
  459.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  460.             0.
  461.         );

  462.         ComposableFloatingUnitSetting cfusFloatingGeometric = new ComposableFloatingUnitSetting (
  463.             "ON",
  464.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_OVERNIGHT,
  465.             null,
  466.             ForwardLabel.Create (
  467.                 new OvernightIndex (
  468.                     strCurrency + "FedFund",
  469.                     "FedFund",
  470.                     strCurrency,
  471.                     "Act/360",
  472.                     strCurrency,
  473.                     "ON",
  474.                     0,
  475.                     CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  476.                 ),
  477.                 "ON"
  478.             ),
  479.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  480.             0.
  481.         );

  482.         ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  483.             "6M",
  484.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  485.             null,
  486.             0.,
  487.             0.,
  488.             strCurrency
  489.         );

  490.         CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  491.             360,
  492.             "ON",
  493.             strCurrency,
  494.             null,
  495.             -1.,
  496.             null,
  497.             null,
  498.             null,
  499.             null
  500.         );

  501.         CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  502.             2,
  503.             "6M",
  504.             strCurrency,
  505.             null,
  506.             1.,
  507.             null,
  508.             null,
  509.             null,
  510.             null
  511.         );

  512.         List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  513.             dtCustomOISStart,
  514.             "6M",
  515.             "6M",
  516.             null
  517.         );

  518.         List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  519.             dtCustomOISStart,
  520.             "6M",
  521.             "6M",
  522.             null
  523.         );

  524.         Stream floatStreamGeometric = new Stream (
  525.             CompositePeriodBuilder.FloatingCompositeUnit (
  526.                 lsFloatingStreamEdgeDate,
  527.                 cpsFloating,
  528.                 cfusFloatingGeometric
  529.             )
  530.         );

  531.         List<CompositePeriod> lsArithmeticFloatPeriods = CompositePeriodBuilder.FloatingCompositeUnit (
  532.             lsFloatingStreamEdgeDate,
  533.             cpsFloating,
  534.             cfusFloatingArithmetic
  535.         );

  536.         Stream floatStreamArithmetic = new Stream (lsArithmeticFloatPeriods);

  537.         Stream fixStream = new Stream (
  538.             CompositePeriodBuilder.FixedCompositeUnit (
  539.                 lsFixedStreamEdgeDate,
  540.                 cpsFixed,
  541.                 ucasFixed,
  542.                 cfusFixed
  543.             )
  544.         );

  545.         FixFloatComponent oisArithmetic = new FixFloatComponent (
  546.             fixStream,
  547.             floatStreamArithmetic,
  548.             new CashSettleParams (
  549.                 0,
  550.                 strCurrency,
  551.                 0
  552.             )
  553.         );

  554.         FixFloatComponent oisGeometric = new FixFloatComponent (
  555.             fixStream,
  556.             floatStreamGeometric,
  557.             new CashSettleParams (
  558.                 0,
  559.                 strCurrency,
  560.                 0
  561.             )
  562.         );

  563.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  564.             dc,
  565.             null,
  566.             null,
  567.             null,
  568.             null,
  569.             null,
  570.             SetFlatOvernightFixings (
  571.                 dtCustomOISStart,
  572.                 dtCustomOISMaturity,
  573.                 dtToday,
  574.                 fri,
  575.                 0.003,
  576.                 -1.
  577.             )
  578.         );

  579.         ValuationParams valParams = new ValuationParams (
  580.             dtToday,
  581.             dtToday,
  582.             strCurrency
  583.         );

  584.         Map<String, Double> mapOISGeometricOutput = oisGeometric.value (
  585.             valParams,
  586.             null,
  587.             mktParams,
  588.             null
  589.         );

  590.         System.out.println ("\tMachine Calc Float Accrued (Geometric Compounding): " + mapOISGeometricOutput.get ("FloatAccrued"));

  591.         Map<String, Double> mapOISArithmeticOutput = oisArithmetic.value (
  592.             valParams,
  593.             null,
  594.             mktParams,
  595.             null
  596.         );

  597.         System.out.println ("\tMachine Calc Float Accrued (Arithmetic Compounding): " + mapOISArithmeticOutput.get ("FloatAccrued"));

  598.         System.out.println ("\tMachine Calc Float Accrued DCF (Arithmetic Compounding): " +
  599.             Math.abs (mapOISGeometricOutput.get ("FloatAccrued") / mapOISGeometricOutput.get ("ResetRate")));

  600.         CompositePeriod period = lsArithmeticFloatPeriods.get (0);

  601.         CompositePeriodCouponMetrics pcmArithmetic = floatStreamArithmetic.coupon (
  602.             period.endDate(),
  603.             valParams,
  604.             mktParams
  605.         );

  606.         System.out.println ("\tPeriod #1 Coupon Without Convexity Adjustment: " + pcmArithmetic.rate());

  607.         double dblOISVol = 0.3;
  608.         double dblUSDFundingVol = 0.3;
  609.         double dblUSDFundingUSDOISCorrelation = 0.3;

  610.         mktParams.setForwardVolatility (
  611.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  612.                 valParams.valueDate(),
  613.                 VolatilityLabel.Standard (fri),
  614.                 fri.currency(),
  615.                 dblOISVol
  616.             )
  617.         );

  618.         mktParams.setFundingVolatility (
  619.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  620.                 valParams.valueDate(),
  621.                 VolatilityLabel.Standard (fundingLabel),
  622.                 fri.currency(),
  623.                 dblUSDFundingVol
  624.             )
  625.         );

  626.         mktParams.setForwardFundingCorrelation (
  627.             fri,
  628.             fundingLabel,
  629.             new FlatUnivariate (dblUSDFundingUSDOISCorrelation)
  630.         );

  631.         System.out.println (
  632.             "\tPeriod #1 Coupon With Convexity Adjustment: " + floatStreamArithmetic.coupon (
  633.                 period.endDate(),
  634.                 valParams,
  635.                 mktParams
  636.             ).rate()
  637.         );

  638.         EnvManager.TerminateEnv();
  639.     }
  640. }