ConservativeTimeline.java

  1. package org.drip.sample.csaevents;

  2. import org.drip.analytics.date.DateUtil;
  3. import org.drip.analytics.date.JulianDate;
  4. import org.drip.exposure.csatimeline.EventDate;
  5. import org.drip.exposure.csatimeline.EventSequence;
  6. import org.drip.service.env.EnvManager;

  7. /*
  8.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  9.  */

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

  80. /**
  81.  * <i>ConservativeTimeline</i> describes CSA mandated Events Time-line occurring Margin Period, as enforced
  82.  * by a "Conservative" Dealer. The References are:
  83.  *  
  84.  * <br><br>
  85.  *  <ul>
  86.  *      <li>
  87.  *          Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Re-thinking Margin Period of Risk
  88.  *              https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2902737 <b>eSSRN</b>
  89.  *      </li>
  90.  *      <li>
  91.  *          Andersen, L. B. G., M. Pykhtin, and A. Sokol (2017): Credit Exposure in the Presence of Initial
  92.  *              Margin https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2806156 <b>eSSRN</b>
  93.  *      </li>
  94.  *      <li>
  95.  *          Anfuso, F., D. Aziz, P. Giltinan, and K Loukopoulus (2017): A Sound Modeling and Back-testing
  96.  *              Framework for Forecasting Initial Margin Requirements
  97.  *              https://papers.ssrn.com/sol3/papers.cfm?abstract_id=2716279 <b>eSSRN</b>
  98.  *      </li>
  99.  *      <li>
  100.  *          BCBS (2015): Margin Requirements for Non-centrally Cleared Derivatives
  101.  *              https://www.bis.org/bcbs/publ/d317.pdf
  102.  *      </li>
  103.  *      <li>
  104.  *          Pykhtin, M. (2009): Modeling Credit Exposure for Collateralized Counter-parties <i>Journal of
  105.  *              Credit Risk</i> <b>5 (4)</b> 3-27
  106.  *      </li>
  107.  *  </ul>
  108.  *  
  109.  * <br><br>
  110.  *  <ul>
  111.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  112.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ExposureAnalyticsLibrary.md">Exposure Analytics</a></li>
  113.  *      <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>
  114.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/csaevents/README.md">Time-line of IMA/CSA Event Sequences</a></li>
  115.  *  </ul>
  116.  * <br><br>
  117.  *
  118.  * @author Lakshmi Krishnamurthy
  119.  */

  120. public class ConservativeTimeline
  121. {

  122.     private static final void DumpCSAEvent (
  123.         final EventDate csaEventDate)
  124.         throws Exception
  125.     {
  126.         System.out.println (
  127.             "\t| " +
  128.             csaEventDate.date() + " => " +
  129.             csaEventDate.aps2017Designation() + " | " +
  130.             csaEventDate.bcbsDesignation()
  131.         );
  132.     }

  133.     public static final void main (
  134.         final String args[])
  135.         throws Exception
  136.     {
  137.         EnvManager.InitEnv ("");

  138.         JulianDate valuationDate = DateUtil.CreateFromYMD (
  139.             2018,
  140.             DateUtil.APRIL,
  141.             16
  142.         );

  143.         String calendar = "USD";

  144.         EventSequence csaTimeline = EventSequence.Conservative (
  145.             valuationDate,
  146.             calendar
  147.         );

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

  149.         System.out.println ("\t|              CSA IMA 2002 \"Conservative\" Timeline               |");

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

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

  152.         System.out.println ("\t|                                                                 |");

  153.         System.out.println ("\t|      - CSA Event Date                                           |");

  154.         System.out.println ("\t|      - Andersen-Pykhtin-Sokol (2017) CSA Event Designation      |");

  155.         System.out.println ("\t|      - BCBS-IOSCO-IMA CSA Event Designation                     |");

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

  157.         DumpCSAEvent (csaTimeline.valuation());

  158.         DumpCSAEvent (csaTimeline.honored());

  159.         DumpCSAEvent (csaTimeline.collateralTransferInitiation());

  160.         DumpCSAEvent (csaTimeline.nonHonored());

  161.         DumpCSAEvent (csaTimeline.ped());

  162.         DumpCSAEvent (csaTimeline.pedCommunication());

  163.         DumpCSAEvent (csaTimeline.ed());

  164.         DumpCSAEvent (csaTimeline.edCommunication());

  165.         DumpCSAEvent (csaTimeline.etdDesignation());

  166.         DumpCSAEvent (csaTimeline.etd());

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

  168.         System.out.println();

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

  170.         System.out.println ("\t| Margin Period Start => " + csaTimeline.marginPeriodStart());

  171.         System.out.println ("\t| Margin Period End   => " + csaTimeline.marginPeriodEnd());

  172.         System.out.println ("\t| Margin Duration     => " + csaTimeline.marginDuration() + " Calendar Days");

  173.         System.out.println ("\t| Margin Frequency    => " + csaTimeline.marginFrequency() + " Business Days");

  174.         System.out.println ("\t| PED Cure Period     => " + csaTimeline.curePeriod() + " Business Days");

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

  176.         EnvManager.TerminateEnv();
  177.     }
  178. }