BGMForwardTenorSnap.java

  1. package org.drip.dynamics.lmm;

  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.  *
  13.  *  This file is part of DROP, an open-source library targeting analytics/risk, transaction cost analytics,
  14.  *      asset liability management analytics, capital, exposure, and margin analytics, valuation adjustment
  15.  *      analytics, and portfolio construction analytics within and across fixed income, credit, commodity,
  16.  *      equity, FX, and structured products. It also includes auxiliary libraries for algorithm support,
  17.  *      numerical analysis, numerical optimization, spline builder, model validation, statistical learning,
  18.  *      and computational support.
  19.  *  
  20.  *      https://lakshmidrip.github.io/DROP/
  21.  *  
  22.  *  DROP is composed of three modules:
  23.  *  
  24.  *  - DROP Product Core - https://lakshmidrip.github.io/DROP-Product-Core/
  25.  *  - DROP Portfolio Core - https://lakshmidrip.github.io/DROP-Portfolio-Core/
  26.  *  - DROP Computational Core - https://lakshmidrip.github.io/DROP-Computational-Core/
  27.  *
  28.  *  DROP Product Core implements libraries for the following:
  29.  *  - Fixed Income Analytics
  30.  *  - Loan Analytics
  31.  *  - Transaction Cost Analytics
  32.  *
  33.  *  DROP Portfolio Core implements libraries for the following:
  34.  *  - Asset Allocation Analytics
  35.  *  - Asset Liability Management Analytics
  36.  *  - Capital Estimation Analytics
  37.  *  - Exposure Analytics
  38.  *  - Margin Analytics
  39.  *  - XVA Analytics
  40.  *
  41.  *  DROP Computational Core implements libraries for the following:
  42.  *  - Algorithm Support
  43.  *  - Computation Support
  44.  *  - Function Analysis
  45.  *  - Model Validation
  46.  *  - Numerical Analysis
  47.  *  - Numerical Optimizer
  48.  *  - Spline Builder
  49.  *  - Statistical Learning
  50.  *
  51.  *  Documentation for DROP is Spread Over:
  52.  *
  53.  *  - Main                     => https://lakshmidrip.github.io/DROP/
  54.  *  - Wiki                     => https://github.com/lakshmiDRIP/DROP/wiki
  55.  *  - GitHub                   => https://github.com/lakshmiDRIP/DROP
  56.  *  - Repo Layout Taxonomy     => https://github.com/lakshmiDRIP/DROP/blob/master/Taxonomy.md
  57.  *  - Javadoc                  => https://lakshmidrip.github.io/DROP/Javadoc/index.html
  58.  *  - Technical Specifications => https://github.com/lakshmiDRIP/DROP/tree/master/Docs/Internal
  59.  *  - Release Versions         => https://lakshmidrip.github.io/DROP/version.html
  60.  *  - Community Credits        => https://lakshmidrip.github.io/DROP/credits.html
  61.  *  - Issues Catalog           => https://github.com/lakshmiDRIP/DROP/issues
  62.  *  - JUnit                    => https://lakshmidrip.github.io/DROP/junit/index.html
  63.  *  - Jacoco                   => https://lakshmidrip.github.io/DROP/jacoco/index.html
  64.  *
  65.  *  Licensed under the Apache License, Version 2.0 (the "License");
  66.  *      you may not use this file except in compliance with the License.
  67.  *  
  68.  *  You may obtain a copy of the License at
  69.  *      http://www.apache.org/licenses/LICENSE-2.0
  70.  *  
  71.  *  Unless required by applicable law or agreed to in writing, software
  72.  *      distributed under the License is distributed on an "AS IS" BASIS,
  73.  *      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  74.  *  
  75.  *  See the License for the specific language governing permissions and
  76.  *      limitations under the License.
  77.  */

  78. /**
  79.  * <i>BGMForwardTenorSnap</i> contains the Absolute and the Incremental Latent State Quantifier Snapshot
  80.  * traced from the Evolution of the LIBOR Forward Rate as formulated in:
  81.  *
  82.  *  <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Goldys, B., M. Musiela, and D. Sondermann (1994): <i>Log-normality of Rates and Term Structure
  86.  *              Models</i> <b>The University of New South Wales</b>
  87.  *      </li>
  88.  *      <li>
  89.  *          Musiela, M. (1994): <i>Nominal Annual Rates and Log-normal Volatility Structure</i> <b>The
  90.  *              University of New South Wales</b>
  91.  *      </li>
  92.  *      <li>
  93.  *          Brace, A., D. Gatarek, and M. Musiela (1997): The Market Model of Interest Rate Dynamics
  94.  *              <i>Mathematical Finance</i> <b>7 (2)</b> 127-155
  95.  *      </li>
  96.  *  </ul>
  97.  *
  98.  *  <br><br>
  99.  *  <ul>
  100.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  101.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  102.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/dynamics/README.md">HJM, Hull White, LMM, and SABR Dynamic Evolution Models</a></li>
  103.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/dynamics/lmm/README.md">LMM Based Latent State Evolution</a></li>
  104.  *  </ul>
  105.  *
  106.  * @author Lakshmi Krishnamurthy
  107.  */

  108. public class BGMForwardTenorSnap {
  109.     private double _dblLIBOR = java.lang.Double.NaN;
  110.     private int _iDate = java.lang.Integer.MIN_VALUE;
  111.     private double _dblDiscountFactor = java.lang.Double.NaN;
  112.     private double _dblLIBORIncrement = java.lang.Double.NaN;
  113.     private double _dblSpotRateIncrement = java.lang.Double.NaN;
  114.     private double _dblDiscountFactorIncrement = java.lang.Double.NaN;
  115.     private double _dblLognormalLIBORVolatility = java.lang.Double.NaN;
  116.     private double _dblInstantaneousNominalForwardRate = java.lang.Double.NaN;
  117.     private double _dblInstantaneousEffectiveForwardRate = java.lang.Double.NaN;
  118.     private double _dblContinuouslyCompoundedForwardIncrement = java.lang.Double.NaN;
  119.     private double _dblContinuouslyCompoundedForwardVolatility = java.lang.Double.NaN;

  120.     /**
  121.      * BGMForwardTenorSnap Constructor
  122.      *
  123.      * @param iDate The Date corresponding to the Tenor
  124.      * @param dblLIBOR The LIBOR Rate
  125.      * @param dblLIBORIncrement The LIBOR Rate Increment
  126.      * @param dblDiscountFactor The Discount Factor
  127.      * @param dblDiscountFactorIncrement The Discount Factor Increment
  128.      * @param dblContinuouslyCompoundedForwardIncrement Continuously Compounded Forward Rate Increment
  129.      * @param dblSpotRateIncrement Spot Rate Increment
  130.      * @param dblInstantaneousEffectiveForwardRate Instantaneous Effective Annual Forward Rate
  131.      * @param dblInstantaneousNominalForwardRate Instantaneous Nominal Annual Forward Rate
  132.      * @param dblLognormalLIBORVolatility The Log-normal LIBOR Rate Volatility
  133.      * @param dblContinuouslyCompoundedForwardVolatility The Continuously Compounded Forward Rate Volatility
  134.      *
  135.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  136.      */

  137.     public BGMForwardTenorSnap (
  138.         final int iDate,
  139.         final double dblLIBOR,
  140.         final double dblLIBORIncrement,
  141.         final double dblDiscountFactor,
  142.         final double dblDiscountFactorIncrement,
  143.         final double dblContinuouslyCompoundedForwardIncrement,
  144.         final double dblSpotRateIncrement,
  145.         final double dblInstantaneousEffectiveForwardRate,
  146.         final double dblInstantaneousNominalForwardRate,
  147.         final double dblLognormalLIBORVolatility,
  148.         final double dblContinuouslyCompoundedForwardVolatility)
  149.         throws java.lang.Exception
  150.     {
  151.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblLIBOR = dblLIBOR) ||
  152.             !org.drip.numerical.common.NumberUtil.IsValid (_dblLIBORIncrement = dblLIBORIncrement) ||
  153.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblDiscountFactor = dblDiscountFactor) ||
  154.                     !org.drip.numerical.common.NumberUtil.IsValid (_dblDiscountFactorIncrement =
  155.                         dblDiscountFactorIncrement) || !org.drip.numerical.common.NumberUtil.IsValid
  156.                             (_dblContinuouslyCompoundedForwardIncrement =
  157.                                 dblContinuouslyCompoundedForwardIncrement) ||
  158.                                     !org.drip.numerical.common.NumberUtil.IsValid (_dblSpotRateIncrement =
  159.                                         dblSpotRateIncrement) || !org.drip.numerical.common.NumberUtil.IsValid
  160.                                             (_dblInstantaneousEffectiveForwardRate =
  161.                                                 dblInstantaneousEffectiveForwardRate) ||
  162.                                                     !org.drip.numerical.common.NumberUtil.IsValid
  163.                                                         (_dblInstantaneousNominalForwardRate =
  164.                                                             dblInstantaneousNominalForwardRate) ||
  165.                                                                 !org.drip.numerical.common.NumberUtil.IsValid
  166.             (_dblLognormalLIBORVolatility = dblLognormalLIBORVolatility) ||
  167.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblContinuouslyCompoundedForwardVolatility =
  168.                     dblContinuouslyCompoundedForwardVolatility))
  169.             throw new java.lang.Exception ("BGMForwardTenorSnap ctr: Invalid Inputs");

  170.         _iDate = iDate;
  171.     }

  172.     /**
  173.      * Retrieve the Tenor Date
  174.      *
  175.      * @return The Tenor Date
  176.      */

  177.     public int date()
  178.     {
  179.         return _iDate;
  180.     }

  181.     /**
  182.      * Retrieve the LIBOR Rate
  183.      *
  184.      * @return The LIBOR Rate
  185.      */

  186.     public double libor()
  187.     {
  188.         return _dblLIBOR;
  189.     }

  190.     /**
  191.      * Retrieve the LIBOR Rate Increment
  192.      *
  193.      * @return The LIBOR Rate Increment
  194.      */

  195.     public double liborIncrement()
  196.     {
  197.         return _dblLIBORIncrement;
  198.     }

  199.     /**
  200.      * Retrieve the Discount Factor
  201.      *
  202.      * @return The Discount Factor
  203.      */

  204.     public double discountFactor()
  205.     {
  206.         return _dblDiscountFactor;
  207.     }

  208.     /**
  209.      * Retrieve the Discount Factor Increment
  210.      *
  211.      * @return The Discount Factor Increment
  212.      */

  213.     public double discountFactorIncrement()
  214.     {
  215.         return _dblDiscountFactorIncrement;
  216.     }

  217.     /**
  218.      * Retrieve the Continuously Compounded Forward Rate Increment
  219.      *
  220.      * @return The Continuously Compounded Forward Rate Increment
  221.      */

  222.     public double continuouslyCompoundedForwardIncrement()
  223.     {
  224.         return _dblContinuouslyCompoundedForwardIncrement;
  225.     }

  226.     /**
  227.      * Retrieve the Spot Rate Increment
  228.      *
  229.      * @return The Spot Rate Increment
  230.      */

  231.     public double spotRateIncrement()
  232.     {
  233.         return _dblSpotRateIncrement;
  234.     }

  235.     /**
  236.      * Retrieve the Instantaneous Effective Annual Forward Rate
  237.      *
  238.      * @return The Instantaneous Effective Annual Forward Rate
  239.      */

  240.     public double instantaneousEffectiveForwardRate()
  241.     {
  242.         return _dblInstantaneousEffectiveForwardRate;
  243.     }

  244.     /**
  245.      * Retrieve the Instantaneous Nominal Annual Forward Rate
  246.      *
  247.      * @return The Instantaneous Nominal Annual Forward Rate
  248.      */

  249.     public double instantaneousNominalForwardRate()
  250.     {
  251.         return _dblInstantaneousNominalForwardRate;
  252.     }

  253.     /**
  254.      * Retrieve the Log-normal LIBOR Volatility
  255.      *
  256.      * @return The Log-normal LIBOR Volatility
  257.      */

  258.     public double lognormalLIBORVolatility()
  259.     {
  260.         return _dblLognormalLIBORVolatility;
  261.     }

  262.     /**
  263.      * Retrieve the Continuously Compounded Forward Rate Volatility
  264.      *
  265.      * @return The Continuously Compounded Forward Rate Volatility
  266.      */

  267.     public double continuouslyCompoundedForwardVolatility()
  268.     {
  269.         return _dblContinuouslyCompoundedForwardVolatility;
  270.     }

  271.     @Override public java.lang.String toString()
  272.     {
  273.         return org.drip.numerical.common.FormatUtil.FormatDouble (_dblLIBOR, 1, 2, 100.) + "% | " +
  274.             org.drip.numerical.common.FormatUtil.FormatDouble (_dblLIBORIncrement, 2, 2, 10000.) + " | " +
  275.                 org.drip.numerical.common.FormatUtil.FormatDouble (_dblDiscountFactor, 1, 4, 1.) + " | " +
  276.                     org.drip.numerical.common.FormatUtil.FormatDouble (_dblDiscountFactorIncrement, 2, 2, 10000.)
  277.                         + " | " + org.drip.numerical.common.FormatUtil.FormatDouble
  278.                             (_dblContinuouslyCompoundedForwardIncrement, 2, 2, 10000.) + " | " +
  279.                                 org.drip.numerical.common.FormatUtil.FormatDouble (_dblSpotRateIncrement, 2, 2,
  280.                                     10000.) + " | " + org.drip.numerical.common.FormatUtil.FormatDouble
  281.                                         (_dblInstantaneousEffectiveForwardRate, 2, 2, 10000.) + " | " +
  282.                                             org.drip.numerical.common.FormatUtil.FormatDouble
  283.                                                 (_dblInstantaneousNominalForwardRate, 2, 2, 10000.) + " ||";
  284.     }
  285. }