BondRVMeasures.java

  1. package org.drip.analytics.output;

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

  81. /**
  82.  * <i>BondRVMeasures</i> encapsulates the comprehensive set of RV measures calculated for the bond to the
  83.  * appropriate exercise:
  84.  *
  85.  *  <br><br>
  86.  *  <ul>
  87.  *      <li>
  88.  *          Work-out Information
  89.  *      </li>
  90.  *      <li>
  91.  *          Price, Yield, and Yield01
  92.  *      </li>
  93.  *      <li>
  94.  *          Spread Measures: Asset Swap/Credit/G/I/OAS/PECS/TSY/Z
  95.  *      </li>
  96.  *      <li>
  97.  *          Basis Measures: Bond Basis, Credit Basis, Yield Basis
  98.  *      </li>
  99.  *      <li>
  100.  *          Duration Measures: Macaulay/Modified Duration, Convexity
  101.  *      </li>
  102.  *  </ul>
  103.  *
  104.  *  <br><br>
  105.  *  <ul>
  106.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  107.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  108.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/analytics/README.md">Date, Cash Flow, and Cash Flow Period Measure Generation Utilities</a></li>
  109.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/analytics/output/README.md">Period Product Targeted Valuation Measures</a></li>
  110.  *  </ul>
  111.  *
  112.  * @author Lakshmi Krishnamurthy
  113.  */

  114. public class BondRVMeasures {
  115.     private double _dblPECS = java.lang.Double.NaN;
  116.     private double _dblPrice = java.lang.Double.NaN;
  117.     private double _dblGSpread = java.lang.Double.NaN;
  118.     private double _dblISpread = java.lang.Double.NaN;
  119.     private double _dblYield01 = java.lang.Double.NaN;
  120.     private double _dblZSpread = java.lang.Double.NaN;
  121.     private double _dblOASpread = java.lang.Double.NaN;
  122.     private double _dblBondBasis = java.lang.Double.NaN;
  123.     private double _dblConvexity = java.lang.Double.NaN;
  124.     private double _dblTSYSpread = java.lang.Double.NaN;
  125.     private double _dblCreditBasis = java.lang.Double.NaN;
  126.     private org.drip.param.valuation.WorkoutInfo _wi = null;
  127.     private double _dblDiscountMargin = java.lang.Double.NaN;
  128.     private double _dblAssetSwapSpread = java.lang.Double.NaN;
  129.     private double _dblMacaulayDuration = java.lang.Double.NaN;
  130.     private double _dblModifiedDuration = java.lang.Double.NaN;

  131.     /**
  132.      * BondRVMeasures ctr
  133.      *
  134.      * @param dblPrice BondRV Clean Price
  135.      * @param dblBondBasis BondRV Bond Basis
  136.      * @param dblZSpread BondRV Z Spread
  137.      * @param dblGSpread BondRV G Spread
  138.      * @param dblISpread BondRV I Spread
  139.      * @param dblOASpread BondRV OAS
  140.      * @param dblTSYSpread BondRV TSY Spread
  141.      * @param dblDiscountMargin BondRV Asset Swap Spread
  142.      * @param dblAssetSwapSpread BondRV Asset Swap Spread
  143.      * @param dblCreditBasis BondRV Credit Basis
  144.      * @param dblPECS BondRV PECS
  145.      * @param dblYield01 BondRV Yield01
  146.      * @param dblModifiedDuration BondRV Modified Duration
  147.      * @param dblMacaulayDuration BondRV Macaulay Duration
  148.      * @param dblConvexity BondRV Convexity
  149.      * @param wi BondRV work-out info
  150.      *
  151.      * @throws java.lang.Exception Thrown if inputs are invalid
  152.      */

  153.     public BondRVMeasures (
  154.         final double dblPrice,
  155.         final double dblBondBasis,
  156.         final double dblZSpread,
  157.         final double dblGSpread,
  158.         final double dblISpread,
  159.         final double dblOASpread,
  160.         final double dblTSYSpread,
  161.         final double dblDiscountMargin,
  162.         final double dblAssetSwapSpread,
  163.         final double dblCreditBasis,
  164.         final double dblPECS,
  165.         final double dblYield01,
  166.         final double dblModifiedDuration,
  167.         final double dblMacaulayDuration,
  168.         final double dblConvexity,
  169.         final org.drip.param.valuation.WorkoutInfo wi)
  170.         throws java.lang.Exception
  171.     {
  172.         if (null == (_wi = wi)) throw new java.lang.Exception ("BondRVMeasures ctr: Invalid inputs!");

  173.         _dblPECS = dblPECS;
  174.         _dblPrice = dblPrice;
  175.         _dblGSpread = dblGSpread;
  176.         _dblISpread = dblISpread;
  177.         _dblYield01 = dblYield01;
  178.         _dblZSpread = dblZSpread;
  179.         _dblOASpread = dblOASpread;
  180.         _dblBondBasis = dblBondBasis;
  181.         _dblConvexity = dblConvexity;
  182.         _dblTSYSpread = dblTSYSpread;
  183.         _dblCreditBasis = dblCreditBasis;
  184.         _dblDiscountMargin = dblDiscountMargin;
  185.         _dblAssetSwapSpread = dblAssetSwapSpread;
  186.         _dblMacaulayDuration = dblMacaulayDuration;
  187.         _dblModifiedDuration = dblModifiedDuration;
  188.     }

  189.     /**
  190.      * Retrieve the Work-out Info
  191.      *
  192.      * @return Work-out Info
  193.      */

  194.     public org.drip.param.valuation.WorkoutInfo wi()
  195.     {
  196.         return _wi;
  197.     }

  198.     /**
  199.      * Retrieve the PECS
  200.      *
  201.      * @return PECS
  202.      */

  203.     public double pecs()
  204.     {
  205.         return _dblPECS;
  206.     }

  207.     /**
  208.      * Retrieve the Price
  209.      *
  210.      * @return Price
  211.      */

  212.     public double price()
  213.     {
  214.         return _dblPrice;
  215.     }

  216.     /**
  217.      * Retrieve the G Spread
  218.      *
  219.      * @return G Spread
  220.      */

  221.     public double gSpread()
  222.     {
  223.         return _dblGSpread;
  224.     }

  225.     /**
  226.      * Retrieve the I Spread
  227.      *
  228.      * @return I Spread
  229.      */

  230.     public double iSpread()
  231.     {
  232.         return _dblISpread;
  233.     }

  234.     /**
  235.      * Retrieve the Yield01
  236.      *
  237.      * @return Yield01
  238.      */

  239.     public double yield01()
  240.     {
  241.         return _dblYield01;
  242.     }

  243.     /**
  244.      * Retrieve the Z Spread
  245.      *
  246.      * @return Z Spread
  247.      */

  248.     public double zSpread()
  249.     {
  250.         return _dblZSpread;
  251.     }

  252.     /**
  253.      * Retrieve the OAS
  254.      *
  255.      * @return OAS
  256.      */

  257.     public double oas()
  258.     {
  259.         return _dblOASpread;
  260.     }

  261.     /**
  262.      * Retrieve the Bond Basis
  263.      *
  264.      * @return Bond Basis
  265.      */

  266.     public double bondBasis()
  267.     {
  268.         return _dblBondBasis;
  269.     }

  270.     /**
  271.      * Retrieve the Convexity
  272.      *
  273.      * @return Convexity
  274.      */

  275.     public double convexity()
  276.     {
  277.         return _dblConvexity;
  278.     }

  279.     /**
  280.      * Retrieve the TSY Spread
  281.      *
  282.      * @return TSY Spread
  283.      */

  284.     public double tsySpread()
  285.     {
  286.         return _dblTSYSpread;
  287.     }

  288.     /**
  289.      * Retrieve the Credit Basis
  290.      *
  291.      * @return Credit Basis
  292.      */

  293.     public double creditBasis()
  294.     {
  295.         return _dblCreditBasis;
  296.     }

  297.     /**
  298.      * Retrieve the Discount Margin
  299.      *
  300.      * @return Discount Margin
  301.      */

  302.     public double discountMargin()
  303.     {
  304.         return _dblDiscountMargin;
  305.     }

  306.     /**
  307.      * Retrieve the Asset Swap Spread
  308.      *
  309.      * @return Asset Swap Spread
  310.      */

  311.     public double asw()
  312.     {
  313.         return _dblAssetSwapSpread;
  314.     }

  315.     /**
  316.      * Retrieve the Macaulay Duration
  317.      *
  318.      * @return Macaulay Duration
  319.      */

  320.     public double macaulayDuration()
  321.     {
  322.         return _dblMacaulayDuration;
  323.     }

  324.     /**
  325.      * Retrieve the Modified Duration
  326.      *
  327.      * @return Modified Duration
  328.      */

  329.     public double modifiedDuration()
  330.     {
  331.         return _dblModifiedDuration;
  332.     }

  333.     /**
  334.      * Return the state as a measure map
  335.      *
  336.      * @param strPrefix RV Measure name prefix
  337.      *
  338.      * @return Map of the RV measures
  339.      */

  340.     public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> toMap (
  341.         final java.lang.String strPrefix)
  342.     {
  343.         org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> mapRVMeasures = new
  344.             org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double>();

  345.         mapRVMeasures.put (strPrefix + "AssetSwapSpread", _dblAssetSwapSpread);

  346.         mapRVMeasures.put (strPrefix + "ASW", _dblAssetSwapSpread);

  347.         mapRVMeasures.put (strPrefix + "BondBasis", _dblBondBasis);

  348.         mapRVMeasures.put (strPrefix + "Convexity", _dblConvexity);

  349.         mapRVMeasures.put (strPrefix + "CreditBasis", _dblCreditBasis);

  350.         mapRVMeasures.put (strPrefix + "DiscountMargin", _dblDiscountMargin);

  351.         mapRVMeasures.put (strPrefix + "Duration", _dblModifiedDuration);

  352.         mapRVMeasures.put (strPrefix + "GSpread", _dblGSpread);

  353.         mapRVMeasures.put (strPrefix + "ISpread", _dblISpread);

  354.         mapRVMeasures.put (strPrefix + "MacaulayDuration", _dblMacaulayDuration);

  355.         mapRVMeasures.put (strPrefix + "ModifiedDuration", _dblModifiedDuration);

  356.         mapRVMeasures.put (strPrefix + "OAS", _dblOASpread);

  357.         mapRVMeasures.put (strPrefix + "OASpread", _dblOASpread);

  358.         mapRVMeasures.put (strPrefix + "OptionAdjustedSpread", _dblOASpread);

  359.         mapRVMeasures.put (strPrefix + "PECS", _dblPECS);

  360.         mapRVMeasures.put (strPrefix + "Price", _dblPrice);

  361.         mapRVMeasures.put (strPrefix + "TSYSpread", _dblTSYSpread);

  362.         mapRVMeasures.put (strPrefix + "WorkoutDate", (double) _wi.date());

  363.         mapRVMeasures.put (strPrefix + "WorkoutFactor", _wi.factor());

  364.         mapRVMeasures.put (strPrefix + "WorkoutType", (double) _wi.type());

  365.         mapRVMeasures.put (strPrefix + "WorkoutYield", _wi.yield());

  366.         mapRVMeasures.put (strPrefix + "Yield", _wi.yield());

  367.         mapRVMeasures.put (strPrefix + "Yield01", _dblYield01);

  368.         mapRVMeasures.put (strPrefix + "YieldBasis", _dblBondBasis);

  369.         mapRVMeasures.put (strPrefix + "YieldSpread", _dblBondBasis);

  370.         mapRVMeasures.put (strPrefix + "ZSpread", _dblZSpread);

  371.         return mapRVMeasures;
  372.     }
  373. }