PathForwardRealization.java

  1. package org.drip.sample.govviemc;

  2. import org.drip.numerical.common.FormatUtil;
  3. import org.drip.service.env.EnvManager;
  4. import org.drip.state.sequence.PathRd;

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

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

  68. /**
  69.  * <i>PathForwardRealization</i> demonstrates the Simulations of the Per-Path Forward Govvie Yield Nodes.
  70.  *  
  71.  * <br><br>
  72.  *  <ul>
  73.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  74.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  75.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  76.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/govviemc/README.md">Govvie Curve Monte Carlo Runs</a></li>
  77.  *  </ul>
  78.  * <br><br>
  79.  *
  80.  * @author Lakshmi Krishnamurthy
  81.  */

  82. public class PathForwardRealization {

  83.     public static final void main (
  84.         final String[] astrArgs)
  85.         throws Exception
  86.     {
  87.         EnvManager.InitEnv ("");

  88.         double[] adblMean = new double[] {
  89.             0.011,
  90.             0.015,
  91.             0.017,
  92.             0.020,
  93.             0.023,
  94.             0.027,
  95.             0.040
  96.         };

  97.         int iNumPath = 50;
  98.         double dblLogNormalVolatility = 0.10;

  99.         PathRd pRd = new PathRd (
  100.             adblMean,
  101.             dblLogNormalVolatility,
  102.             true
  103.         );

  104.         double[][] aadblSequence = pRd.sequence (iNumPath);

  105.         String strDump = "\t||";
  106.         int iNumVertex = adblMean.length;

  107.         System.out.println();

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

  109.         for (int iVertex = 0; iVertex < iNumVertex; ++iVertex)
  110.             strDump = strDump + FormatUtil.FormatDouble (adblMean[iVertex], 1, 2, 100.) + "% |";

  111.         System.out.println (strDump + "|");

  112.         for (int iPath = 0; iPath < iNumPath; ++iPath) {
  113.             strDump = "\t||";

  114.             for (int iVertex = 0; iVertex < iNumVertex; ++iVertex)
  115.                 strDump = strDump + FormatUtil.FormatDouble (aadblSequence[iPath][iVertex], 1, 2, 100.) + "% |";

  116.             System.out.println (strDump + "|");
  117.         }

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

  119.         System.out.println();

  120.         EnvManager.TerminateEnv();
  121.     }
  122. }