CreditSpreadEventDesign.java

  1. package org.drip.sample.systemicstress;

  2. import java.util.Map;

  3. import org.drip.capital.env.SystemicScenarioDesignContextManager;
  4. import org.drip.capital.systemicscenario.CreditSpreadEvent;
  5. import org.drip.capital.systemicscenario.Criterion;
  6. import org.drip.numerical.common.FormatUtil;
  7. import org.drip.numerical.common.NumberUtil;
  8. import org.drip.service.env.EnvManager;

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

  12. /*!
  13.  * Copyright (C) 2019 Quantitative Risk Analytics
  14.  */

  15. /**
  16.  * <i>CreditSpreadEventDesign</i> zeds the Built-in Credit Spread Events used for GSST Scenario Design. The
  17.  *  References are:
  18.  *
  19.  * <br><br>
  20.  *  <ul>
  21.  *      <li>
  22.  *          Bank for International Supervision(2005): Stress Testing at Major Financial Institutions: Survey
  23.  *              Results and Practice https://www.bis.org/publ/cgfs24.htm
  24.  *      </li>
  25.  *      <li>
  26.  *          Glasserman, P. (2004): <i>Monte Carlo Methods in Financial Engineering</i> <b>Springer</b>
  27.  *      </li>
  28.  *      <li>
  29.  *          Kupiec, P. H. (2000): Stress Tests and Risk Capital <i>Risk</i> <b>2 (4)</b> 27-39
  30.  *      </li>
  31.  *  </ul>
  32.  *
  33.  * @author Lakshmi Krishnamurthy
  34.  */

  35. public class CreditSpreadEventDesign
  36. {

  37.     private static final String CriterionValue (
  38.         final double value,
  39.         final int lefttOfDecimal,
  40.         final int rightOfDecimal)
  41.         throws Exception
  42.     {
  43.         return !NumberUtil.IsValid (value) ? " N/A" :
  44.             FormatUtil.FormatDouble (value, lefttOfDecimal, rightOfDecimal, 1.);
  45.     }

  46.     private static final void DisplayCriterion (
  47.         final Criterion criterion)
  48.         throws Exception
  49.     {
  50.         System.out.println (
  51.             "\t|            - " + criterion.name() + " => " + criterion.description()
  52.         );
  53.     }

  54.     public static final void main (
  55.         final String[] argumentArray)
  56.         throws Exception
  57.     {
  58.         EnvManager.InitEnv ("");

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

  60.         System.out.println ("\t|                 GSST SCENARIO DESIGN CREDIT SPREAD EVENTS                 |");

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

  62.         boolean headerPass = true;

  63.         for (Map.Entry<Integer, CreditSpreadEvent> creditSpreadEventMapEntry :
  64.             SystemicScenarioDesignContextManager.CreditSpreadEventContainer().creditSpreadEventMap().entrySet())
  65.         {
  66.             CreditSpreadEvent creditSpreadEvent = creditSpreadEventMapEntry.getValue();

  67.             if (headerPass)
  68.             {
  69.                 headerPass = false;

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

  71.                 System.out.println ("\t|            - Credit Spread Event Index");

  72.                 System.out.println ("\t|            - Credit Spread Event Scenario Name");

  73.                 DisplayCriterion (
  74.                     creditSpreadEvent.baaSpreadChange()
  75.                 );

  76.                 DisplayCriterion (
  77.                     creditSpreadEvent.snp500Return()
  78.                 );

  79.                 DisplayCriterion (
  80.                     creditSpreadEvent.ust5YChange()
  81.                 );

  82.                 DisplayCriterion (
  83.                     creditSpreadEvent.ust10YMinus3MChange()
  84.                 );

  85.                 DisplayCriterion (
  86.                     creditSpreadEvent.fxChange()
  87.                 );

  88.                 DisplayCriterion (
  89.                     creditSpreadEvent.wtiSpotReturn()
  90.                 );

  91.                 DisplayCriterion (
  92.                     creditSpreadEvent.snpGSCI()
  93.                 );

  94.                 System.out.println ("\t|---------------------------------------------------------------------------|");
  95.             }

  96.             System.out.println (
  97.                 "\t|" + FormatUtil.FormatDouble (creditSpreadEventMapEntry.getKey(), 2, 0, 1.) + " => " +
  98.                 creditSpreadEvent.scenario() + " | " +
  99.                 FormatUtil.FormatDouble (creditSpreadEvent.baaSpreadChange().value(), 3, 0, 1., false) + " | " +
  100.                 CriterionValue (creditSpreadEvent.snp500Return().value(), 3, 1) + "% | " +
  101.                 CriterionValue (creditSpreadEvent.ust5YChange().value(), 3, 0) + " | " +
  102.                 CriterionValue (creditSpreadEvent.ust10YMinus3MChange().value(), 3, 0) + " | " +
  103.                 CriterionValue (creditSpreadEvent.fxChange().value(), 1, 1) + "% | " +
  104.                 CriterionValue (creditSpreadEvent.wtiSpotReturn().value(), 3, 1) + "% | " +
  105.                 CriterionValue (creditSpreadEvent.snpGSCI().value(), 2, 1) + "%"
  106.             );
  107.         }

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

  109.         EnvManager.TerminateEnv();
  110.     }
  111. }