USDIRSAttribution.java

  1. package org.drip.sample.fixfloatpnl;

  2. import org.drip.feed.metric.FixFloatPnLAttributor;
  3. import org.drip.service.env.EnvManager;

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

  7. /*!
  8.  * Copyright (C) 2019 Lakshmi Krishnamurthy
  9.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2016 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>USDIRSAttribution</i> generates the Historical PnL Attribution for USD IRS.
  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/fixfloatpnl/README.md">Fix Float Swap Historical Series PnL</a></li>
  77.  *  </ul>
  78.  * <br><br>
  79.  *
  80.  * @author Lakshmi Krishnamurthy
  81.  */

  82. public class USDIRSAttribution {

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

  88.         String strCurrency = "USD";
  89.         String strClosesLocation = "C:\\DROP\\Daemons\\Transforms\\FundingStateMarks\\" + strCurrency + "ShapePreservingReconstitutor.csv";

  90.         String[] astrFundingDepositTenor = new String[] {
  91.             "1M",
  92.             "2M",
  93.             "3M",
  94.             "4M",
  95.             "5M",
  96.             "6M"
  97.         };

  98.         int[] aiFundingDepositColumn = new int[] {
  99.             1,
  100.             2,
  101.             3,
  102.             4,
  103.             5,
  104.             6
  105.         };

  106.         String[] astrFundingFixFloatTenor = new String[] {
  107.             "1Y",
  108.             "2Y",
  109.             "3Y",
  110.             "4Y",
  111.             "5Y",
  112.             "6Y",
  113.             "7Y",
  114.             "8Y",
  115.             "9Y",
  116.             "10Y",
  117.             "11Y",
  118.             "12Y",
  119.             "15Y",
  120.             "20Y",
  121.             "25Y",
  122.             "30Y",
  123.             "40Y",
  124.             "50Y"
  125.         };

  126.         int[] aiFundingFixFloatColumn = new int[] {
  127.              7,
  128.              8,
  129.              9,
  130.             10,
  131.             11,
  132.             12,
  133.             13,
  134.             14,
  135.             15,
  136.             16,
  137.             17,
  138.             18,
  139.             19,
  140.             20,
  141.             21,
  142.             22,
  143.             23,
  144.             24
  145.         };

  146.         String[] astrMaturityTenor = new String[] {
  147.             "1Y",
  148.             "2Y",
  149.             "3Y",
  150.             "4Y",
  151.             "5Y",
  152.             "6Y",
  153.             "7Y",
  154.             "8Y",
  155.             "9Y",
  156.             "10Y",
  157.             "11Y",
  158.             "12Y",
  159.             "15Y",
  160.             "20Y",
  161.             "25Y"
  162.         };

  163.         int[] aiHorizonGap = new int[] {
  164.             1,
  165.             // 22,
  166.             // 67
  167.         };

  168.         String[] astrRollDownHorizonMap = new String[] {
  169.             "1M",
  170.             "3M"
  171.         };

  172.         FixFloatPnLAttributor.TenorHorizonExplainComponents (
  173.             strCurrency,
  174.             astrMaturityTenor,
  175.             aiHorizonGap,
  176.             strClosesLocation,
  177.             astrFundingDepositTenor,
  178.             aiFundingDepositColumn,
  179.             astrFundingFixFloatTenor,
  180.             aiFundingFixFloatColumn,
  181.             astrRollDownHorizonMap
  182.         );

  183.         EnvManager.TerminateEnv();
  184.     }
  185. }