NumeraireInducedMeasureShift.java

  1. package org.drip.exposure.csadynamics;

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

  76. /**
  77.  * <i>NumeraireInducedMeasureShift</i> computes the Shift of the Forward Terminal Distribution between the
  78.  * Non-CSA and the CSA Cases. The References are:
  79.  *  
  80.  * <br><br>
  81.  *      <ul>
  82.  *          <li>
  83.  *              Antonov, A., and M. Arneguy (2009): Analytical Formulas for Pricing CMS Products in the LIBOR
  84.  *                  Market Model with Stochastic Volatility
  85.  *                  https://papers.ssrn.com/sol3/Papers.cfm?abstract_id=1352606 <b>eSSRN</b>
  86.  *          </li>
  87.  *          <li>
  88.  *              Burgard, C., and M. Kjaer (2009): Modeling and successful Management of Credit Counter-party
  89.  *                  Risk of Derivative Portfolios <i>ICBI Conference</i> <b>Rome</b>
  90.  *          </li>
  91.  *          <li>
  92.  *              Gregory, J. (2009): Being Two-faced over Counter-party Credit Risk <i>Risk</i> <b>20 (2)</b>
  93.  *                  86-90
  94.  *          </li>
  95.  *          <li>
  96.  *              Johannes, M., and S. Sundaresan (2007): Pricing Collateralized Swaps <i>Journal of
  97.  *                  Finance</i> <b>62</b> 383-410
  98.  *          </li>
  99.  *          <li>
  100.  *              Piterbarg, V. (2010): Funding Beyond Discounting: Collateral Agreements and Derivatives
  101.  *                  Pricing <i>Risk</i> <b>21 (2)</b> 97-102
  102.  *          </li>
  103.  *      </ul>
  104.  *
  105.  *  <br><br>
  106.  *  <ul>
  107.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/PortfolioCore.md">Portfolio Core Module</a></li>
  108.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ExposureAnalyticsLibrary.md">Exposure Analytics</a></li>
  109.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/exposure/README.md">Exposure Group Level Collateralized/Uncollateralized Exposure</a></li>
  110.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/exposure/csadynamics/README.md">CSA Numeraire Basis/Measure Dynamics</a></li>
  111.  *  </ul>
  112.  *
  113.  * @author Lakshmi Krishnamurthy
  114.  */

  115. public class NumeraireInducedMeasureShift
  116. {
  117.     private double _csaForward = java.lang.Double.NaN;
  118.     private double _noCSAForward = java.lang.Double.NaN;
  119.     private double _terminalVariance = java.lang.Double.NaN;

  120.     /**
  121.      * NumeraireInducedMeasureShift Constructor
  122.      *
  123.      * @param csaForward The CSA Implied Forward Value
  124.      * @param noCSAForward The No CSA Implied Forward Value
  125.      * @param terminalVariance The Terminal Variance of the Underlying
  126.      *
  127.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  128.      */

  129.     public NumeraireInducedMeasureShift (
  130.         final double csaForward,
  131.         final double noCSAForward,
  132.         final double terminalVariance)
  133.         throws java.lang.Exception
  134.     {
  135.         if (!org.drip.numerical.common.NumberUtil.IsValid (_csaForward = csaForward) ||
  136.             !org.drip.numerical.common.NumberUtil.IsValid (_noCSAForward = noCSAForward) ||
  137.             !org.drip.numerical.common.NumberUtil.IsValid (_terminalVariance = terminalVariance))
  138.         {
  139.             throw new java.lang.Exception ("NumeraireInducedMeasureShift Constructor => Invalid Inputs");
  140.         }
  141.     }

  142.     /**
  143.      * Return the Value of the Forward Contract under CSA
  144.      *
  145.      * @return The Value of the Forward Contract under CSA
  146.      */

  147.     public double csaForward()
  148.     {
  149.         return _csaForward;
  150.     }

  151.     /**
  152.      * Return the Value of the Forward Contract under No CSA Criterion
  153.      *
  154.      * @return The Value of the Forward Contract under No CSA Criterion
  155.      */

  156.     public double noCSAForward()
  157.     {
  158.         return _noCSAForward;
  159.     }

  160.     /**
  161.      * Return the Terminal Variance of the Underlying
  162.      *
  163.      * @return The Terminal Variance of the Underlying
  164.      */

  165.     public double terminalVariance()
  166.     {
  167.         return _terminalVariance;
  168.     }

  169.     /**
  170.      * Return the Linear Strike Coefficient of the Relative Measure Differential
  171.      *
  172.      * @return The Linear Strike Coefficient of the Relative Measure Differential
  173.      */

  174.     public double alpha1()
  175.     {
  176.         return (_noCSAForward - _csaForward) / _terminalVariance;
  177.     }

  178.     /**
  179.      * Return the Constant Strike Coefficient of the Relative Measure Differential
  180.      *
  181.      * @return The Constant Strike Coefficient of the Relative Measure Differential
  182.      */

  183.     public double alpha0()
  184.     {
  185.         return 1. - alpha1() * _csaForward;
  186.     }

  187.     /**
  188.      * Compute the No CSA/CSA Density Re-scaling using the Antonov and Arneguy (2009) Linear Proxy Approach
  189.      *
  190.      * @param k The Strike at which the Density Re-scaling is Sought
  191.      *
  192.      * @return The No CSA/CSA Density Re-scaling using the Antonov and Arneguy (2009) Linear Proxy Approach
  193.      *
  194.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  195.      */

  196.     public double densityRescale (
  197.         final double k)
  198.         throws java.lang.Exception
  199.     {
  200.         if (!org.drip.numerical.common.NumberUtil.IsValid (k))
  201.         {
  202.             throw new java.lang.Exception ("NumeraireInducedMeasureShift::densityRescale => Invalid Inputs");
  203.         }

  204.         double dblAlpha1 = (_noCSAForward - _csaForward) / _terminalVariance;
  205.         return 1. - dblAlpha1 * _csaForward + dblAlpha1 * k;
  206.     }
  207. }