FloatFloatFloatFloatAnalysis.java

  1. package org.drip.sample.cross;

  2. import java.util.List;

  3. import org.drip.analytics.date.JulianDate;
  4. import org.drip.analytics.support.*;
  5. import org.drip.function.r1tor1.FlatUnivariate;
  6. import org.drip.numerical.common.FormatUtil;
  7. import org.drip.param.market.CurveSurfaceQuoteContainer;
  8. import org.drip.param.period.*;
  9. import org.drip.param.valuation.*;
  10. import org.drip.product.fx.ComponentPair;
  11. import org.drip.product.params.*;
  12. import org.drip.product.rates.*;
  13. import org.drip.service.env.EnvManager;
  14. import org.drip.state.creator.*;
  15. import org.drip.state.identifier.*;

  16. /*
  17.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  18.  */

  19. /*!
  20.  * Copyright (C) 2020 Lakshmi Krishnamurthy
  21.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  22.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  23.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  24.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  25.  * Copyright (C) 2015 Lakshmi Krishnamurthy
  26.  * Copyright (C) 2014 Lakshmi Krishnamurthy
  27.  *
  28.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  29.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  30.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  31.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  32.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  33.  *      and computational support.
  34.  *  
  35.  *      https://lakshmidrip.github.io/DROP/
  36.  *  
  37.  *  DROP is composed of three modules:
  38.  *  
  39.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  40.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  41.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  42.  *
  43.  *  DROP Product Core implements libraries for the following:
  44.  *  - Fixed Income Analytics
  45.  *  - Loan Analytics
  46.  *  - Transaction Cost Analytics
  47.  *
  48.  *  DROP Portfolio Core implements libraries for the following:
  49.  *  - Asset Allocation Analytics
  50.  *  - Asset Liability Management Analytics
  51.  *  - Capital Estimation Analytics
  52.  *  - Exposure Analytics
  53.  *  - Margin Analytics
  54.  *  - XVA Analytics
  55.  *
  56.  *  DROP Computational Core implements libraries for the following:
  57.  *  - Algorithm Support
  58.  *  - Computation Support
  59.  *  - Function Analysis
  60.  *  - Model Validation
  61.  *  - Numerical Analysis
  62.  *  - Numerical Optimizer
  63.  *  - Spline Builder
  64.  *  - Statistical Learning
  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>FloatFloatFloatFloatAnalysis</i> demonstrates the Funding Volatility, Forward Volatility, FX
  95.  * Volatility, Funding/Forward Correlation, Funding/FX Correlation, and Forward/FX Correlation of the Cross
  96.  * Currency Basis Swap built out of a pair of float-float swaps.
  97.  *  
  98.  * <br><br>
  99.  *  <ul>
  100.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  101.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  102.  *      <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>
  103.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/cross/README.md">Single/Dual Stream XCCY Component</a></li>
  104.  *  </ul>
  105.  * <br><br>
  106.  *
  107.  * @author Lakshmi Krishnamurthy
  108.  */

  109. public class FloatFloatFloatFloatAnalysis {

  110.     private static final FloatFloatComponent MakeFloatFloatSwap (
  111.         final JulianDate dtEffective,
  112.         final boolean bFXMTM,
  113.         final String strPayCurrency,
  114.         final String strCouponCurrency,
  115.         final String strMaturityTenor,
  116.         final int iTenorInMonthsReference,
  117.         final int iTenorInMonthsDerived)
  118.         throws Exception
  119.     {
  120.         ComposableFloatingUnitSetting cfusReference = new ComposableFloatingUnitSetting (
  121.             iTenorInMonthsReference + "M",
  122.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  123.             null,
  124.             ForwardLabel.Create (
  125.                 strCouponCurrency,
  126.                 iTenorInMonthsReference + "M"
  127.             ),
  128.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  129.             0.
  130.         );

  131.         ComposableFloatingUnitSetting cfusDerived = new ComposableFloatingUnitSetting (
  132.             iTenorInMonthsDerived + "M",
  133.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  134.             null,
  135.             ForwardLabel.Create (
  136.                 strCouponCurrency,
  137.                 iTenorInMonthsDerived + "M"
  138.             ),
  139.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  140.             0.
  141.         );

  142.         CompositePeriodSetting cpsReference = new CompositePeriodSetting (
  143.             12 / iTenorInMonthsReference,
  144.             iTenorInMonthsReference + "M",
  145.             strPayCurrency,
  146.             null,
  147.             -1.,
  148.             null,
  149.             null,
  150.             bFXMTM ? null : new FixingSetting (
  151.                 FixingSetting.FIXING_PRESET_STATIC,
  152.                 null,
  153.                 dtEffective.julian()
  154.             ),
  155.             null
  156.         );

  157.         CompositePeriodSetting cpsDerived = new CompositePeriodSetting (
  158.             12 / iTenorInMonthsDerived,
  159.             iTenorInMonthsDerived + "M",
  160.             strPayCurrency,
  161.             null,
  162.             1.,
  163.             null,
  164.             null,
  165.             bFXMTM ? null : new FixingSetting (
  166.                 FixingSetting.FIXING_PRESET_STATIC,
  167.                 null,
  168.                 dtEffective.julian()
  169.             ),
  170.             null
  171.         );

  172.         List<Integer> lsReferenceStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  173.             dtEffective,
  174.             iTenorInMonthsReference + "M",
  175.             strMaturityTenor,
  176.             null
  177.         );

  178.         List<Integer> lsDerivedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  179.             dtEffective,
  180.             iTenorInMonthsDerived + "M",
  181.             strMaturityTenor,
  182.             null
  183.         );

  184.         Stream referenceStream = new Stream (
  185.             CompositePeriodBuilder.FloatingCompositeUnit (
  186.                 lsReferenceStreamEdgeDate,
  187.                 cpsReference,
  188.                 cfusReference
  189.             )
  190.         );

  191.         Stream derivedStream = new Stream (
  192.             CompositePeriodBuilder.FloatingCompositeUnit (
  193.                 lsDerivedStreamEdgeDate,
  194.                 cpsDerived,
  195.                 cfusDerived
  196.             )
  197.         );

  198.         CashSettleParams csp = new CashSettleParams (
  199.             0,
  200.             strPayCurrency,
  201.             0
  202.         );

  203.         return new FloatFloatComponent (
  204.             referenceStream,
  205.             derivedStream,
  206.             csp
  207.         );
  208.     }

  209.     private static final void SetMarketParams (
  210.         final int iValueDate,
  211.         final CurveSurfaceQuoteContainer mktParams,
  212.         final ForwardLabel forwardReferenceLabel1,
  213.         final ForwardLabel forwardReferenceLabel2,
  214.         final ForwardLabel forwardDerivedLabel1,
  215.         final ForwardLabel forwardDerivedLabel2,
  216.         final FundingLabel fundingLabel,
  217.         final FXLabel fxLabel,
  218.         final double dblForwardReference1Vol,
  219.         final double dblForwardReference2Vol,
  220.         final double dblForwardDerived1Vol,
  221.         final double dblForwardDerived2Vol,
  222.         final double dblFundingVol,
  223.         final double dblFXVol,
  224.         final double dblForwardReference1FundingCorr,
  225.         final double dblForwardReference2FundingCorr,
  226.         final double dblForwardDerived1FundingCorr,
  227.         final double dblForwardDerived2FundingCorr,
  228.         final double dblForwardReference1FXCorr,
  229.         final double dblForwardReference2FXCorr,
  230.         final double dblForwardDerived1FXCorr,
  231.         final double dblForwardDerived2FXCorr,
  232.         final double dblFundingFXCorr)
  233.         throws Exception
  234.     {
  235.         mktParams.setForwardVolatility (
  236.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  237.                 iValueDate,
  238.                 VolatilityLabel.Standard (forwardReferenceLabel1),
  239.                 forwardReferenceLabel1.currency(),
  240.                 dblForwardReference1Vol
  241.             )
  242.         );

  243.         mktParams.setForwardVolatility (
  244.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  245.                 iValueDate,
  246.                 VolatilityLabel.Standard (forwardReferenceLabel2),
  247.                 forwardReferenceLabel2.currency(),
  248.                 dblForwardReference2Vol
  249.             )
  250.         );

  251.         mktParams.setForwardVolatility (
  252.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  253.                 iValueDate,
  254.                 VolatilityLabel.Standard (forwardDerivedLabel1),
  255.                 forwardDerivedLabel1.currency(),
  256.                 dblForwardDerived1Vol
  257.             )
  258.         );

  259.         mktParams.setForwardVolatility (
  260.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  261.                 iValueDate,
  262.                 VolatilityLabel.Standard (forwardDerivedLabel2),
  263.                 forwardDerivedLabel2.currency(),
  264.                 dblForwardDerived2Vol
  265.             )
  266.         );

  267.         mktParams.setFundingVolatility (
  268.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  269.                 iValueDate,
  270.                 VolatilityLabel.Standard (fundingLabel),
  271.                 forwardDerivedLabel1.currency(),
  272.                 dblFundingVol
  273.             )
  274.         );

  275.         mktParams.setFXVolatility (
  276.             ScenarioDeterministicVolatilityBuilder.FlatForward (
  277.                 iValueDate,
  278.                 VolatilityLabel.Standard (fxLabel),
  279.                 forwardDerivedLabel1.currency(),
  280.                 dblFXVol
  281.             )
  282.         );

  283.         mktParams.setForwardFundingCorrelation (
  284.             forwardReferenceLabel1,
  285.             fundingLabel,
  286.             new FlatUnivariate (dblForwardReference1FundingCorr)
  287.         );

  288.         mktParams.setForwardFundingCorrelation (
  289.             forwardReferenceLabel2,
  290.             fundingLabel,
  291.             new FlatUnivariate (dblForwardReference2FundingCorr)
  292.         );

  293.         mktParams.setForwardFundingCorrelation (
  294.             forwardDerivedLabel1,
  295.             fundingLabel,
  296.             new FlatUnivariate (dblForwardDerived1FundingCorr)
  297.         );

  298.         mktParams.setForwardFundingCorrelation (
  299.             forwardDerivedLabel2,
  300.             fundingLabel,
  301.             new FlatUnivariate (dblForwardDerived2FundingCorr)
  302.         );

  303.         mktParams.setForwardFXCorrelation (
  304.             forwardReferenceLabel1,
  305.             fxLabel,
  306.             new FlatUnivariate (dblForwardReference1FXCorr)
  307.         );

  308.         mktParams.setForwardFXCorrelation (
  309.             forwardReferenceLabel2,
  310.             fxLabel,
  311.             new FlatUnivariate (dblForwardReference2FXCorr)
  312.         );

  313.         mktParams.setForwardFXCorrelation (
  314.             forwardDerivedLabel1,
  315.             fxLabel,
  316.             new FlatUnivariate (dblForwardDerived1FXCorr)
  317.         );

  318.         mktParams.setForwardFXCorrelation (
  319.             forwardDerivedLabel2,
  320.             fxLabel,
  321.             new FlatUnivariate (dblForwardDerived2FXCorr)
  322.         );

  323.         mktParams.setFundingFXCorrelation (
  324.             fundingLabel,
  325.             fxLabel,
  326.             new FlatUnivariate (dblFundingFXCorr)
  327.         );
  328.     }

  329.     private static final void VolCorrScenario (
  330.         final ComponentPair[] aCP,
  331.         final ValuationParams valParams,
  332.         final CurveSurfaceQuoteContainer mktParams,
  333.         final ForwardLabel forwardReferenceLabel1,
  334.         final ForwardLabel forwardReferenceLabel2,
  335.         final ForwardLabel forwardDerivedLabel1,
  336.         final ForwardLabel forwardDerivedLabel2,
  337.         final FundingLabel fundingLabel,
  338.         final FXLabel fxLabel,
  339.         final double dblForwardReference1Vol,
  340.         final double dblForwardReference2Vol,
  341.         final double dblForwardDerived1Vol,
  342.         final double dblForwardDerived2Vol,
  343.         final double dblFundingVol,
  344.         final double dblFXVol,
  345.         final double dblForwardReference1FundingCorr,
  346.         final double dblForwardReference2FundingCorr,
  347.         final double dblForwardDerived1FundingCorr,
  348.         final double dblForwardDerived2FundingCorr,
  349.         final double dblForwardReference1FXCorr,
  350.         final double dblForwardReference2FXCorr,
  351.         final double dblForwardDerived1FXCorr,
  352.         final double dblForwardDerived2FXCorr,
  353.         final double dblFundingFXCorr)
  354.         throws Exception
  355.     {
  356.         SetMarketParams (
  357.             valParams.valueDate(),
  358.             mktParams,
  359.             forwardReferenceLabel1,
  360.             forwardReferenceLabel2,
  361.             forwardDerivedLabel1,
  362.             forwardDerivedLabel2,
  363.             fundingLabel,
  364.             fxLabel,
  365.             dblForwardReference1Vol,
  366.             dblForwardReference2Vol,
  367.             dblForwardDerived1Vol,
  368.             dblForwardDerived2Vol,
  369.             dblFundingVol,
  370.             dblFXVol,
  371.             dblForwardReference1FundingCorr,
  372.             dblForwardReference2FundingCorr,
  373.             dblForwardDerived1FundingCorr,
  374.             dblForwardDerived2FundingCorr,
  375.             dblForwardReference1FXCorr,
  376.             dblForwardReference2FXCorr,
  377.             dblForwardDerived1FXCorr,
  378.             dblForwardDerived2FXCorr,
  379.             dblFundingFXCorr
  380.         );

  381.         String strDump = "\t[" +
  382.             FormatUtil.FormatDouble (dblForwardReference1Vol, 2, 0, 100.) + "%," +
  383.             FormatUtil.FormatDouble (dblForwardReference2Vol, 2, 0, 100.) + "%," +
  384.             FormatUtil.FormatDouble (dblForwardDerived1Vol, 2, 0, 100.) + "%," +
  385.             FormatUtil.FormatDouble (dblForwardDerived2Vol, 2, 0, 100.) + "%," +
  386.             FormatUtil.FormatDouble (dblFundingVol, 2, 0, 100.) + "%," +
  387.             FormatUtil.FormatDouble (dblFXVol, 2, 0, 100.) + "%," +
  388.             FormatUtil.FormatDouble (dblForwardReference1FundingCorr, 2, 0, 100.) + "%," +
  389.             FormatUtil.FormatDouble (dblForwardReference2FundingCorr, 2, 0, 100.) + "%," +
  390.             FormatUtil.FormatDouble (dblForwardDerived1FundingCorr, 2, 0, 100.) + "%," +
  391.             FormatUtil.FormatDouble (dblForwardDerived2FundingCorr, 2, 0, 100.) + "%," +
  392.             FormatUtil.FormatDouble (dblForwardReference1FXCorr, 2, 0, 100.) + "%," +
  393.             FormatUtil.FormatDouble (dblForwardReference2FXCorr, 2, 0, 100.) + "%," +
  394.             FormatUtil.FormatDouble (dblForwardDerived1FXCorr, 2, 0, 100.) + "%," +
  395.             FormatUtil.FormatDouble (dblForwardDerived2FXCorr, 2, 0, 100.) + "%," +
  396.             FormatUtil.FormatDouble (dblFundingFXCorr, 2, 0, 100.) + "%] = ";

  397.         for (int i = 0; i < aCP.length; ++i) {
  398.             CaseInsensitiveTreeMap<Double> mapOutput = aCP[i].value (
  399.                 valParams,
  400.                 null,
  401.                 mktParams,
  402.                 null
  403.             );

  404.             if (0 != i) strDump += " || ";

  405.             strDump +=
  406.                 FormatUtil.FormatDouble (mapOutput.get ("ReferenceCumulativeConvexityAdjustmentPremium"), 2, 0, 10000.) + " | " +
  407.                 FormatUtil.FormatDouble (mapOutput.get ("DerivedCumulativeConvexityAdjustmentPremium"), 2, 0, 10000.) + " | " +
  408.                 FormatUtil.FormatDouble (mapOutput.get ("CumulativeConvexityAdjustmentPremium"), 2, 0, 10000.);
  409.         }

  410.         System.out.println (strDump);
  411.     }

  412.     public static final void main (
  413.         final String[] astrArgs)
  414.         throws Exception
  415.     {
  416.         String strReferenceCurrency = "USD";
  417.         String strDerivedCurrency = "EUR";

  418.         double dblReference3MForwardRate = 0.00750;
  419.         double dblReference6MForwardRate = 0.01000;
  420.         double dblDerived3MForwardRate = 0.00375;
  421.         double dblDerived6MForwardRate = 0.00625;
  422.         double dblReferenceFundingRate = 0.02;
  423.         double dblReferenceDerivedFXRate = 1. / 1.28;

  424.         /*
  425.          * Initialize the Credit Analytics Library
  426.          */

  427.         EnvManager.InitEnv ("");

  428.         JulianDate dtToday = org.drip.analytics.date.DateUtil.Today();

  429.         ValuationParams valParams = new ValuationParams (
  430.             dtToday,
  431.             dtToday,
  432.             "USD"
  433.         );

  434.         ForwardLabel fri3MReference = ForwardLabel.Create (
  435.             strReferenceCurrency,
  436.             "3M"
  437.         );

  438.         ForwardLabel fri6MReference = ForwardLabel.Create (
  439.             strReferenceCurrency,
  440.             "6M"
  441.         );

  442.         ForwardLabel fri3MDerived = ForwardLabel.Create (
  443.             strDerivedCurrency,
  444.             "3M"
  445.         );

  446.         ForwardLabel fri6MDerived = ForwardLabel.Create (
  447.             strDerivedCurrency,
  448.             "6M"
  449.         );

  450.         FundingLabel fundingLabelReference = FundingLabel.Standard (strReferenceCurrency);

  451.         CurrencyPair cp = CurrencyPair.FromCode (strReferenceCurrency + "/" + strDerivedCurrency);

  452.         FXLabel fxLabel = FXLabel.Standard (cp);

  453.         FloatFloatComponent floatFloatReference = MakeFloatFloatSwap (
  454.             dtToday,
  455.             false,
  456.             strReferenceCurrency,
  457.             strReferenceCurrency,
  458.             "2Y",
  459.             6,
  460.             3
  461.         );

  462.         floatFloatReference.setPrimaryCode (
  463.             "FLOAT::FLOAT::" + strReferenceCurrency + "::" + strReferenceCurrency + "_3M::" + strReferenceCurrency + "_6M::2Y"
  464.         );

  465.         FloatFloatComponent floatFloatDerivedMTM = MakeFloatFloatSwap (
  466.             dtToday,
  467.             true,
  468.             strReferenceCurrency,
  469.             strDerivedCurrency,
  470.             "2Y",
  471.             6,
  472.             3
  473.         );

  474.         floatFloatDerivedMTM.setPrimaryCode (
  475.             "FLOAT::FLOAT::MTM::" + strReferenceCurrency + "::" + strDerivedCurrency + "_3M::" + strDerivedCurrency + "_6M::2Y"
  476.         );

  477.         ComponentPair cpMTM = new ComponentPair (
  478.             "FFFF_MTM",
  479.             floatFloatReference,
  480.             floatFloatDerivedMTM,
  481.             null
  482.         );

  483.         FloatFloatComponent floatFloatDerivedNonMTM = MakeFloatFloatSwap (
  484.             dtToday,
  485.             false,
  486.             strReferenceCurrency,
  487.             strDerivedCurrency,
  488.             "2Y",
  489.             6,
  490.             3
  491.         );

  492.         floatFloatDerivedNonMTM.setPrimaryCode (
  493.             "FLOAT::FLOAT::NONMTM::" + strReferenceCurrency + "::" + strDerivedCurrency + "_3M::" + strDerivedCurrency + "_6M::2Y"
  494.         );

  495.         ComponentPair cpNonMTM = new ComponentPair (
  496.             "FFFF_NonMTM",
  497.             floatFloatReference,
  498.             floatFloatDerivedNonMTM,
  499.             null
  500.         );

  501.         CurveSurfaceQuoteContainer mktParams = new CurveSurfaceQuoteContainer();

  502.         mktParams.setFixing (
  503.             dtToday,
  504.             fxLabel,
  505.             dblReferenceDerivedFXRate
  506.         );

  507.         mktParams.setForwardState (
  508.             ScenarioForwardCurveBuilder.FlatForwardForwardCurve (
  509.                 dtToday,
  510.                 fri3MReference,
  511.                 dblReference3MForwardRate
  512.             )
  513.         );

  514.         mktParams.setForwardState (
  515.             ScenarioForwardCurveBuilder.FlatForwardForwardCurve (
  516.                 dtToday,
  517.                 fri6MReference,
  518.                 dblReference6MForwardRate
  519.             )
  520.         );

  521.         mktParams.setForwardState (
  522.             ScenarioForwardCurveBuilder.FlatForwardForwardCurve (
  523.                 dtToday,
  524.                 fri3MDerived,
  525.                 dblDerived3MForwardRate
  526.             )
  527.         );

  528.         mktParams.setForwardState (
  529.             ScenarioForwardCurveBuilder.FlatForwardForwardCurve (
  530.                 dtToday,
  531.                 fri6MDerived,
  532.                 dblDerived6MForwardRate
  533.             )
  534.         );

  535.         mktParams.setFundingState (
  536.             ScenarioDiscountCurveBuilder.ExponentiallyCompoundedFlatRate (
  537.                 dtToday,
  538.                 strReferenceCurrency,
  539.                 dblReferenceFundingRate
  540.             )
  541.         );

  542.         mktParams.setFXState (
  543.             ScenarioFXCurveBuilder.CubicPolynomialCurve (
  544.                 fxLabel.fullyQualifiedName(),
  545.                 dtToday,
  546.                 cp,
  547.                 new String[] {"10Y"},
  548.                 new double[] {dblReferenceDerivedFXRate},
  549.                 dblReferenceDerivedFXRate
  550.             )
  551.         );

  552.         double[] adblReference3MForwardVol = new double[] {
  553.             0.1, 0.4
  554.         };
  555.         double[] adblReference6MForwardVol = new double[] {
  556.             0.1, 0.4
  557.         };
  558.         double[] adblDerived3MForwardVol = new double[] {
  559.             0.1, 0.4
  560.         };
  561.         double[] adblDerived6MForwardVol = new double[] {
  562.             0.1, 0.4
  563.         };
  564.         double[] adblReferenceFundingVol = new double[] {
  565.             0.1, 0.4
  566.         };
  567.         double[] adblReferenceDerivedFXVol = new double[] {
  568.             0.1, 0.4
  569.         };

  570.         double[] adblReference3MForwardFundingCorr = new double[] {
  571.             -0.1, 0.2
  572.         };
  573.         double[] adblReference6MForwardFundingCorr = new double[] {
  574.             -0.1, 0.2
  575.         };
  576.         double[] adblDerived3MForwardFundingCorr = new double[] {
  577.             -0.1, 0.2
  578.         };
  579.         double[] adblDerived6MForwardFundingCorr = new double[] {
  580.             -0.1, 0.2
  581.         };

  582.         double[] adblReference3MForwardFXCorr = new double[] {
  583.             -0.1, 0.2
  584.         };
  585.         double[] adblReference6MForwardFXCorr = new double[] {
  586.             -0.1, 0.2
  587.         };
  588.         double[] adblDerived3MForwardFXCorr = new double[] {
  589.             -0.1, 0.2
  590.         };
  591.         double[] adblDerived6MForwardFXCorr = new double[] {
  592.             -0.1, 0.2
  593.         };

  594.         double[] adblFundingFXCorr = new double[] {
  595.             -0.1, 0.2
  596.         };

  597.         for (double dblReference3MForwardVol : adblReference3MForwardVol) {
  598.             for (double dblReference6MForwardVol : adblReference6MForwardVol) {
  599.                 for (double dblDerived3MForwardVol : adblDerived3MForwardVol) {
  600.                     for (double dblDerived6MForwardVol : adblDerived6MForwardVol) {
  601.                         for (double dblReferenceFundingVol : adblReferenceFundingVol) {
  602.                             for (double dblReferenceDerivedFXVol : adblReferenceDerivedFXVol) {
  603.                                 for (double dblReference3MForwardFundingCorr : adblReference3MForwardFundingCorr) {
  604.                                     for (double dblReference6MForwardFundingCorr : adblReference6MForwardFundingCorr) {
  605.                                         for (double dblDerived3MForwardFundingCorr : adblDerived3MForwardFundingCorr) {
  606.                                             for (double dblDerived6MForwardFundingCorr : adblDerived6MForwardFundingCorr) {
  607.                                                 for (double dblReference3MForwardFXCorr : adblReference3MForwardFXCorr) {
  608.                                                     for (double dblReference6MForwardFXCorr : adblReference6MForwardFXCorr) {
  609.                                                         for (double dblDerived3MForwardFXCorr : adblDerived3MForwardFXCorr) {
  610.                                                             for (double dblDerived6MForwardFXCorr : adblDerived6MForwardFXCorr) {
  611.                                                                 for (double dblFundingFXCorr : adblFundingFXCorr)
  612.                                                                     VolCorrScenario (
  613.                                                                         new ComponentPair[] {
  614.                                                                             cpMTM,
  615.                                                                             cpNonMTM
  616.                                                                         },
  617.                                                                         valParams,
  618.                                                                         mktParams,
  619.                                                                         fri3MReference,
  620.                                                                         fri6MReference,
  621.                                                                         fri3MDerived,
  622.                                                                         fri6MDerived,
  623.                                                                         fundingLabelReference,
  624.                                                                         fxLabel,
  625.                                                                         dblReference3MForwardVol,
  626.                                                                         dblReference6MForwardVol,
  627.                                                                         dblDerived3MForwardVol,
  628.                                                                         dblDerived6MForwardVol,
  629.                                                                         dblReferenceFundingVol,
  630.                                                                         dblReferenceDerivedFXVol,
  631.                                                                         dblReference3MForwardFundingCorr,
  632.                                                                         dblReference6MForwardFundingCorr,
  633.                                                                         dblDerived3MForwardFundingCorr,
  634.                                                                         dblDerived6MForwardFundingCorr,
  635.                                                                         dblReference3MForwardFXCorr,
  636.                                                                         dblReference6MForwardFXCorr,
  637.                                                                         dblDerived3MForwardFXCorr,
  638.                                                                         dblDerived6MForwardFXCorr,
  639.                                                                         dblFundingFXCorr
  640.                                                                     );
  641.                                                             }
  642.                                                         }
  643.                                                     }
  644.                                                 }
  645.                                             }
  646.                                         }
  647.                                     }
  648.                                 }
  649.                             }
  650.                         }
  651.                     }
  652.                 }
  653.             }
  654.         }

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