ForeignCollateralizedDiscountCurve.java

  1. package org.drip.state.curve;

  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>ForeignCollateralizedDiscountCurve</i> computes the discount factor corresponding to one unit of
  81.  * domestic currency collateralized by a foreign collateral.
  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</a></li>
  87.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/README.md">Latent State Inference and Creation Utilities</a></li>
  88.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/curve/README.md">Basis Spline Based Latent States</a></li>
  89.  *  </ul>
  90.  * <br><br>
  91.  *
  92.  * @author Lakshmi Krishnamurthy
  93.  */

  94. public class ForeignCollateralizedDiscountCurve extends org.drip.state.discount.ExplicitBootDiscountCurve {
  95.     private java.lang.String _strCurrency = null;
  96.     private org.drip.state.fx.FXCurve _fxForward = null;
  97.     private org.drip.state.volatility.VolatilityCurve _vcFX = null;
  98.     private org.drip.state.discount.MergedDiscountForwardCurve _dcCollateralForeign = null;
  99.     private org.drip.state.volatility.VolatilityCurve _vcCollateralForeign = null;
  100.     private org.drip.function.definition.R1ToR1 _r1r1CollateralForeignFXCorrelation = null;

  101.     /**
  102.      * ForeignCollateralizedDiscountCurve constructor
  103.      *
  104.      * @param strCurrency The Currency
  105.      * @param dcCollateralForeign The Collateralized Foreign Discount Curve
  106.      * @param fxForward The FX Forward Curve
  107.      * @param vcCollateralForeign The Foreign Collateral Volatility Curve
  108.      * @param vcFX The FX Volatility Curve
  109.      * @param r1r1CollateralForeignFXCorrelation The FX Foreign Collateral Correlation Curve
  110.      *
  111.      * @throws java.lang.Exception Thrown if the Inputs are invalid
  112.      */

  113.     public ForeignCollateralizedDiscountCurve (
  114.         final java.lang.String strCurrency,
  115.         final org.drip.state.discount.MergedDiscountForwardCurve dcCollateralForeign,
  116.         final org.drip.state.fx.FXCurve fxForward,
  117.         final org.drip.state.volatility.VolatilityCurve vcCollateralForeign,
  118.         final org.drip.state.volatility.VolatilityCurve vcFX,
  119.         final org.drip.function.definition.R1ToR1 r1r1CollateralForeignFXCorrelation)
  120.         throws java.lang.Exception
  121.     {
  122.         super (dcCollateralForeign.epoch().julian(), strCurrency);

  123.         if (null == (_strCurrency = strCurrency) || _strCurrency.isEmpty() || null == (_vcCollateralForeign =
  124.             vcCollateralForeign) || null == (_vcFX = vcFX) || null == (_r1r1CollateralForeignFXCorrelation =
  125.                 r1r1CollateralForeignFXCorrelation) || null == (_dcCollateralForeign = dcCollateralForeign)
  126.                     || null == (_fxForward = fxForward))
  127.             throw new java.lang.Exception ("ForeignCollateralizedDiscountCurve ctr: Invalid Inputs");
  128.     }

  129.     @Override public double df (
  130.         final int iDate)
  131.         throws java.lang.Exception
  132.     {
  133.         return iDate <= _iEpochDate ? 1. : _dcCollateralForeign.df (iDate) * _fxForward.fx (iDate) *
  134.             java.lang.Math.exp (-1. * org.drip.analytics.support.OptionHelper.IntegratedCrossVolQuanto
  135.                 (_vcFX, _vcCollateralForeign, _r1r1CollateralForeignFXCorrelation, _iEpochDate, iDate));
  136.     }

  137.     @Override public double forward (
  138.         final int iDate1,
  139.         final int iDate2)
  140.         throws java.lang.Exception
  141.     {
  142.         if (iDate1 < _iEpochDate || iDate2 < _iEpochDate) return 0.;

  143.         return 365.25 / (iDate2 - iDate1) * java.lang.Math.log (df (iDate1) / df (iDate2));
  144.     }

  145.     @Override public double zero (
  146.         final int iDate)
  147.         throws java.lang.Exception
  148.     {
  149.         if (iDate < _iEpochDate) return 0.;

  150.         return -365.25 / (iDate - _iEpochDate) * java.lang.Math.log (df (iDate));
  151.     }

  152.     @Override public org.drip.state.forward.ForwardRateEstimator forwardRateEstimator (
  153.         final int iDate,
  154.         final org.drip.state.identifier.ForwardLabel fri)
  155.     {
  156.         return null;
  157.     }

  158.     @Override public java.util.Map<java.lang.Integer, java.lang.Double> canonicalTruthness (
  159.         final java.lang.String strLatentQuantificationMetric)
  160.     {
  161.         return null;
  162.     }

  163.     @Override public org.drip.state.nonlinear.FlatForwardDiscountCurve parallelShiftManifestMeasure (
  164.         final java.lang.String strManifestMeasure,
  165.         final double dblShift)
  166.     {
  167.         return null;
  168.     }

  169.     @Override public org.drip.state.nonlinear.FlatForwardDiscountCurve shiftManifestMeasure (
  170.         final int iSpanIndex,
  171.         final java.lang.String strManifestMeasure,
  172.         final double dblShift)
  173.     {
  174.         return null;
  175.     }

  176.     @Override public org.drip.state.discount.ExplicitBootDiscountCurve customTweakManifestMeasure (
  177.         final java.lang.String strManifestMeasure,
  178.         final org.drip.param.definition.ManifestMeasureTweak rvtp)
  179.     {
  180.         return null;
  181.     }

  182.     @Override public org.drip.state.nonlinear.FlatForwardDiscountCurve parallelShiftQuantificationMetric (
  183.         final double dblShift)
  184.     {
  185.         return null;
  186.     }

  187.     @Override public org.drip.analytics.definition.Curve customTweakQuantificationMetric (
  188.         final org.drip.param.definition.ManifestMeasureTweak rvtp)
  189.     {
  190.         return null;
  191.     }

  192.     @Override public org.drip.state.nonlinear.FlatForwardDiscountCurve createBasisRateShiftedCurve (
  193.         final int[] aiDate,
  194.         final double[] adblBasis)
  195.     {
  196.         return null;
  197.     }

  198.     @Override public java.lang.String latentStateQuantificationMetric()
  199.     {
  200.         return org.drip.analytics.definition.LatentStateStatic.DISCOUNT_QM_ZERO_RATE;
  201.     }

  202.     @Override public org.drip.numerical.differentiation.WengertJacobian jackDDFDManifestMeasure (
  203.         final int iDate,
  204.         final java.lang.String strManifestMeasure)
  205.     {
  206.         return null;
  207.     }

  208.     @Override public boolean setNodeValue (
  209.         final int iNodeIndex,
  210.         final double dblValue)
  211.     {
  212.         return true;
  213.     }

  214.     @Override public boolean bumpNodeValue (
  215.         final int iNodeIndex,
  216.         final double dblValue)
  217.     {
  218.         return true;
  219.     }

  220.     @Override public boolean setFlatValue (
  221.         final double dblValue)
  222.     {
  223.         return true;
  224.     }
  225. }