OptionComponent.java

  1. package org.drip.product.option;

  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>OptionComponent</i> extends ComponentMarketParamRef and provides the following methods:
  81.  *
  82.  * <br><br>
  83.  *  <ul>
  84.  *      <li>
  85.  *          Get the component's initial notional, notional, and coupon.
  86.  *      </li>
  87.  *      <li>
  88.  *          Get the Effective date, Maturity date, First Coupon Date.
  89.  *      </li>
  90.  *      <li>
  91.  *          Set the market curves - discount, TSY, forward, and Credit curves.
  92.  *      </li>
  93.  *      <li>
  94.  *          Retrieve the component's settlement parameters.
  95.  *      </li>
  96.  *      <li>
  97.  *          Value the component using standard/custom market parameters.
  98.  *      </li>
  99.  *      <li>
  100.  *          Retrieve the component's named measures and named measure values.
  101.  *      </li>
  102.  *      <li>
  103.  *          Retrieve the Underlying Fixed Income Product, Day Count, Strike, Calendar, and Manifest Measure.
  104.  *      </li>
  105.  *  </ul>
  106.  *
  107.  * <br><br>
  108.  *  <ul>
  109.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  110.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  111.  *      <li><b>Project</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/README.md">Product Components/Baskets for Credit, FRA, FX, Govvie, Rates, and Option AssetClasses</a></li>
  112.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/option/README.md">Options on Fixed Income Components</a></li>
  113.  *  </ul>
  114.  * <br><br>
  115.  *
  116.  * @author Lakshmi Krishnamurthy
  117.  */

  118. public abstract class OptionComponent extends org.drip.product.definition.CalibratableComponent
  119. {
  120.     private java.lang.String _strCode = "";
  121.     private java.lang.String _strName = "";
  122.     private double _dblStrike = java.lang.Double.NaN;
  123.     private java.lang.String _strManifestMeasure = "";
  124.     private double _dblNotional = java.lang.Double.NaN;
  125.     private org.drip.product.definition.Component _comp = null;
  126.     private org.drip.param.valuation.CashSettleParams _csp = null;
  127.     private org.drip.product.params.LastTradingDateSetting _ltds = null;

  128.     protected OptionComponent (
  129.         final java.lang.String strName,
  130.         final org.drip.product.definition.Component comp,
  131.         final java.lang.String strManifestMeasure,
  132.         final double dblStrike,
  133.         final double dblNotional,
  134.         final org.drip.product.params.LastTradingDateSetting ltds,
  135.         final org.drip.param.valuation.CashSettleParams csp)
  136.         throws java.lang.Exception
  137.     {
  138.         if (null == (_strName = strName) || _strName.isEmpty() || null == (_comp = comp) || null ==
  139.             (_strManifestMeasure = strManifestMeasure) || _strManifestMeasure.isEmpty() ||
  140.                 !org.drip.numerical.common.NumberUtil.IsValid (_dblStrike = dblStrike) ||
  141.                     !org.drip.numerical.common.NumberUtil.IsValid (_dblNotional = dblNotional))
  142.             throw new java.lang.Exception ("OptionComponent ctr: Invalid Inputs");

  143.         _csp = csp;
  144.         _ltds = ltds;
  145.     }

  146.     /**
  147.      * Retrieve the Underlying Component
  148.      *
  149.      * @return The Underlying Component
  150.      */

  151.     public org.drip.product.definition.Component underlying()
  152.     {
  153.         return _comp;
  154.     }

  155.     /**
  156.      * Retrieve the Manifest Measure on which the Option's Strike is quoted
  157.      *
  158.      * @return The Manifest Measure on which the Option's Strike is quoted
  159.      */

  160.     public java.lang.String manifestMeasure()
  161.     {
  162.         return _strManifestMeasure;
  163.     }

  164.     /**
  165.      * Retrieve the Strike
  166.      *
  167.      * @return The Strike
  168.      */

  169.     public double strike()
  170.     {
  171.         return _dblStrike;
  172.     }

  173.     /**
  174.      * Retrieve the Notional
  175.      *
  176.      * @return The Notional
  177.      */

  178.     public double notional()
  179.     {
  180.         return _dblNotional;
  181.     }

  182.     /**
  183.      * Retrieve the Option Exercise Date
  184.      *
  185.      * @return The Option Exercise Date
  186.      */

  187.     public org.drip.analytics.date.JulianDate exerciseDate()
  188.     {
  189.         return _comp.effectiveDate();
  190.     }

  191.     /**
  192.      * Retrieve the Option Last Trading Date Setting
  193.      *
  194.      * @return The Option Last Trading Date Setting
  195.      */

  196.     public org.drip.product.params.LastTradingDateSetting lastTradingDateSetting()
  197.     {
  198.         return _ltds;
  199.     }

  200.     @Override public void setPrimaryCode (
  201.         final java.lang.String strCode)
  202.     {
  203.         _strCode = strCode;
  204.     }

  205.     @Override public java.lang.String primaryCode()
  206.     {
  207.         return _strCode;
  208.     }

  209.     @Override public java.lang.String name()
  210.     {
  211.         return _strName;
  212.     }

  213.     @Override public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.String> couponCurrency()
  214.     {
  215.         return _comp.couponCurrency();
  216.     }

  217.     @Override public java.lang.String payCurrency()
  218.     {
  219.         return _comp.payCurrency();
  220.     }

  221.     @Override public java.lang.String principalCurrency()
  222.     {
  223.         return _comp.payCurrency();
  224.     }

  225.     @Override public org.drip.analytics.date.JulianDate effectiveDate()
  226.     {
  227.         return null;
  228.     }

  229.     @Override public org.drip.analytics.date.JulianDate maturityDate()
  230.     {
  231.         return exerciseDate();
  232.     }

  233.     @Override public org.drip.analytics.date.JulianDate firstCouponDate()
  234.     {
  235.         return _comp.effectiveDate();
  236.     }

  237.     @Override public double initialNotional()
  238.     {
  239.         return _dblNotional;
  240.     }

  241.     @Override public double notional (
  242.         final int dblDate1)
  243.     {
  244.         return _dblNotional;
  245.     }

  246.     @Override public double notional (
  247.         final int dblDate1,
  248.         final int dblDate2)
  249.     {
  250.         return _dblNotional;
  251.     }

  252.     @Override public int freq()
  253.     {
  254.         return _comp.freq();
  255.     }

  256.     @Override public org.drip.state.identifier.EntityCDSLabel creditLabel()
  257.     {
  258.         return _comp.creditLabel();
  259.     }

  260.     @Override public
  261.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.ForwardLabel>
  262.             forwardLabel()
  263.     {
  264.         return _comp.forwardLabel();
  265.     }

  266.     @Override public
  267.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.OTCFixFloatLabel>
  268.             otcFixFloatLabel()
  269.     {
  270.         return _comp.otcFixFloatLabel();
  271.     }

  272.     @Override public org.drip.state.identifier.FundingLabel fundingLabel()
  273.     {
  274.         return _comp.fundingLabel();
  275.     }

  276.     @Override public org.drip.state.identifier.GovvieLabel govvieLabel()
  277.     {
  278.         return _comp.govvieLabel();
  279.     }

  280.     @Override public org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.FXLabel>
  281.         fxLabel()
  282.     {
  283.         return _comp.fxLabel();
  284.     }

  285.     @Override public
  286.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.VolatilityLabel>
  287.             volatilityLabel()
  288.     {
  289.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.ForwardLabel>
  290.             mapForwardLabel = forwardLabel();

  291.         if (null == mapForwardLabel || 0 == mapForwardLabel.size()) return null;

  292.         org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.VolatilityLabel>
  293.             mapVolatilityLabel = new
  294.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.VolatilityLabel>();

  295.         for (java.util.Map.Entry<java.lang.String, org.drip.state.identifier.ForwardLabel> forwardLabelEntry
  296.             : mapForwardLabel.entrySet())
  297.             mapVolatilityLabel.put (forwardLabelEntry.getKey(),
  298.                 org.drip.state.identifier.VolatilityLabel.Standard (forwardLabelEntry.getValue()));

  299.         return mapVolatilityLabel;
  300.     }

  301.     @Override public org.drip.analytics.output.CompositePeriodCouponMetrics couponMetrics (
  302.         final int iAccrualEndDate,
  303.         final org.drip.param.valuation.ValuationParams valParams,
  304.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs)
  305.     {
  306.         return null;
  307.     }

  308.     @Override public java.util.List<org.drip.analytics.cashflow.CompositePeriod> couponPeriods()
  309.     {
  310.         return null;
  311.     }

  312.     @Override public org.drip.param.valuation.CashSettleParams cashSettleParams()
  313.     {
  314.         return _csp;
  315.     }

  316.     @Override public org.drip.product.calib.ProductQuoteSet calibQuoteSet (
  317.         final org.drip.state.representation.LatentStateSpecification[] aLSS)
  318.     {
  319.         try {
  320.             return new org.drip.product.calib.VolatilityProductQuoteSet (aLSS);
  321.         } catch (java.lang.Exception e) {
  322.             e.printStackTrace();
  323.         }

  324.         return null;
  325.     }

  326.     @Override public org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.Double> calibMeasures (
  327.         final org.drip.param.valuation.ValuationParams valParams,
  328.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  329.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  330.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  331.     {
  332.         return null;
  333.     }

  334.     @Override public org.drip.state.estimator.PredictorResponseWeightConstraint forwardPRWC (
  335.         final org.drip.param.valuation.ValuationParams valParams,
  336.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  337.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  338.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  339.         final org.drip.product.calib.ProductQuoteSet pqs)
  340.     {
  341.         return null;
  342.     }

  343.     @Override public org.drip.state.estimator.PredictorResponseWeightConstraint fundingPRWC (
  344.         final org.drip.param.valuation.ValuationParams valParams,
  345.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  346.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  347.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  348.         final org.drip.product.calib.ProductQuoteSet pqs)
  349.     {
  350.         return null;
  351.     }

  352.     @Override public org.drip.state.estimator.PredictorResponseWeightConstraint fundingForwardPRWC (
  353.         final org.drip.param.valuation.ValuationParams valParams,
  354.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  355.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  356.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  357.         final org.drip.product.calib.ProductQuoteSet pqs)
  358.     {
  359.         return null;
  360.     }

  361.     @Override public org.drip.state.estimator.PredictorResponseWeightConstraint fxPRWC (
  362.         final org.drip.param.valuation.ValuationParams valParams,
  363.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  364.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  365.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  366.         final org.drip.product.calib.ProductQuoteSet pqs)
  367.     {
  368.         return null;
  369.     }

  370.     @Override public org.drip.state.estimator.PredictorResponseWeightConstraint govviePRWC (
  371.         final org.drip.param.valuation.ValuationParams valParams,
  372.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  373.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  374.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  375.         final org.drip.product.calib.ProductQuoteSet pqs)
  376.     {
  377.         return null;
  378.     }

  379.     @Override public org.drip.numerical.differentiation.WengertJacobian jackDDirtyPVDManifestMeasure (
  380.         final org.drip.param.valuation.ValuationParams valParams,
  381.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  382.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  383.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  384.     {
  385.         return null;
  386.     }

  387.     @Override public org.drip.numerical.differentiation.WengertJacobian manifestMeasureDFMicroJack (
  388.         final java.lang.String strMainfestMeasure,
  389.         final org.drip.param.valuation.ValuationParams valParams,
  390.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  391.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  392.         final org.drip.param.valuation.ValuationCustomizationParams vcp)
  393.     {
  394.         return null;
  395.     }
  396. }