FBB1.java

  1. package org.drip.sample.treasuryfuturesapi;

  2. import java.util.Map;

  3. import org.drip.analytics.date.*;
  4. import org.drip.service.env.EnvManager;
  5. import org.drip.service.product.TreasuryFuturesAPI;

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

  9. /*!
  10.  * Copyright (C) 2018 Lakshmi Krishnamurthy
  11.  * Copyright (C) 2017 Lakshmi Krishnamurthy
  12.  * Copyright (C) 2016 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.  * FBB1 demonstrates the Invocation and Examination of the FBB1 10Y SPGB Treasury Futures.
  53.  *
  54.  * @author Lakshmi Krishnamurthy
  55.  */

  56. public class FBB1 {

  57.     public static final void main (
  58.         final String[] args)
  59.         throws Exception
  60.     {
  61.         EnvManager.InitEnv ("");

  62.         int[] aiFuturesComponentTreasuryEffectiveDate = new int[] {
  63.             DateUtil.CreateFromYMD (2014, DateUtil.FEBRUARY,  28).julian(), // 912828J5
  64.             DateUtil.CreateFromYMD (2014, DateUtil.MARCH,     31).julian(), // 912828J8
  65.             DateUtil.CreateFromYMD (2014, DateUtil.APRIL,     30).julian(), // 912828K5
  66.             DateUtil.CreateFromYMD (2014, DateUtil.MAY,       31).julian(), // 912828XE
  67.             DateUtil.CreateFromYMD (2014, DateUtil.JUNE,      30).julian(), // 912828XH
  68.             DateUtil.CreateFromYMD (2014, DateUtil.JULY,      31).julian(), // 912828XM
  69.             DateUtil.CreateFromYMD (2014, DateUtil.AUGUST,    31).julian(), // 912828L3
  70.             DateUtil.CreateFromYMD (2014, DateUtil.SEPTEMBER, 30).julian(), // 912828L6
  71.             DateUtil.CreateFromYMD (2014, DateUtil.OCTOBER,   31).julian()  // 912828L9
  72.         };

  73.         int[] aiFuturesComponentTreasuryMaturityDate = new int[] {
  74.             DateUtil.CreateFromYMD (2020, DateUtil.FEBRUARY,  28).julian(), // 912828J5
  75.             DateUtil.CreateFromYMD (2020, DateUtil.MARCH,     31).julian(), // 912828J8
  76.             DateUtil.CreateFromYMD (2020, DateUtil.APRIL,     30).julian(), // 912828K5
  77.             DateUtil.CreateFromYMD (2020, DateUtil.MAY,       31).julian(), // 912828XE
  78.             DateUtil.CreateFromYMD (2020, DateUtil.JUNE,      30).julian(), // 912828XH
  79.             DateUtil.CreateFromYMD (2020, DateUtil.JULY,      31).julian(), // 912828XM
  80.             DateUtil.CreateFromYMD (2020, DateUtil.AUGUST,    31).julian(), // 912828L3
  81.             DateUtil.CreateFromYMD (2020, DateUtil.SEPTEMBER, 30).julian(), // 912828L6
  82.             DateUtil.CreateFromYMD (2020, DateUtil.OCTOBER,   31).julian()  // 912828L9
  83.         };

  84.         double[] adblFuturesComponentTreasuryCoupon = new double[] {
  85.             0.01375, // 912828J5
  86.             0.01375, // 912828J8
  87.             0.01375, // 912828K5
  88.             0.01500, // 912828XE
  89.             0.01625, // 912828XH
  90.             0.01625, // 912828XM
  91.             0.01375, // 912828L3
  92.             0.01375, // 912828L6
  93.             0.01375  // 912828L9
  94.         };

  95.         double[] adblFuturesComponentConversionFactor = new double[] {
  96.             0.8317, // 912828J5
  97.             0.8287, // 912828J8
  98.             0.8258, // 912828K5
  99.             0.8276, // 912828XE
  100.             0.8297, // 912828XH
  101.             0.8269, // 912828XM
  102.             0.8141, // 912828L3
  103.             0.8113, // 912828L6
  104.             0.8084  // 912828L9
  105.         };

  106.         int iSpotDate = DateUtil.CreateFromYMD (
  107.             2015,
  108.             DateUtil.NOVEMBER,
  109.             18
  110.         ).julian();

  111.         String[] astrFundingCurveDepositTenor = new String[] {
  112.             "2D",
  113.             "1W",
  114.             "1M",
  115.             "2M",
  116.             "3M"
  117.         };

  118.         double[] adblFundingCurveDepositQuote = new double[] {
  119.             0.00195, // 2D
  120.             0.00176, // 1W
  121.             0.00301, // 1M
  122.             0.00401, // 2M
  123.             0.00492  // 3M
  124.         };

  125.         String strFundingCurveDepositMeasure = "ForwardRate";

  126.         double[] adblFundingCurveFuturesQuote = new double[] {
  127.             0.00609,
  128.             0.00687
  129.         };

  130.         String strFundingCurveFuturesMeasure = "ForwardRate";

  131.         String[] astrFundingCurveFixFloatTenor = new String[] {
  132.             "01Y",
  133.             "02Y",
  134.             "03Y",
  135.             "04Y",
  136.             "05Y",
  137.             "06Y",
  138.             "07Y",
  139.             "08Y",
  140.             "09Y",
  141.             "10Y",
  142.             "11Y",
  143.             "12Y",
  144.             "15Y",
  145.             "20Y",
  146.             "25Y",
  147.             "30Y",
  148.             "40Y",
  149.             "50Y"
  150.         };

  151.         double[] adblFundingCurveFixFloatQuote = new double[] {
  152.             0.00762, //  1Y
  153.             0.01055, //  2Y
  154.             0.01300, //  3Y
  155.             0.01495, //  4Y
  156.             0.01651, //  5Y
  157.             0.01787, //  6Y
  158.             0.01904, //  7Y
  159.             0.02005, //  8Y
  160.             0.02090, //  9Y
  161.             0.02166, // 10Y
  162.             0.02231, // 11Y
  163.             0.02289, // 12Y
  164.             0.02414, // 15Y
  165.             0.02570, // 20Y
  166.             0.02594, // 25Y
  167.             0.02627, // 30Y
  168.             0.02648, // 40Y
  169.             0.02632  // 50Y
  170.         };

  171.         String strFundingFixFloatMeasure = "SwapRate";

  172.         int[] aiGovvieCurveTreasuryEffectiveDate = new int[] {
  173.             iSpotDate,
  174.             iSpotDate,
  175.             iSpotDate,
  176.             iSpotDate,
  177.             iSpotDate,
  178.             iSpotDate,
  179.             iSpotDate
  180.         };

  181.         int[] aiGovvieCurveTreasuryMaturityDate = new int[] {
  182.             new JulianDate (iSpotDate).addTenor ("1Y").julian(),
  183.             new JulianDate (iSpotDate).addTenor ("2Y").julian(),
  184.             new JulianDate (iSpotDate).addTenor ("3Y").julian(),
  185.             new JulianDate (iSpotDate).addTenor ("5Y").julian(),
  186.             new JulianDate (iSpotDate).addTenor ("7Y").julian(),
  187.             new JulianDate (iSpotDate).addTenor ("10Y").julian(),
  188.             new JulianDate (iSpotDate).addTenor ("30Y").julian()
  189.         };

  190.         double[] adblGovvieCurveTreasuryCoupon = new double[] {
  191.             0.0100,
  192.             0.0100,
  193.             0.0125,
  194.             0.0150,
  195.             0.0200,
  196.             0.0225,
  197.             0.0300
  198.         };

  199.         double[] adblGovvieCurveTreasuryYield = new double[] {
  200.             0.00692,
  201.             0.00945,
  202.             0.01257,
  203.             0.01678,
  204.             0.02025,
  205.             0.02235,
  206.             0.02972
  207.         };

  208.         String strGovvieCurveTreasuryMeasure = "Yield";

  209.         double[] adblFuturesComponentTreasuryPrice = new double[] {
  210.              0.99909375, // 912828J5
  211.              0.99900000, // 912828J8
  212.              0.99890625, // 912828K5
  213.              0.99943750, // 912828XE
  214.              0.99984375, // 912828XH
  215.              0.99978125, // 912828XM
  216.              0.99862500, // 912828L3
  217.              0.99850000, // 912828L6
  218.              0.99853125  // 912828L9
  219.         };

  220.         Map<String, Double> mapTreasuryFutures = TreasuryFuturesAPI.ValuationMetrics (
  221.             "FBB1",
  222.             aiFuturesComponentTreasuryEffectiveDate,
  223.             aiFuturesComponentTreasuryMaturityDate,
  224.             adblFuturesComponentTreasuryCoupon,
  225.             adblFuturesComponentConversionFactor,
  226.             iSpotDate,
  227.             astrFundingCurveDepositTenor,
  228.             adblFundingCurveDepositQuote,
  229.             strFundingCurveDepositMeasure,
  230.             adblFundingCurveFuturesQuote,
  231.             strFundingCurveFuturesMeasure,
  232.             astrFundingCurveFixFloatTenor,
  233.             adblFundingCurveFixFloatQuote,
  234.             strFundingFixFloatMeasure,
  235.             aiGovvieCurveTreasuryEffectiveDate,
  236.             aiGovvieCurveTreasuryMaturityDate,
  237.             adblGovvieCurveTreasuryCoupon,
  238.             adblGovvieCurveTreasuryYield,
  239.             strGovvieCurveTreasuryMeasure,
  240.             adblFuturesComponentTreasuryPrice
  241.         );

  242.         for (Map.Entry<String, Double> me : mapTreasuryFutures.entrySet())
  243.             System.out.println ("\t" + me.getKey() + " => " + me.getValue());
  244.     }
  245. }