FixFloatInArrearsPeriods.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.*;
  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>FixFloatInArrearsPeriods</i> demonstrates the Cash Flow Period Details for an In-Arrears Fix-Float
  93.  * 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 FixFloatInArrearsPeriods {

  107.     private static final FixFloatComponent SwapInstrumentsFromMaturityTenor (
  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.RegularEdgeDates (
  170.             dtEffective,
  171.             "6M",
  172.             strMaturityTenor,
  173.             null
  174.         );

  175.         List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  176.             dtEffective,
  177.             "6M",
  178.             strMaturityTenor,
  179.             null
  180.         );

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

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

  196.         FixFloatComponent irs = new FixFloatComponent (
  197.             fixedStream,
  198.             floatingStream,
  199.             csp
  200.         );

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

  202.         return irs;
  203.     }

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

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

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

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

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

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

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

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

  285.         String strCurrency = "USD";

  286.         FixFloatComponent ffcInArrears = SwapInstrumentsFromMaturityTenor (
  287.             dtSpot,
  288.             strCurrency,
  289.             "8Y"
  290.         );

  291.         System.out.println();

  292.         MergedDiscountForwardCurve mdfc = FundingCurve (
  293.             dtSpot,
  294.             strCurrency,
  295.             0.
  296.         );

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  324.         for (CompositePeriod p : ffcInArrears.referenceStream().cashFlowPeriod()) {
  325.             int iEndDate = p.endDate();

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

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

  343.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

  357.         for (CompositePeriod p : ffcInArrears.referenceStream().cashFlowPeriod()) {
  358.             int iEndDate = p.endDate();

  359.             int iStartDate = p.startDate();

  360.             double dblCouponRate = p.couponMetrics (
  361.                 iEndDate,
  362.                 csqc
  363.             ).rate();

  364.             double dblCouponDCF = p.couponDCF();

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

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

  377.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  399.         for (CompositePeriod p : ffcInArrears.derivedStream().cashFlowPeriod()) {
  400.             int iEndDate = p.endDate();

  401.             CompositeFloatingPeriod cfp = (CompositeFloatingPeriod) p;

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

  403.             ReferenceIndexPeriod rip = cufp.referenceIndexPeriod();

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

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

  424.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  439.         for (CompositePeriod p : ffcInArrears.derivedStream().cashFlowPeriod()) {
  440.             int iEndDate = p.endDate();

  441.             int iStartDate = p.startDate();

  442.             double dblCouponRate = p.couponMetrics (
  443.                 iEndDate,
  444.                 csqc
  445.             ).rate();

  446.             double dblCouponDCF = p.couponDCF();

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

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

  460.         System.out.println();

  461.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  477.         for (CompositePeriod p : ffcInArrears.couponPeriods()) {
  478.             ConvexityAdjustment ca = p.terminalConvexityAdjustment (
  479.                 dtSpot.julian(),
  480.                 csqc
  481.             );

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

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

  498.         System.out.println();

  499.         EnvManager.TerminateEnv();
  500.     }
  501. }