DateRollAPI.java

  1. package org.drip.sample.date;

  2. import org.drip.analytics.date.*;
  3. import org.drip.analytics.daycount.Convention;
  4. import org.drip.service.env.EnvManager;

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

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

  84. /**
  85.  * <i>DateRollAPI</i> demonstrates Date Roll Functionality.
  86.  *  
  87.  * <br><br>
  88.  *  <ul>
  89.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  90.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  91.  *      <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>
  92.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/date/README.md">Calendar Date Roll Day Count</a></li>
  93.  *  </ul>
  94.  * <br><br>
  95.  *
  96.  * @author Lakshmi Krishnamurthy
  97.  */

  98. public class DateRollAPI {
  99.     public static final void main (
  100.         final String astrArgs[])
  101.         throws Exception
  102.     {
  103.         // String strConfig = "c:\\Lakshmi\\BondAnal\\Config.xml";

  104.         String strConfig = "";

  105.         EnvManager.InitEnv (strConfig);

  106.         JulianDate dt = DateUtil.CreateFromYMD (
  107.             2012,
  108.             DateUtil.FEBRUARY,
  109.             5
  110.         );

  111.         System.out.println ("\tDATE_ROLL_ACTUAL                      : " + dt + " -> " +
  112.             new JulianDate (
  113.                 Convention.RollDate (
  114.                     dt.julian(),
  115.                     Convention.DATE_ROLL_ACTUAL,
  116.                     "USD",
  117.                     1
  118.                 )
  119.             )
  120.         );

  121.         System.out.println ("\tDATE_ROLL_FOLLOWING                   : " + dt + " -> " +
  122.             new JulianDate (
  123.                 Convention.RollDate (
  124.                     dt.julian(),
  125.                     Convention.DATE_ROLL_FOLLOWING,
  126.                     "USD",
  127.                     1
  128.                 )
  129.             )
  130.         );

  131.         System.out.println ("\tDATE_ROLL_MODIFIED_FOLLOWING          : " + dt + " -> " +
  132.             new JulianDate (
  133.                 Convention.RollDate (
  134.                     dt.julian(),
  135.                     Convention.DATE_ROLL_MODIFIED_FOLLOWING,
  136.                     "USD",
  137.                     1
  138.                 )
  139.             )
  140.         );

  141.         System.out.println ("\tDATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY: " + dt + " -> " +
  142.             new JulianDate (
  143.                 Convention.RollDate (
  144.                     dt.julian(),
  145.                     Convention.DATE_ROLL_MODIFIED_FOLLOWING_BIMONTHLY,
  146.                     "USD",
  147.                     1
  148.                 )
  149.             )
  150.         );

  151.         System.out.println ("\tDATE_ROLL_PREVIOUS                    : " + dt + " -> " +
  152.             new JulianDate (
  153.                 Convention.RollDate (
  154.                     dt.julian(),
  155.                     Convention.DATE_ROLL_PREVIOUS,
  156.                     "USD",
  157.                     1
  158.                 )
  159.             )
  160.         );

  161.         System.out.println ("\tDATE_ROLL_MODIFIED_PREVIOUS           : " + dt + " -> " +
  162.             new JulianDate (
  163.                 Convention.RollDate (
  164.                     dt.julian(),
  165.                     Convention.DATE_ROLL_MODIFIED_PREVIOUS,
  166.                     "USD",
  167.                     1
  168.                 )
  169.             )
  170.         );

  171.         EnvManager.TerminateEnv();
  172.     }
  173. }