JumpDiffusionEdge.java

  1. package org.drip.measure.realization;

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

  77. /**
  78.  * <i>JumpDiffusionEdge</i> implements the Deterministic and the Stochastic Components of a R<sup>d</sup>
  79.  * Marginal Random Increment Edge as well the Original Marginal Random Variate. The References are:
  80.  *
  81.  * <br><br>
  82.  *  <ul>
  83.  *      <li>
  84.  *          Almgren, R. F., and N. Chriss (2000): Optimal Execution of Portfolio Transactions <i>Journal of
  85.  *              Risk</i> <b>3 (2)</b> 5-39
  86.  *      </li>
  87.  *      <li>
  88.  *          Almgren, R. F. (2009): Optimal Trading in a Dynamic Market
  89.  *              https://www.math.nyu.edu/financial_mathematics/content/02_financial/2009-2.pdf
  90.  *      </li>
  91.  *      <li>
  92.  *          Almgren, R. F. (2012): Optimal Trading with Stochastic Liquidity and Volatility <i>SIAM Journal
  93.  *              of Financial Mathematics</i> <b>3 (1)</b> 163-181
  94.  *      </li>
  95.  *      <li>
  96.  *          Geman, H., D. B. Madan, and M. Yor (2001): Time Changes for Levy Processes <i>Mathematical
  97.  *              Finance</i> <b>11 (1)</b> 79-96
  98.  *      </li>
  99.  *      <li>
  100.  *          Jones, C. M., G. Kaul, and M. L. Lipson (1994): Transactions, Volume, and Volatility <i>Review of
  101.  *              Financial Studies</i> <b>7 (4)</b> 631-651
  102.  *      </li>
  103.  *  </ul>
  104.  *
  105.  *  <br><br>
  106.  *  <ul>
  107.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ComputationalCore.md">Computational Core Module</a></li>
  108.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/NumericalAnalysisLibrary.md">Numerical Analysis Library</a></li>
  109.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/README.md">R<sup>d</sup> Continuous/Discrete Probability Measures</a></li>
  110.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/measure/realization/README.md">Stochastic Jump Diffusion Vertex Edge</a></li>
  111.  *  </ul>
  112.  *
  113.  * @author Lakshmi Krishnamurthy
  114.  */

  115. public class JumpDiffusionEdge {
  116.     private double _dblStart = java.lang.Double.NaN;
  117.     private double _dblDeterministic = java.lang.Double.NaN;
  118.     private org.drip.measure.realization.StochasticEdgeJump _sej = null;
  119.     private org.drip.measure.realization.JumpDiffusionEdgeUnit _jdeu = null;
  120.     private org.drip.measure.realization.StochasticEdgeDiffusion _sed = null;

  121.     /**
  122.      * Construct the Standard JumpDiffusionEdge Instance
  123.      *
  124.      * @param dblStart The Starting Random Variable Realization
  125.      * @param dblDeterministic The Deterministic Increment Component
  126.      * @param dblDiffusionStochastic The Diffusion Stochastic Edge Change Amount
  127.      * @param bJumpOccurred TRUE - The Jump Occurred in this Edge Period
  128.      * @param dblHazardRate The Hazard Rate
  129.      * @param dblHazardIntegral The Level Hazard Integral
  130.      * @param dblJumpTarget The Jump Target
  131.      * @param dblTimeIncrement The Time Increment
  132.      * @param dblUnitDiffusion The Diffusion Random Variable
  133.      * @param dblUnitJump The Jump Random Variable
  134.      *
  135.      * @return The JumpDiffusionEdge Instance
  136.      */

  137.     public static final JumpDiffusionEdge Standard (
  138.         final double dblStart,
  139.         final double dblDeterministic,
  140.         final double dblDiffusionStochastic,
  141.         final boolean bJumpOccurred,
  142.         final double dblHazardRate,
  143.         final double dblHazardIntegral,
  144.         final double dblJumpTarget,
  145.         final double dblTimeIncrement,
  146.         final double dblUnitDiffusion,
  147.         final double dblUnitJump)
  148.     {
  149.         try {
  150.             return new JumpDiffusionEdge (dblStart, dblDeterministic, new
  151.                 org.drip.measure.realization.StochasticEdgeDiffusion (dblDiffusionStochastic), new
  152.                     org.drip.measure.realization.StochasticEdgeJump (bJumpOccurred, dblHazardRate,
  153.                         dblHazardIntegral, dblJumpTarget), new
  154.                             org.drip.measure.realization.JumpDiffusionEdgeUnit (dblTimeIncrement,
  155.                                 dblUnitDiffusion, dblUnitJump));
  156.         } catch (java.lang.Exception e) {
  157.             e.printStackTrace();
  158.         }

  159.         return null;
  160.     }

  161.     /**
  162.      * Construct the Standard JumpDiffusionEdge Instance
  163.      *
  164.      * @param dblStart The Starting Random Variable Realization
  165.      * @param dblDeterministic The Deterministic Increment Component
  166.      * @param dblDiffusionStochastic The Diffusion Stochastic Edge Change Amount
  167.      * @param sej The Stochastic Jump Edge Instance
  168.      * @param jdeu The Random Unit Realization
  169.      *
  170.      * @return The JumpDiffusionEdge Instance
  171.      */

  172.     public static final JumpDiffusionEdge Standard (
  173.         final double dblStart,
  174.         final double dblDeterministic,
  175.         final double dblDiffusionStochastic,
  176.         final org.drip.measure.realization.StochasticEdgeJump sej,
  177.         final org.drip.measure.realization.JumpDiffusionEdgeUnit jdeu)
  178.     {
  179.         try {
  180.             return new JumpDiffusionEdge (dblStart, dblDeterministic, new
  181.                 org.drip.measure.realization.StochasticEdgeDiffusion (dblDiffusionStochastic), sej, jdeu);
  182.         } catch (java.lang.Exception e) {
  183.             e.printStackTrace();
  184.         }

  185.         return null;
  186.     }

  187.     /**
  188.      * JumpDiffusionEdge Constructor
  189.      *
  190.      * @param dblStart The Starting Random Variable Realization
  191.      * @param dblDeterministic The Deterministic Increment Component
  192.      * @param sed The Stochastic Diffusion Edge Instance
  193.      * @param sej The Stochastic Jump Edge Instance
  194.      * @param jdeu The Random Unit Realization
  195.      *
  196.      * @throws java.lang.Exception Thrown if the Inputs are Invalid
  197.      */

  198.     public JumpDiffusionEdge (
  199.         final double dblStart,
  200.         final double dblDeterministic,
  201.         final org.drip.measure.realization.StochasticEdgeDiffusion sed,
  202.         final org.drip.measure.realization.StochasticEdgeJump sej,
  203.         final org.drip.measure.realization.JumpDiffusionEdgeUnit jdeu)
  204.         throws java.lang.Exception
  205.     {
  206.         _sed = sed;
  207.         _sej = sej;

  208.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblStart = dblStart) ||
  209.             !org.drip.numerical.common.NumberUtil.IsValid (_dblDeterministic = dblDeterministic) || (null == _sed
  210.                 && null == _sej) || null == (_jdeu = jdeu))
  211.             throw new java.lang.Exception ("JumpDiffusionEdge Constructor => Invalid Inputs");
  212.     }

  213.     /**
  214.      * Retrieve the Edge Time Increment
  215.      *
  216.      * @return The Edge Time Increment
  217.      */

  218.     public double timeIncrement()
  219.     {
  220.         return _jdeu.timeIncrement();
  221.     }

  222.     /**
  223.      * Retrieve the Start Realization
  224.      *
  225.      * @return The Start Realization
  226.      */

  227.     public double start()
  228.     {
  229.         return _dblStart;
  230.     }

  231.     /**
  232.      * Retrieve the Deterministic Component
  233.      *
  234.      * @return The Deterministic Component
  235.      */

  236.     public double deterministic()
  237.     {
  238.         return _dblDeterministic;
  239.     }

  240.     /**
  241.      * Retrieve the Diffusion Stochastic Component
  242.      *
  243.      * @return The Diffusion Stochastic Component
  244.      */

  245.     public double diffusionStochastic()
  246.     {
  247.         return null == _sed ? 0. : _sed.change();
  248.     }

  249.     /**
  250.      * Retrieve the Diffusion Wander Realization
  251.      *
  252.      * @return The Diffusion Wander Realization
  253.      */

  254.     public double diffusionWander()
  255.     {
  256.         return _jdeu.diffusion();
  257.     }

  258.     /**
  259.      * Retrieve the Jump Stochastic Component
  260.      *
  261.      * @return The Jump Stochastic Component
  262.      */

  263.     public double jumpStochastic()
  264.     {
  265.         return null == _sej ? 0. : _sej.target();
  266.     }

  267.     /**
  268.      * Retrieve the Jump Wander Realization
  269.      *
  270.      * @return The Jump Wander Realization
  271.      */

  272.     public double jumpWander()
  273.     {
  274.         return _jdeu.jump();
  275.     }

  276.     /**
  277.      * Retrieve the Finish Realization
  278.      *
  279.      * @return The Finish Realization
  280.      */

  281.     public double finish()
  282.     {
  283.         return null == _sej || !_sej.jumpOccurred() ? _dblStart + _dblDeterministic + diffusionStochastic() :
  284.             _sej.target();
  285.     }

  286.     /**
  287.      * Retrieve the Gross Change
  288.      *
  289.      * @return The Gross Change
  290.      */

  291.     public double grossChange()
  292.     {
  293.         return finish() - _dblStart;
  294.     }

  295.     /**
  296.      * Retrieve the Stochastic Diffusion Edge Instance
  297.      *
  298.      * @return The Stochastic Diffusion Edge Instance
  299.      */

  300.     public org.drip.measure.realization.StochasticEdgeDiffusion stochasticDiffusionEdge()
  301.     {
  302.         return _sed;
  303.     }

  304.     /**
  305.      * Retrieve the Stochastic Jump Edge Instance
  306.      *
  307.      * @return The Stochastic Jump Edge Instance
  308.      */

  309.     public org.drip.measure.realization.StochasticEdgeJump stochasticJumpEdge()
  310.     {
  311.         return _sej;
  312.     }
  313. }