SABRLIBORCapVolatility.java

  1. package org.drip.function.r1tor1;

  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>SABRLIBORCapVolatility</i> implements the Deterministic, Non-local Cap Volatility Scheme detailed in:
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Rebonato, R., K. McKay, and R. White (2009): <i>The SABR/LIBOR Market Model: Pricing,
  86.  *              Calibration, and Hedging for Complex Interest-Rate Derivatives</i> <b>John Wiley and Sons</b>
  87.  *      </li>
  88.  *  </ul>
  89.  *
  90.  *  <br><br>
  91.  *  <ul>
  92.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  93.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  94.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/README.md">R<sup>d</sup> To R<sup>d</sup> Function Analysis</a></li>
  95.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/function/r1tor1/README.md">Built-in R<sup>1</sup> To R<sup>1</sup> Functions</a></li>
  96.  *  </ul>
  97.  *
  98.  * @author Lakshmi Krishnamurthy
  99.  */

  100. public class SABRLIBORCapVolatility extends org.drip.function.definition.R1ToR1 {
  101.     private double _dblA = java.lang.Double.NaN;
  102.     private double _dblB = java.lang.Double.NaN;
  103.     private double _dblC = java.lang.Double.NaN;
  104.     private double _dblD = java.lang.Double.NaN;
  105.     private double _dblEpoch = java.lang.Double.NaN;

  106.     /**
  107.      * SABRLIBORCapVolatility Constructor
  108.      *
  109.      * @param dblEpoch Epoch
  110.      * @param dblA A
  111.      * @param dblB B
  112.      * @param dblC C
  113.      * @param dblD D
  114.      *
  115.      * @throws java.lang.Exception Thrown if Inputs are Invalid
  116.      */

  117.     public SABRLIBORCapVolatility (
  118.         final double dblEpoch,
  119.         final double dblA,
  120.         final double dblB,
  121.         final double dblC,
  122.         final double dblD)
  123.         throws java.lang.Exception
  124.     {
  125.         super (null);

  126.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblEpoch = dblEpoch) ||
  127.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblA = dblA) ||
  128.                     !org.drip.numerical.common.NumberUtil.IsValid (_dblB = dblB) ||
  129.                         !org.drip.numerical.common.NumberUtil.IsValid (_dblC = dblC) ||
  130.                             !org.drip.numerical.common.NumberUtil.IsValid (_dblD = dblD))
  131.             throw new java.lang.Exception ("SABRLIBORCapVolatility ctr: Invalid Inputs");
  132.     }

  133.     @Override public double evaluate (
  134.         final double dblVariate)
  135.         throws java.lang.Exception
  136.     {
  137.         if (!org.drip.numerical.common.NumberUtil.IsValid (dblVariate))
  138.             throw new java.lang.Exception ("SABRLIBORCapVolatility::evaluate => Invalid Inputs");

  139.         double dblDateGap = dblVariate - _dblEpoch;

  140.         return (_dblB * dblDateGap + _dblA) * java.lang.Math.exp (-1. * _dblC * dblDateGap) + _dblD;
  141.     }

  142.     /**
  143.      * Return "A"
  144.      *
  145.      * @return "A"
  146.      */

  147.     public double A()
  148.     {
  149.         return _dblA;
  150.     }

  151.     /**
  152.      * Return "B"
  153.      *
  154.      * @return "B"
  155.      */

  156.     public double B()
  157.     {
  158.         return _dblB;
  159.     }

  160.     /**
  161.      * Return "C"
  162.      *
  163.      * @return "C"
  164.      */

  165.     public double C()
  166.     {
  167.         return _dblC;
  168.     }

  169.     /**
  170.      * Return "D"
  171.      *
  172.      * @return "D"
  173.      */

  174.     public double D()
  175.     {
  176.         return _dblD;
  177.     }

  178.     /**
  179.      * Return the Epoch
  180.      *
  181.      * @return The Epoch
  182.      */

  183.     public double epoch()
  184.     {
  185.         return _dblEpoch;
  186.     }
  187. }