TreasuryFuturesSettle.java

  1. package org.drip.market.exchange;

  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.  *
  14.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  15.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  16.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  17.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  18.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  19.  *      and computational support.
  20.  *  
  21.  *      https://lakshmidrip.github.io/DROP/
  22.  *  
  23.  *  DROP is composed of three modules:
  24.  *  
  25.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  26.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  27.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  28.  *
  29.  *  DROP Product Core implements libraries for the following:
  30.  *  - Fixed Income Analytics
  31.  *  - Loan Analytics
  32.  *  - Transaction Cost Analytics
  33.  *
  34.  *  DROP Portfolio Core implements libraries for the following:
  35.  *  - Asset Allocation Analytics
  36.  *  - Asset Liability Management Analytics
  37.  *  - Capital Estimation Analytics
  38.  *  - Exposure Analytics
  39.  *  - Margin Analytics
  40.  *  - XVA Analytics
  41.  *
  42.  *  DROP Computational Core implements libraries for the following:
  43.  *  - Algorithm Support
  44.  *  - Computation Support
  45.  *  - Function Analysis
  46.  *  - Model Validation
  47.  *  - Numerical Analysis
  48.  *  - Numerical Optimizer
  49.  *  - Spline Builder
  50.  *  - Statistical Learning
  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>TreasuryFuturesSettle</i> contains the Settlement Details for the Futures Basket of the Exchange-Traded
  81.  * Treasury Futures Contracts.
  82.  *
  83.  *  <br><br>
  84.  *  <ul>
  85.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product 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/market">Static Market Fields - the Definitions, the OTC/Exchange Traded Products, and Treasury Settings</a></li>
  88.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/market/exchange">Deliverable Swap, STIR, Treasury Futures</a></li>
  89.  *  </ul>
  90.  *
  91.  * @author Lakshmi Krishnamurthy
  92.  */

  93. public class TreasuryFuturesSettle {

  94.     /**
  95.      * Cash Settled Futures
  96.      */

  97.     public static final int SETTLE_TYPE_CASH = 1;

  98.     /**
  99.      * Physically Settled Futures
  100.      */

  101.     public static final int SETTLE_TYPE_PHYSICAL_DELIVERY = 2;

  102.     /**
  103.      * Settle Quote Type - AUD Bank Bill Type - Uses a Flat Reference Index
  104.      */

  105.     public static final int QUOTE_REFERENCE_INDEX_FLAT = 1;

  106.     /**
  107.      * Settle Quote Type - Uses a Reference Index Based off of Conversion Factor
  108.      */

  109.     public static final int QUOTE_REFERENCE_INDEX_CONVERSION_FACTOR = 2;

  110.     /**
  111.      * Settle Quote Type - Uses a Reference Index Based off of Conversion Factor Computed AUD Bond Futures
  112.      *  Style
  113.      */

  114.     public static final int QUOTE_REFERENCE_INDEX_AUD_BOND_FUTURES_STYLE = 3;

  115.     private int _iSettleType = -1;
  116.     private int _iSettleQuoteStyle = -1;
  117.     private int[] _aiDeliveryMonth = null;
  118.     private int _iExpiryLastTradingLag = -1;
  119.     private boolean _bWildCardOption = false;
  120.     private int _iExpiryFirstDeliveryLag = -1;
  121.     private int _iExpiryFinalDeliveryLag = -1;
  122.     private int _iExpiryDeliveryNoticeLag = -1;
  123.     private double _dblReferenceCouponCurrent = java.lang.Double.NaN;
  124.     private double _dblReferenceCouponOriginal = java.lang.Double.NaN;

  125.     /**
  126.      * TreasuryFuturesSettle Constructor
  127.      *
  128.      * @param iExpiryFirstDeliveryLag Lag Between the Expiry and the First Delivery Dates
  129.      * @param iExpiryFinalDeliveryLag Lag Between the Expiry and the Final Delivery Dates
  130.      * @param iExpiryDeliveryNoticeLag Lag between the Expiry and the Delivery Notice
  131.      * @param iExpiryLastTradingLag Lag between the Expiry and the Last Trading Day
  132.      * @param iSettleType Settlement Type
  133.      * @param iSettleQuoteStyle Settlement Quote Style
  134.      * @param bWildCardOption TRUE - Turn ON the Wild Card Option
  135.      * @param dblReferenceCouponCurrent The Current Reference Coupon
  136.      * @param dblReferenceCouponOriginal The Original Reference Coupon
  137.      * @param aiDeliveryMonth Array of the Delivery Months
  138.      *
  139.      * @throws java.lang.Exception Thrown if the Inputs are invalid
  140.      */

  141.     public TreasuryFuturesSettle (
  142.         final int iExpiryFirstDeliveryLag,
  143.         final int iExpiryFinalDeliveryLag,
  144.         final int iExpiryDeliveryNoticeLag,
  145.         final int iExpiryLastTradingLag,
  146.         final int iSettleType,
  147.         final int iSettleQuoteStyle,
  148.         final boolean bWildCardOption,
  149.         final double dblReferenceCouponCurrent,
  150.         final double dblReferenceCouponOriginal,
  151.         final int[] aiDeliveryMonth)
  152.         throws java.lang.Exception
  153.     {
  154.         if ((_iExpiryFinalDeliveryLag = iExpiryFinalDeliveryLag) < (_iExpiryFirstDeliveryLag =
  155.             iExpiryFirstDeliveryLag) || _iExpiryFirstDeliveryLag < 0)
  156.             throw new java.lang.Exception ("TreasuryFuturesSettle ctr: Invalid Inputs");

  157.         _iSettleType = iSettleType;
  158.         _aiDeliveryMonth = aiDeliveryMonth;
  159.         _bWildCardOption = bWildCardOption;
  160.         _iSettleQuoteStyle = iSettleQuoteStyle;
  161.         _iExpiryLastTradingLag = iExpiryLastTradingLag;
  162.         _iExpiryFirstDeliveryLag = iExpiryFirstDeliveryLag;
  163.         _iExpiryFinalDeliveryLag = iExpiryFinalDeliveryLag;
  164.         _iExpiryDeliveryNoticeLag = iExpiryDeliveryNoticeLag;
  165.         _dblReferenceCouponCurrent = dblReferenceCouponCurrent;
  166.         _dblReferenceCouponOriginal = dblReferenceCouponOriginal;
  167.     }

  168.     /**
  169.      * Retrieve the Lag Between the Expiry and the First Delivery Dates
  170.      *
  171.      * @return The Lag Between the Expiry and the First Delivery Dates
  172.      */

  173.     public int expiryFirstDeliveryLag()
  174.     {
  175.         return _iExpiryFirstDeliveryLag;
  176.     }

  177.     /**
  178.      * Retrieve the Lag Between the Expiry and the Final Delivery Dates
  179.      *
  180.      * @return The Lag Between the Expiry and the Final Delivery Dates
  181.      */

  182.     public int expiryFinalDeliveryLag()
  183.     {
  184.         return _iExpiryFinalDeliveryLag;
  185.     }

  186.     /**
  187.      * Retrieve the Lag Between the Expiry and the Delivery Notice Dates
  188.      *
  189.      * @return The Lag Between the Expiry and the Delivery Notice Dates
  190.      */

  191.     public int expiryDeliveryNoticeLag()
  192.     {
  193.         return _iExpiryDeliveryNoticeLag;
  194.     }

  195.     /**
  196.      * Retrieve the Lag Between the Expiry and the Last Trading Dates
  197.      *
  198.      * @return The Lag Between the Expiry and the Last Trading Dates
  199.      */

  200.     public int expiryLastTradingLag()
  201.     {
  202.         return _iExpiryLastTradingLag;
  203.     }

  204.     /**
  205.      * Retrieve the Settle Type
  206.      *
  207.      * @return The Settle Type
  208.      */

  209.     public int settleType()
  210.     {
  211.         return _iSettleType;
  212.     }

  213.     /**
  214.      * Retrieve the Settle Quote Style
  215.      *
  216.      * @return The Settle Quote Style
  217.      */

  218.     public int settleQuoteStyle()
  219.     {
  220.         return _iSettleQuoteStyle;
  221.     }

  222.     /**
  223.      * Retrieve the Bond Futures Wild Card Option Setting
  224.      *
  225.      * @return Bond Futures Wild Card Option Setting
  226.      */

  227.     public boolean wildCardOption()
  228.     {
  229.         return _bWildCardOption;
  230.     }

  231.     /**
  232.      * Retrieve the Current Reference Coupon
  233.      *
  234.      * @return The Current Reference Coupon
  235.      */

  236.     public double currentReferenceYield()
  237.     {
  238.         return _dblReferenceCouponCurrent;
  239.     }

  240.     /**
  241.      * Retrieve the Original Reference Coupon
  242.      *
  243.      * @return The Original Reference Coupon
  244.      */

  245.     public double originalReferenceCoupon()
  246.     {
  247.         return _dblReferenceCouponOriginal;
  248.     }

  249.     /**
  250.      * Retrieve the Delivery Months
  251.      *
  252.      * @return The Array of Delivery Months
  253.      */

  254.     public int[] deliveryMonths()
  255.     {
  256.         return _aiDeliveryMonth;
  257.     }

  258.     @Override public java.lang.String toString()
  259.     {
  260.         java.lang.String strDeliveryMonths = "";
  261.         int iNumDeliveryMonth = null == _aiDeliveryMonth ? 0 : _aiDeliveryMonth.length;

  262.         if (0 != iNumDeliveryMonth) {
  263.             for (int i = 0; i < iNumDeliveryMonth; ++i) {
  264.                 if (0 == i)
  265.                     strDeliveryMonths += " | Delivery Months: {";
  266.                 else
  267.                     strDeliveryMonths += ",";

  268.                 strDeliveryMonths += org.drip.analytics.date.DateUtil.MonthChar (_aiDeliveryMonth[i]);
  269.             }

  270.             strDeliveryMonths += "}";
  271.         }

  272.         return "[Futures Settle => Expiry To First Delivery Lag: " + _iExpiryFirstDeliveryLag +
  273.             " | Expiry To Final Delivery Lag: " + _iExpiryFinalDeliveryLag +
  274.                 " | Expiry To Delivery Notice Lag: " + _iExpiryDeliveryNoticeLag +
  275.                     " | Expiry To Last Trading Lag: " + _iExpiryLastTradingLag + " | Settlement Type:  " +
  276.                         _iSettleType + " | Settlement Quote Style: " + _iSettleQuoteStyle + " | Wild Card: "
  277.                             + _bWildCardOption + " | Current Reference Coupon: " + _dblReferenceCouponCurrent
  278.                                 + " | Original Reference Coupon: " + _dblReferenceCouponOriginal +
  279.                                     strDeliveryMonths + "]";
  280.     }
  281. }