FixFloatInArrearsIMMPeriods.java

  1. package org.drip.sample.cashflow;

  2. import java.util.List;

  3. import org.drip.analytics.cashflow.*;
  4. import org.drip.analytics.date.*;
  5. import org.drip.analytics.output.ConvexityAdjustment;
  6. import org.drip.analytics.support.CompositePeriodBuilder;
  7. import org.drip.numerical.common.FormatUtil;
  8. import org.drip.param.creator.MarketParamsBuilder;
  9. import org.drip.param.market.CurveSurfaceQuoteContainer;
  10. import org.drip.param.period.*;
  11. import org.drip.param.valuation.CashSettleParams;
  12. import org.drip.product.rates.*;
  13. import org.drip.service.env.EnvManager;
  14. import org.drip.service.template.LatentMarketStateBuilder;
  15. import org.drip.state.discount.MergedDiscountForwardCurve;
  16. import org.drip.state.identifier.ForwardLabel;

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

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

  91. /**
  92.  * <i>FixFloatInArrearsIMMPeriods</i> demonstrates the Cash Flow Period Details for an In-Arrears Fix-Float
  93.  * IMM Swap.
  94.  *  
  95.  * <br><br>
  96.  *  <ul>
  97.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  98.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  99.  *      <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>
  100.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/cashflow/README.md">Fixed Income Product Cash Flow Display</a></li>
  101.  *  </ul>
  102.  * <br><br>
  103.  *
  104.  * @author Lakshmi Krishnamurthy
  105.  */

  106. public class FixFloatInArrearsIMMPeriods {

  107.     private static final FixFloatComponent FixFloatInArrears (
  108.         final JulianDate dtEffective,
  109.         final String strCurrency,
  110.         final String strMaturityTenor)
  111.         throws Exception
  112.     {
  113.         UnitCouponAccrualSetting ucasFixed = new UnitCouponAccrualSetting (
  114.             2,
  115.             "Act/360",
  116.             false,
  117.             "Act/360",
  118.             false,
  119.             strCurrency,
  120.             true,
  121.             CompositePeriodBuilder.ACCRUAL_COMPOUNDING_RULE_GEOMETRIC
  122.         );

  123.         ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  124.             "6M",
  125.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  126.             null,
  127.             ForwardLabel.Create (
  128.                 strCurrency,
  129.                 "6M"
  130.             ),
  131.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ARREARS,
  132.             0.
  133.         );

  134.         ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  135.             "6M",
  136.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  137.             null,
  138.             0.,
  139.             0.,
  140.             strCurrency
  141.         );

  142.         CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  143.             2,
  144.             "6M",
  145.             strCurrency,
  146.             null,
  147.             -1.,
  148.             null,
  149.             null,
  150.             null,
  151.             null
  152.         );

  153.         CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  154.             2,
  155.             "6M",
  156.             strCurrency,
  157.             null,
  158.             1.,
  159.             null,
  160.             null,
  161.             null,
  162.             null
  163.         );

  164.         CashSettleParams csp = new CashSettleParams (
  165.             0,
  166.             strCurrency,
  167.             0
  168.         );

  169.         List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.IMMEdgeDates (
  170.             dtEffective,
  171.             3,
  172.             "6M",
  173.             strMaturityTenor,
  174.             null
  175.         );

  176.         List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.IMMEdgeDates (
  177.             dtEffective,
  178.             3,
  179.             "6M",
  180.             strMaturityTenor,
  181.             null
  182.         );

  183.         Stream floatingStream = new Stream (
  184.             CompositePeriodBuilder.FloatingCompositeUnit (
  185.                 lsFloatingStreamEdgeDate,
  186.                 cpsFloating,
  187.                 cfusFloating
  188.             )
  189.         );

  190.         Stream fixedStream = new Stream (
  191.             CompositePeriodBuilder.FixedCompositeUnit (
  192.                 lsFixedStreamEdgeDate,
  193.                 cpsFixed,
  194.                 ucasFixed,
  195.                 cfusFixed
  196.             )
  197.         );

  198.         FixFloatComponent irs = new FixFloatComponent (
  199.             fixedStream,
  200.             floatingStream,
  201.             csp
  202.         );

  203.         irs.setPrimaryCode ("IRS." + strMaturityTenor + "." + strCurrency);

  204.         return irs;
  205.     }

  206.     private static final MergedDiscountForwardCurve FundingCurve (
  207.         final JulianDate dtSpot,
  208.         final String strCurrency,
  209.         final double dblBump)
  210.         throws Exception
  211.     {
  212.         String[] astrDepositMaturityTenor = new String[] {
  213.             "2D"
  214.         };

  215.         double[] adblDepositQuote = new double[] {
  216.             0.0111956 + dblBump // 2D
  217.         };

  218.         double[] adblFuturesQuote = new double[] {
  219.             0.011375 + dblBump, // 98.8625
  220.             0.013350 + dblBump, // 98.6650
  221.             0.014800 + dblBump, // 98.5200
  222.             0.016450 + dblBump, // 98.3550
  223.             0.017850 + dblBump, // 98.2150
  224.             0.019300 + dblBump  // 98.0700
  225.         };

  226.         String[] astrFixFloatMaturityTenor = new String[] {
  227.             "02Y",
  228.             "03Y",
  229.             "04Y",
  230.             "05Y",
  231.             "06Y",
  232.             "07Y",
  233.             "08Y",
  234.             "09Y",
  235.             "10Y",
  236.             "11Y",
  237.             "12Y",
  238.             "15Y",
  239.             "20Y",
  240.             "25Y",
  241.             "30Y",
  242.             "40Y",
  243.             "50Y"
  244.         };

  245.         double[] adblFixFloatQuote = new double[] {
  246.             0.017029 + dblBump, //  2Y
  247.             0.019354 + dblBump, //  3Y
  248.             0.021044 + dblBump, //  4Y
  249.             0.022291 + dblBump, //  5Y
  250.             0.023240 + dblBump, //  6Y
  251.             0.024025 + dblBump, //  7Y
  252.             0.024683 + dblBump, //  8Y
  253.             0.025243 + dblBump, //  9Y
  254.             0.025720 + dblBump, // 10Y
  255.             0.026130 + dblBump, // 11Y
  256.             0.026495 + dblBump, // 12Y
  257.             0.027230 + dblBump, // 15Y
  258.             0.027855 + dblBump, // 20Y
  259.             0.028025 + dblBump, // 25Y
  260.             0.028028 + dblBump, // 30Y
  261.             0.027902 + dblBump, // 40Y
  262.             0.027655 + dblBump  // 50Y
  263.         };

  264.         return LatentMarketStateBuilder.SmoothFundingCurve (
  265.             dtSpot,
  266.             strCurrency,
  267.             astrDepositMaturityTenor,
  268.             adblDepositQuote,
  269.             "ForwardRate",
  270.             adblFuturesQuote,
  271.             "ForwardRate",
  272.             astrFixFloatMaturityTenor,
  273.             adblFixFloatQuote,
  274.             "SwapRate"
  275.         );
  276.     }

  277.     public static final void main (
  278.         final String[] astrArgs)
  279.         throws Exception
  280.     {
  281.         EnvManager.InitEnv ("");

  282.         JulianDate dtSpot = DateUtil.CreateFromYMD (
  283.             2017,
  284.             DateUtil.MARCH,
  285.             10
  286.         );

  287.         String strCurrency = "USD";

  288.         FixFloatComponent ffcInArrearsIMM = FixFloatInArrears (
  289.             dtSpot,
  290.             strCurrency,
  291.             "8Y"
  292.         );

  293.         System.out.println();

  294.         MergedDiscountForwardCurve mdfc = FundingCurve (
  295.             dtSpot,
  296.             strCurrency,
  297.             0.
  298.         );

  299.         CurveSurfaceQuoteContainer csqc = MarketParamsBuilder.Create (
  300.             mdfc,
  301.             null,
  302.             null,
  303.             null,
  304.             null,
  305.             null,
  306.             null
  307.         );

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

  309.         System.out.println ("\t||                                         FIXED PERIOD DATES AND FACTORS                                            ||");

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

  311.         System.out.println ("\t||   L -> R:                                                                                                         ||");

  312.         System.out.println ("\t||           - Period Start Date                                                                                     ||");

  313.         System.out.println ("\t||           - Period End Date                                                                                       ||");

  314.         System.out.println ("\t||           - Period Pay Date                                                                                       ||");

  315.         System.out.println ("\t||           - Period FX Fixing Date                                                                                 ||");

  316.         System.out.println ("\t||           - Period Is FX MTM?                                                                                     ||");

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

  318.         System.out.println ("\t||           - Period Coupon Frequency                                                                               ||");

  319.         System.out.println ("\t||           - Period Pay Currency                                                                                   ||");

  320.         System.out.println ("\t||           - Period Coupon Currency                                                                                ||");

  321.         System.out.println ("\t||           - Period Basis                                                                                          ||");

  322.         System.out.println ("\t||           - Period Base Notional                                                                                  ||");

  323.         System.out.println ("\t||           - Period Notional                                                                                       ||");

  324.         System.out.println ("\t||           - Period Coupon Factor                                                                                  ||");

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

  326.         for (CompositePeriod p : ffcInArrearsIMM.referenceStream().cashFlowPeriod()) {
  327.             int iEndDate = p.endDate();

  328.             System.out.println ("\t|| " +
  329.                 DateUtil.YYYYMMDD (p.startDate()) + " => " +
  330.                 DateUtil.YYYYMMDD (iEndDate) + " | " +
  331.                 DateUtil.YYYYMMDD (p.payDate()) + " | " +
  332.                 DateUtil.YYYYMMDD (p.fxFixingDate()) + " | " +
  333.                 p.isFXMTM() + " | " +
  334.                 p.tenor() + " | " +
  335.                 p.freq() + " | " +
  336.                 p.payCurrency() + " | " +
  337.                 p.couponCurrency() + " | " +
  338.                 FormatUtil.FormatDouble (p.basis(), 1, 0, 10000.) + " | " +
  339.                 FormatUtil.FormatDouble (p.baseNotional(), 1, 4, 1.) + " | " +
  340.                 FormatUtil.FormatDouble (p.notional (iEndDate), 1, 4, 1.) + " | " +
  341.                 FormatUtil.FormatDouble (p.couponFactor (iEndDate), 1, 4, 1.) + " ||"
  342.             );
  343.         }

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

  345.         System.out.println();

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

  347.         System.out.println ("\t||                     FIXED PERIOD LABELS AND CURVE FACTORS                       ||");

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

  349.         System.out.println ("\t||   L -> R:                                                                       ||");

  350.         System.out.println ("\t||           - Period Start Date                                                   ||");

  351.         System.out.println ("\t||           - Period End Date                                                     ||");

  352.         System.out.println ("\t||           - Period Funding Label                                                ||");

  353.         System.out.println ("\t||           - Period Coupon Rate (%)                                              ||");

  354.         System.out.println ("\t||           - Period Coupon Year Fraction                                         ||");

  355.         System.out.println ("\t||           - Period Coupon Amount                                                ||");

  356.         System.out.println ("\t||           - Period Principal Amount                                             ||");

  357.         System.out.println ("\t||           - Period Discount Factor                                              ||");

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

  359.         for (CompositePeriod p : ffcInArrearsIMM.referenceStream().cashFlowPeriod()) {
  360.             int iEndDate = p.endDate();

  361.             int iStartDate = p.startDate();

  362.             double dblCouponRate = p.couponMetrics (
  363.                 iEndDate,
  364.                 csqc
  365.             ).rate();

  366.             double dblCouponDCF = p.couponDCF();

  367.             System.out.println ("\t|| " +
  368.                 DateUtil.YYYYMMDD (iStartDate) + " => " +
  369.                 DateUtil.YYYYMMDD (iEndDate) + " | " +
  370.                 p.fundingLabel().fullyQualifiedName() + " | " +
  371.                 FormatUtil.FormatDouble (dblCouponRate, 1, 2, 100.) + "% | " +
  372.                 FormatUtil.FormatDouble (dblCouponDCF, 1, 4, 1.) + " | " +
  373.                 FormatUtil.FormatDouble (dblCouponRate * dblCouponDCF * p.notional (iEndDate) * p.couponFactor (iEndDate), 1, 4, 1.) + " | " +
  374.                 FormatUtil.FormatDouble (p.notional (iStartDate) - p.notional (iEndDate), 1, 4, 1.) + " | " +
  375.                 FormatUtil.FormatDouble (p.df (csqc), 1, 4, 1.) + " ||"
  376.             );
  377.         }

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

  379.         System.out.println();

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

  381.         System.out.println ("\t||                                                           FLOATING PERIOD DATES AND FACTORS                                                              ||");

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

  383.         System.out.println ("\t||   L -> R:                                                                                                                                                ||");

  384.         System.out.println ("\t||           - Period Start Date                                                                                                                            ||");

  385.         System.out.println ("\t||           - Period End Date                                                                                                                              ||");

  386.         System.out.println ("\t||           - Reference Index Start Date                                                                                                                   ||");

  387.         System.out.println ("\t||           - Reference Index End Date                                                                                                                     ||");

  388.         System.out.println ("\t||           - Reference Index Fixing Date                                                                                                                  ||");

  389.         System.out.println ("\t||           - Period Pay Date                                                                                                                              ||");

  390.         System.out.println ("\t||           - Period FX Fixing Date                                                                                                                        ||");

  391.         System.out.println ("\t||           - Period Is FX MTM?                                                                                                                            ||");

  392.         System.out.println ("\t||           - Period Tenor                                                                                                                                 ||");

  393.         System.out.println ("\t||           - Period Coupon Frequency                                                                                                                      ||");

  394.         System.out.println ("\t||           - Period Pay Currency                                                                                                                          ||");

  395.         System.out.println ("\t||           - Period Coupon Currency                                                                                                                       ||");

  396.         System.out.println ("\t||           - Period Basis                                                                                                                                 ||");

  397.         System.out.println ("\t||           - Period Base Notional                                                                                                                         ||");

  398.         System.out.println ("\t||           - Period Notional                                                                                                                              ||");

  399.         System.out.println ("\t||           - Period Coupon Factor                                                                                                                         ||");

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

  401.         for (CompositePeriod p : ffcInArrearsIMM.derivedStream().cashFlowPeriod()) {
  402.             int iEndDate = p.endDate();

  403.             CompositeFloatingPeriod cfp = (CompositeFloatingPeriod) p;

  404.             ComposableUnitFloatingPeriod cufp = (ComposableUnitFloatingPeriod) cfp.periods().get(0);

  405.             ReferenceIndexPeriod rip = cufp.referenceIndexPeriod();

  406.             System.out.println ("\t|| " +
  407.                 DateUtil.YYYYMMDD (p.startDate()) + " => " +
  408.                 DateUtil.YYYYMMDD (iEndDate) + " | " +
  409.                 DateUtil.YYYYMMDD (rip.startDate()) + " | " +
  410.                 DateUtil.YYYYMMDD (rip.endDate()) + " | " +
  411.                 DateUtil.YYYYMMDD (rip.fixingDate()) + " | " +
  412.                 DateUtil.YYYYMMDD (p.payDate()) + " | " +
  413.                 DateUtil.YYYYMMDD (p.fxFixingDate()) + " | " +
  414.                 p.isFXMTM() + " | " +
  415.                 p.tenor() + " | " +
  416.                 p.freq() + " | " +
  417.                 p.payCurrency() + " | " +
  418.                 p.couponCurrency() + " | " +
  419.                 FormatUtil.FormatDouble (p.basis(), 1, 0, 10000.) + " | " +
  420.                 FormatUtil.FormatDouble (p.baseNotional(), 1, 4, 1.) + " | " +
  421.                 FormatUtil.FormatDouble (p.notional (iEndDate), 1, 4, 1.) + " | " +
  422.                 FormatUtil.FormatDouble (p.couponFactor (iEndDate), 1, 4, 1.) + " ||"
  423.             );
  424.         }

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

  426.         System.out.println();

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

  428.         System.out.println ("\t||                            FLOATING PERIOD LABELS AND CURVE FACTORS                            ||");

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

  430.         System.out.println ("\t||   L -> R:                                                                                      ||");

  431.         System.out.println ("\t||           - Period Start Date                                                                  ||");

  432.         System.out.println ("\t||           - Period End Date                                                                    ||");

  433.         System.out.println ("\t||           - Period Funding Label                                                               ||");

  434.         System.out.println ("\t||           - Period Forward Label                                                               ||");

  435.         System.out.println ("\t||           - Period Coupon Rate (%)                                                             ||");

  436.         System.out.println ("\t||           - Period Coupon Year Fraction                                                        ||");

  437.         System.out.println ("\t||           - Period Coupon Amount                                                               ||");

  438.         System.out.println ("\t||           - Period Principal Amount                                                            ||");

  439.         System.out.println ("\t||           - Period Discount Factor                                                             ||");

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

  441.         for (CompositePeriod p : ffcInArrearsIMM.derivedStream().cashFlowPeriod()) {
  442.             int iEndDate = p.endDate();

  443.             int iStartDate = p.startDate();

  444.             double dblCouponRate = p.couponMetrics (
  445.                 iEndDate,
  446.                 csqc
  447.             ).rate();

  448.             double dblCouponDCF = p.couponDCF();

  449.             System.out.println ("\t|| " +
  450.                 DateUtil.YYYYMMDD (iStartDate) + " => " +
  451.                 DateUtil.YYYYMMDD (iEndDate) + " | " +
  452.                 p.fundingLabel().fullyQualifiedName() + " | " +
  453.                 p.floaterLabel().fullyQualifiedName() + " | " +
  454.                 FormatUtil.FormatDouble (dblCouponRate, 1, 2, 100.) + "% | " +
  455.                 FormatUtil.FormatDouble (dblCouponDCF, 1, 4, 1.) + " | " +
  456.                 FormatUtil.FormatDouble (dblCouponRate * dblCouponDCF * p.notional (iEndDate) * p.couponFactor (iEndDate), 1, 4, 1.) + " | " +
  457.                 FormatUtil.FormatDouble (p.notional (iStartDate) - p.notional (iEndDate), 1, 4, 1.) + " | " +
  458.                 FormatUtil.FormatDouble (p.df (csqc), 1, 4, 1.) + " ||"
  459.             );
  460.         }

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

  462.         System.out.println();

  463.         System.out.println();

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

  465.         System.out.println ("\t||                                       CASH FLOW PERIODS CONVEXITY CORRECTION                                       ||");

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

  467.         System.out.println ("\t||    L -> R:                                                                                                         ||");

  468.         System.out.println ("\t||            - Collateral Credit Adjustment                                                                          ||");

  469.         System.out.println ("\t||            - Collateral Forward Adjustment                                                                         ||");

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

  471.         System.out.println ("\t||            - Collateral FX Adjustment                                                                              ||");

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

  473.         System.out.println ("\t||            - Credit Funding Adjustment                                                                             ||");

  474.         System.out.println ("\t||            - Credit FX Adjustment                                                                                  ||");

  475.         System.out.println ("\t||            - Forward Funding Adjustment                                                                            ||");

  476.         System.out.println ("\t||            - Forward FX Adjustment                                                                                 ||");

  477.         System.out.println ("\t||            - Funding FX Adjustment                                                                                 ||");

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

  479.         for (CompositePeriod p : ffcInArrearsIMM.couponPeriods()) {
  480.             ConvexityAdjustment ca = p.terminalConvexityAdjustment (
  481.                 dtSpot.julian(),
  482.                 csqc
  483.             );

  484.             System.out.println ("\t|| " +
  485.                 DateUtil.YYYYMMDD (p.startDate()) + " => " +
  486.                 DateUtil.YYYYMMDD (p.endDate()) + " | " +
  487.                 FormatUtil.FormatDouble (ca.collateralCredit(), 1, 3, 1.) + " | " +
  488.                 FormatUtil.FormatDouble (ca.collateralForward(), 1, 3, 1.) + " | " +
  489.                 FormatUtil.FormatDouble (ca.collateralFunding(), 1, 3, 1.) + " | " +
  490.                 FormatUtil.FormatDouble (ca.collateralFX(), 1, 3, 1.) + " | " +
  491.                 FormatUtil.FormatDouble (ca.creditForward(), 1, 3, 1.) + " | " +
  492.                 FormatUtil.FormatDouble (ca.creditFunding(), 1, 3, 1.) + " | " +
  493.                 FormatUtil.FormatDouble (ca.creditFX(), 1, 3, 1.) + " | " +
  494.                 FormatUtil.FormatDouble (ca.forwardFunding(), 1, 3, 1.) + " | " +
  495.                 FormatUtil.FormatDouble (ca.forwardFX(), 1, 3, 1.) + " | " +
  496.                 FormatUtil.FormatDouble (ca.fundingFX(), 1, 3, 1.) + " ||"
  497.             );
  498.         }

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

  500.         System.out.println();

  501.         EnvManager.TerminateEnv();
  502.     }
  503. }