ExpiryDeliveryTradingDates.java

  1. package org.drip.sample.treasuryfutures;

  2. import org.drip.analytics.date.*;
  3. import org.drip.market.exchange.*;
  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) 2018 Lakshmi Krishnamurthy
  10.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2016 Lakshmi Krishnamurthy
  12.  * Copyright (C) 2015 Lakshmi Krishnamurthy
  13.  *
  14.  *  This file is part of DRIP, a free-software/open-source library for buy/side financial/trading model
  15.  *      libraries targeting analysts and developers
  16.  *      https://lakshmidrip.github.io/DRIP/
  17.  *  
  18.  *  DRIP is composed of four main libraries:
  19.  *  
  20.  *  - DRIP Fixed Income - https://lakshmidrip.github.io/DRIP-Fixed-Income/
  21.  *  - DRIP Asset Allocation - https://lakshmidrip.github.io/DRIP-Asset-Allocation/
  22.  *  - DRIP Numerical Optimizer - https://lakshmidrip.github.io/DRIP-Numerical-Optimizer/
  23.  *  - DRIP Statistical Learning - https://lakshmidrip.github.io/DRIP-Statistical-Learning/
  24.  *
  25.  *  - DRIP Fixed Income: Library for Instrument/Trading Conventions, Treasury Futures/Options,
  26.  *      Funding/Forward/Overnight Curves, Multi-Curve Construction/Valuation, Collateral Valuation and XVA
  27.  *      Metric Generation, Calibration and Hedge Attributions, Statistical Curve Construction, Bond RV
  28.  *      Metrics, Stochastic Evolution and Option Pricing, Interest Rate Dynamics and Option Pricing, LMM
  29.  *      Extensions/Calibrations/Greeks, Algorithmic Differentiation, and Asset Backed Models and Analytics.
  30.  *
  31.  *  - DRIP Asset Allocation: Library for model libraries for MPT framework, Black Litterman Strategy
  32.  *      Incorporator, Holdings Constraint, and Transaction Costs.
  33.  *
  34.  *  - DRIP Numerical Optimizer: Library for Numerical Optimization and Spline Functionality.
  35.  *
  36.  *  - DRIP Statistical Learning: Library for Statistical Evaluation and Machine Learning.
  37.  *
  38.  *  Licensed under the Apache License, Version 2.0 (the "License");
  39.  *      you may not use this file except in compliance with the License.
  40.  *  
  41.  *  You may obtain a copy of the License at
  42.  *      http://www.apache.org/licenses/LICENSE-2.0
  43.  *  
  44.  *  Unless required by applicable law or agreed to in writing, software
  45.  *      distributed under the License is distributed on an "AS IS" BASIS,
  46.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  47.  *  
  48.  *  See the License for the specific language governing permissions and
  49.  *      limitations under the License.
  50.  */

  51. /**
  52.  * ExpiryDeliveryTradingDates illustrates Generation of Event Dates from the Expiry Month/Year of the Bond
  53.  *  Futures Contracts.
  54.  *
  55.  * @author Lakshmi Krishnamurthy
  56.  */

  57. public class ExpiryDeliveryTradingDates {

  58.     private static final void DisplayEventDateInfo (
  59.         String strCurrency,
  60.         String strUnderlierType,
  61.         String strUnderlierSubtype,
  62.         String strMaturityTenor,
  63.         JulianDate dtSettle)
  64.         throws Exception
  65.     {
  66.         TreasuryFuturesConvention bfc = TreasuryFuturesConventionContainer.FromJurisdictionTypeMaturity (
  67.             strCurrency,
  68.             strUnderlierType,
  69.             strUnderlierSubtype,
  70.             strMaturityTenor
  71.         );

  72.         System.out.println ("\t| " +
  73.             bfc.eventDates (
  74.                 DateUtil.Year (dtSettle.julian()),
  75.                 DateUtil.Month (dtSettle.julian())
  76.             ) + " | [" +
  77.             strCurrency + "-" +
  78.             strUnderlierType + "-" +
  79.             strUnderlierSubtype + "-" +
  80.             strMaturityTenor + "]"
  81.         );
  82.     }

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

  88.         System.out.println();

  89.         java.lang.String strForwardTenor = "3M";

  90.         JulianDate dtToday = DateUtil.Today().addTenor (strForwardTenor);

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

  92.         System.out.println ("\t|   EXPIRY   | DELIV START |  DELIV END | DELIV NOTICE | LAST TRADE |           FUTURE           |");

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

  94.         DisplayEventDateInfo ("AUD", "BANK", "BILLS", "3M", dtToday);

  95.         DisplayEventDateInfo ("AUD", "TREASURY", "BOND", "3Y", dtToday);

  96.         DisplayEventDateInfo ("AUD", "TREASURY", "BOND", "10Y", dtToday);

  97.         DisplayEventDateInfo ("EUR", "EURO", "SCHATZ", "2Y", dtToday);

  98.         DisplayEventDateInfo ("EUR", "EURO", "BOBL", "5Y", dtToday);

  99.         DisplayEventDateInfo ("EUR", "EURO", "BUND", "10Y", dtToday);

  100.         DisplayEventDateInfo ("EUR", "EURO", "BUXL", "30Y", dtToday);

  101.         DisplayEventDateInfo ("EUR", "TREASURY", "BONO", "10Y", dtToday);

  102.         DisplayEventDateInfo ("GBP", "SHORT", "GILT", "2Y", dtToday);

  103.         DisplayEventDateInfo ("GBP", "MEDIUM", "GILT", "5Y", dtToday);

  104.         DisplayEventDateInfo ("GBP", "LONG", "GILT", "10Y", dtToday);

  105.         DisplayEventDateInfo ("JPY", "TREASURY", "JGB", "5Y", dtToday);

  106.         DisplayEventDateInfo ("JPY", "TREASURY", "JGB", "10Y", dtToday);

  107.         DisplayEventDateInfo ("USD", "TREASURY", "NOTE", "2Y", dtToday);

  108.         DisplayEventDateInfo ("USD", "TREASURY", "NOTE", "3Y", dtToday);

  109.         DisplayEventDateInfo ("USD", "TREASURY", "NOTE", "5Y", dtToday);

  110.         DisplayEventDateInfo ("USD", "TREASURY", "NOTE", "10Y", dtToday);

  111.         DisplayEventDateInfo ("USD", "TREASURY", "BOND", "30Y", dtToday);

  112.         DisplayEventDateInfo ("USD", "TREASURY", "BOND", "ULTRA", dtToday);

  113.         System.out.println ("\t|------------------------------------------------------------------------------------------------|\n");
  114.     }
  115. }