DIFutures.java

  1. package org.drip.sample.forwardratefutures;

  2. import java.util.Map;

  3. import org.drip.analytics.date.*;
  4. import org.drip.param.creator.MarketParamsBuilder;
  5. import org.drip.param.market.CurveSurfaceQuoteContainer;
  6. import org.drip.param.valuation.ValuationParams;
  7. import org.drip.product.creator.SingleStreamComponentBuilder;
  8. import org.drip.product.rates.SingleStreamComponent;
  9. import org.drip.sample.forward.OvernightIndexCurve;
  10. import org.drip.service.env.EnvManager;
  11. import org.drip.state.discount.MergedDiscountForwardCurve;
  12. import org.drip.state.identifier.OvernightLabel;

  13. /*
  14.  * -*- mode: java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
  15.  */

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

  79. /**
  80.  * <i>DIFutures</i> contains the demonstration of the construction and the Valuation of the DI Futures
  81.  * Contract.
  82.  *  
  83.  * <br><br>
  84.  *  <ul>
  85.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/AnalyticsCore.md">Analytics Core Module</a></li>
  86.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics Library</a></li>
  87.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/README.md">Sample</a></li>
  88.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/sample/forwardratefutures/README.md">Forward Rate Futures Analytics</a></li>
  89.  *  </ul>
  90.  * <br><br>
  91.  *
  92.  * @author Lakshmi Krishnamurthy
  93.  */

  94. public class DIFutures {
  95.     public static final void main (
  96.         final String[] astrArgs)
  97.         throws Exception
  98.     {
  99.         /*
  100.          * Initialize the Credit Analytics Library
  101.          */

  102.         EnvManager.InitEnv ("");

  103.         String strCurrency = "BRL";

  104.         JulianDate dtToday = DateUtil.Today().addBusDays (
  105.             0,
  106.             strCurrency
  107.         );

  108.         MergedDiscountForwardCurve dcOIS = OvernightIndexCurve.MakeDC (
  109.             dtToday,
  110.             strCurrency
  111.         );

  112.         SingleStreamComponent diFutures = SingleStreamComponentBuilder.Deposit (
  113.             dtToday,
  114.             dtToday.addTenorAndAdjust (
  115.                 "1M",
  116.                 strCurrency
  117.             ),
  118.             OvernightLabel.Create (
  119.                 strCurrency
  120.             )
  121.         );

  122.         CurveSurfaceQuoteContainer mktParams = MarketParamsBuilder.Create (
  123.             dcOIS,
  124.             null,
  125.             null,
  126.             null,
  127.             null,
  128.             null,
  129.             null,
  130.             null
  131.         );

  132.         ValuationParams valParams = new ValuationParams (
  133.             dtToday,
  134.             dtToday,
  135.             strCurrency
  136.         );

  137.         Map<String, Double> mapDIFuturesOutput = diFutures.value (
  138.             valParams,
  139.             null,
  140.             mktParams,
  141.             null
  142.         );

  143.         for (Map.Entry<String, Double> me : mapDIFuturesOutput.entrySet())
  144.             System.out.println ("\t" + me.getKey() + " => " + me.getValue());

  145.         EnvManager.TerminateEnv();
  146.     }
  147. }