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

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

  125.         ComposableFloatingUnitSetting cfusFloating = new ComposableFloatingUnitSetting (
  126.             strCompositeTenor,
  127.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  128.             null,
  129.             ForwardLabel.Create (
  130.                 strCurrency,
  131.                 strFloatingTenor
  132.             ),
  133.             CompositePeriodBuilder.REFERENCE_PERIOD_IN_ADVANCE,
  134.             0.
  135.         );

  136.         ComposableFixedUnitSetting cfusFixed = new ComposableFixedUnitSetting (
  137.             strCompositeTenor,
  138.             CompositePeriodBuilder.EDGE_DATE_SEQUENCE_REGULAR,
  139.             null,
  140.             0.,
  141.             0.,
  142.             strCurrency
  143.         );

  144.         CompositePeriodSetting cpsFloating = new CompositePeriodSetting (
  145.             Helper.TenorToFreq (strCompositeTenor),
  146.             strCompositeTenor,
  147.             strCurrency,
  148.             null,
  149.             -1.,
  150.             null,
  151.             null,
  152.             null,
  153.             null
  154.         );

  155.         CompositePeriodSetting cpsFixed = new CompositePeriodSetting (
  156.             Helper.TenorToFreq (strCompositeTenor),
  157.             strCompositeTenor,
  158.             strCurrency,
  159.             null,
  160.             1.,
  161.             null,
  162.             null,
  163.             null,
  164.             null
  165.         );

  166.         CashSettleParams csp = new CashSettleParams (
  167.             0,
  168.             strCurrency,
  169.             0
  170.         );

  171.         List<Integer> lsFixedStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  172.             dtEffective,
  173.             strCompositeTenor,
  174.             strMaturityTenor,
  175.             null
  176.         );

  177.         List<Integer> lsFloatingStreamEdgeDate = CompositePeriodBuilder.RegularEdgeDates (
  178.             dtEffective,
  179.             strCompositeTenor,
  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 ffcInAdvanceShortTenor = InAdvanceShortTenor (
  289.             dtSpot,
  290.             strCurrency,
  291.             "8Y",
  292.             "12M",
  293.             "3M"
  294.         );

  295.         System.out.println();

  296.         MergedDiscountForwardCurve mdfc = FundingCurve (
  297.             dtSpot,
  298.             strCurrency,
  299.             0.
  300.         );

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  328.         for (CompositePeriod p : ffcInAdvanceShortTenor.referenceStream().cashFlowPeriod()) {
  329.             int iEndDate = p.endDate();

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

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

  347.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

  361.         for (CompositePeriod p : ffcInAdvanceShortTenor.referenceStream().cashFlowPeriod()) {
  362.             int iEndDate = p.endDate();

  363.             int iStartDate = p.startDate();

  364.             double dblCouponRate = p.couponMetrics (
  365.                 iEndDate,
  366.                 csqc
  367.             ).rate();

  368.             double dblCouponDCF = p.couponDCF();

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

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

  381.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  403.         for (CompositePeriod p : ffcInAdvanceShortTenor.derivedStream().cashFlowPeriod()) {
  404.             int iEndDate = p.endDate();

  405.             CompositeFloatingPeriod cfp = (CompositeFloatingPeriod) p;

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

  407.             ReferenceIndexPeriod rip = cufp.referenceIndexPeriod();

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

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

  428.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  443.         for (CompositePeriod p : ffcInAdvanceShortTenor.derivedStream().cashFlowPeriod()) {
  444.             int iEndDate = p.endDate();

  445.             int iStartDate = p.startDate();

  446.             double dblCouponRate = p.couponMetrics (
  447.                 iEndDate,
  448.                 csqc
  449.             ).rate();

  450.             double dblCouponDCF = p.couponDCF();

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

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

  464.         System.out.println();

  465.         System.out.println();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

  481.         for (CompositePeriod p : ffcInAdvanceShortTenor.couponPeriods()) {
  482.             ConvexityAdjustment ca = p.terminalConvexityAdjustment (
  483.                 dtSpot.julian(),
  484.                 csqc
  485.             );

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

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

  502.         System.out.println();

  503.         EnvManager.TerminateEnv();
  504.     }
  505. }