EnvManager.java

  1. package org.drip.service.env;

  2. /*
  3.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  4.  */

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

  82. /**
  83.  * <i>EnvManager</i> sets the environment/connection parameters, and populates the market parameters for the
  84.  * given EOD.
  85.  *
  86.  * <br><br>
  87.  *  <ul>
  88.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  89.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationSupportLibrary.md">Computation Support</a></li>
  90.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/README.md">Environment, Product/Definition Containers, and Scenario/State Manipulation APIs</a></li>
  91.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/service/env/README.md">Library Module Loader Environment Manager</a></li>
  92.  *  </ul>
  93.  * <br><br>
  94.  *
  95.  * @author Lakshmi Krishnamurthy
  96.  */

  97. public class EnvManager {
  98.     private static boolean s_bInvocationCapture = false;

  99.     /**
  100.      * Initialize the logger, the database connections, the day count parameters, and day count objects.
  101.      *
  102.      * @param strConfig String representing the full path of the configuration file
  103.      * @param bInvocationCapture TRUE - Run the Invocation Capture
  104.      *
  105.      * @return SQL Statement representing the initialized object.
  106.      */

  107.     public static final java.sql.Statement InitEnv (
  108.         final java.lang.String strConfig,
  109.         final boolean bInvocationCapture)
  110.     {
  111.         if (s_bInvocationCapture = bInvocationCapture)
  112.         {
  113.             if (!org.drip.service.env.InvocationManager.Init())
  114.             {
  115.                 System.out.println ("EnvManager::InitEnv => Cannot Initialize Invocation Manager!");

  116.                 return null;
  117.             }
  118.         }

  119.         if (!org.drip.analytics.support.Logger.Init (strConfig)) {
  120.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Logger Manager!");

  121.             return null;
  122.         }

  123.         if (!org.drip.service.env.CacheManager.Init()) {
  124.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Cache Manager!");

  125.             return null;
  126.         }

  127.         if (!org.drip.analytics.daycount.Convention.Init (strConfig)) {
  128.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Day Count Conventions!");

  129.             return null;
  130.         }

  131.         if (!org.drip.service.env.StandardCDXManager.InitStandardCDXSeries()) {
  132.             System.out.println ("EnvManager::InitEnv => Cannot Initialize standard CDX Indexes!");

  133.             return null;
  134.         }

  135.         if (!org.drip.market.definition.OvernightIndexContainer.Init()) {
  136.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Overnight Indexes!");

  137.             return null;
  138.         }

  139.         if (!org.drip.market.definition.IBORIndexContainer.Init()) {
  140.             System.out.println ("EnvManager::InitEnv => Cannot Initialize IBOR Indexes!");

  141.             return null;
  142.         }

  143.         if (!org.drip.market.exchange.ShortTermFuturesContainer.Init()) {
  144.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Short Term Futures!");

  145.             return null;
  146.         }

  147.         if (!org.drip.market.exchange.FuturesOptionsContainer.Init()) {
  148.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Short Term Futures Options!");

  149.             return null;
  150.         }

  151.         if (!org.drip.market.otc.IBORFixedFloatContainer.Init()) {
  152.             System.out.println
  153.                 ("EnvManager::InitEnv => Cannot Initialize IBOR Fix-Float Convention Settings!");

  154.             return null;
  155.         }

  156.         if (!org.drip.market.otc.IBORFloatFloatContainer.Init()) {
  157.             System.out.println
  158.                 ("EnvManager::InitEnv => Cannot Initialize IBOR Float-Float Convention Settings!");

  159.             return null;
  160.         }

  161.         if (!org.drip.market.otc.OvernightFixedFloatContainer.Init()) {
  162.             System.out.println
  163.                 ("EnvManager::InitEnv => Cannot Initialize Overnight Fix-Float Convention Settings!");

  164.             return null;
  165.         }

  166.         if (!org.drip.market.exchange.DeliverableSwapFuturesContainer.Init()) {
  167.             System.out.println ("EnvManager::InitEnv => Cannot Initialize Deliverable Swap Futures Settings!");

  168.             return null;
  169.         }

  170.         if (!org.drip.market.otc.CrossFloatConventionContainer.Init()) {
  171.             System.out.println
  172.                 ("EnvManager::InitEnv => Cannot Initialize Cross-Currency Float-Float Convention Settings!");

  173.             return null;
  174.         }

  175.         if (!org.drip.market.otc.SwapOptionSettlementContainer.Init()) {
  176.             System.out.println
  177.                 ("EnvManager::InitEnv => Cannot Initialize the Swap Option Settlement Conventions!");

  178.             return null;
  179.         }

  180.         if (!org.drip.market.otc.CreditIndexConventionContainer.Init()) {
  181.             System.out.println ("EnvManager::InitEnv => Cannot Initialize the Credit Index Conventions!");

  182.             return null;
  183.         }

  184.         if (!org.drip.market.exchange.TreasuryFuturesConventionContainer.Init()) {
  185.             System.out.println
  186.                 ("EnvManager::InitEnv => Cannot Initialize the Bond Futures Convention Conventions!");

  187.             return null;
  188.         }

  189.         if (!org.drip.market.exchange.TreasuryFuturesOptionContainer.Init()) {
  190.             System.out.println
  191.                 ("EnvManager::InitEnv => Cannot Initialize the Bond Futures Option Conventions!");

  192.             return null;
  193.         }

  194.         if (!org.drip.market.definition.FXSettingContainer.Init()) {
  195.             System.out.println ("EnvManager::InitEnv => Cannot Initialize the FX Conventions!");

  196.             return null;
  197.         }

  198.         if (!org.drip.market.issue.TreasurySettingContainer.Init()) {
  199.             System.out.println ("EnvManager::InitEnv => Cannot Initialize the Treasury Settings!");

  200.             return null;
  201.         }

  202.         if (!org.drip.market.exchange.TreasuryFuturesContractContainer.Init()) {
  203.             System.out.println ("EnvManager::InitEnv => Cannot Initialize the Treasury Futures Contract!");

  204.             return null;
  205.         }

  206.         if (!org.drip.simm.common.ISDASettingsContainer.Init()) {
  207.             System.out.println ("EnvManager::InitEnv => Cannot Initialize ISDA SIMM 2.0 Specifications!");

  208.             return null;
  209.         }

  210.         if (!org.drip.capital.env.CapitalEstimationContextManager.Init())
  211.         {
  212.             System.out.println
  213.                 ("EnvManager::InitEnv => Cannot Initialize Capital Estimation Context Manager!");

  214.             return null;
  215.         }

  216.         if (!org.drip.capital.env.SystemicScenarioDesignContextManager.Init())
  217.         {
  218.             System.out.println ("EnvManager::InitEnv => Cannot Initialize GSST Design Context Manager!");

  219.             return null;
  220.         }

  221.         if (!org.drip.capital.env.SystemicScenarioDefinitionContextManager.Init())
  222.         {
  223.             System.out.println
  224.                 ("EnvManager::InitEnv => Cannot Initialize GSST Definition Context Manager!");

  225.             return null;
  226.         }

  227.         if (s_bInvocationCapture)
  228.         {
  229.             if (!org.drip.service.env.InvocationManager.Setup())
  230.             {
  231.                 System.out.println ("EnvManager::InitEnv => Cannot Setup Invocation Manager!");

  232.                 return null;
  233.             }
  234.         }

  235.         return org.drip.param.config.ConfigLoader.OracleInit (strConfig);
  236.     }

  237.     /**
  238.      * Initialize the Environment Setup
  239.      *
  240.      * @param strConfig String representing the full path of the configuration file
  241.      *
  242.      * @return SQL Statement representing the initialized object.
  243.      */

  244.     public static final java.sql.Statement InitEnv (
  245.         final java.lang.String strConfig)
  246.     {
  247.         return InitEnv (
  248.             strConfig,
  249.             true
  250.         );
  251.     }

  252.     /**
  253.      * Terminate the Environment Frame Context
  254.      *
  255.      * @return The Environment Frame Context is Terminated
  256.      */

  257.     public static final boolean TerminateEnv()
  258.     {
  259.         return s_bInvocationCapture ? org.drip.service.env.InvocationManager.Terminate() : true;
  260.     }
  261. }