ScenarioFXCurveBuilder.java

  1. package org.drip.state.creator;

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

  78. /**
  79.  * <i>ScenarioFXCurveBuilder</i> implements the construction of the scenario FX Curve using the input FX
  80.  * Curve instruments.
  81.  *
  82.  *  <br><br>
  83.  *  <ul>
  84.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  85.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  86.  *      <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>
  87.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/state/creator/README.md">Scenario State Curve/Surface Builders</a></li>
  88.  *  </ul>
  89.  * <br><br>
  90.  *
  91.  * @author Lakshmi Krishnamurthy
  92.  */

  93. public class ScenarioFXCurveBuilder {

  94.     /**
  95.      * Build the Shape Preserving FX Curve using the Custom Parameters
  96.      *
  97.      * @param llsc The Linear Latent State Calibrator Instance
  98.      * @param aStretchSpec Array of the Latent State Stretches
  99.      * @param cp The FX Currency Pair
  100.      * @param valParams Valuation Parameters
  101.      * @param pricerParams Pricer Parameters
  102.      * @param csqs Market Parameters
  103.      * @param vcp Quoting Parameters
  104.      * @param dblEpochResponse The Starting Response Value
  105.      *
  106.      * @return Instance of the Shape Preserving Discount Curve
  107.      */

  108.     public static final org.drip.state.fx.FXCurve ShapePreservingFXCurve (
  109.         final org.drip.state.inference.LinearLatentStateCalibrator llsc,
  110.         final org.drip.state.inference.LatentStateStretchSpec[] aStretchSpec,
  111.         final org.drip.product.params.CurrencyPair cp,
  112.         final org.drip.param.valuation.ValuationParams valParams,
  113.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  114.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  115.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  116.         final double dblEpochResponse)
  117.     {
  118.         if (null == llsc) return null;

  119.         try {
  120.             org.drip.state.fx.FXCurve fxCurve = new org.drip.state.curve.BasisSplineFXForward (cp,
  121.                 llsc.calibrateSpan (aStretchSpec, dblEpochResponse, valParams, pricerParams, vcp, csqs));

  122.             return fxCurve.setCCIS (new org.drip.analytics.input.LatentStateShapePreservingCCIS (llsc,
  123.                 aStretchSpec, valParams, pricerParams, vcp, csqs)) ? fxCurve : null;
  124.         } catch (java.lang.Exception e) {
  125.             e.printStackTrace();
  126.         }

  127.         return null;
  128.     }

  129.     /**
  130.      * Construct an instance of the Shape Preserver of the desired basis type, using the specified basis set
  131.      *  builder parameters.
  132.      *
  133.      * @param strName Curve Name
  134.      * @param cp The FX Currency Pair
  135.      * @param valParams Valuation Parameters
  136.      * @param pricerParams Pricer Parameters
  137.      * @param csqs Market Parameters
  138.      * @param vcp Quoting Parameters
  139.      * @param aCalibComp Array of Calibration Components
  140.      * @param strManifestMeasure The Calibration Manifest Measure
  141.      * @param adblQuote Array of Calibration Quotes
  142.      * @param dblEpochResponse The Stretch Start DF
  143.      * @param scbc Segment Custom Builder Control Parameters
  144.      *
  145.      * @return Instance of the Shape Preserver of the desired basis type
  146.      */

  147.     public static final org.drip.state.fx.FXCurve ShapePreservingFXCurve (
  148.         final java.lang.String strName,
  149.         final org.drip.product.params.CurrencyPair cp,
  150.         final org.drip.param.valuation.ValuationParams valParams,
  151.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  152.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  153.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  154.         final org.drip.product.definition.CalibratableComponent[] aCalibComp,
  155.         final java.lang.String strManifestMeasure,
  156.         final double[] adblQuote,
  157.         final double dblEpochResponse,
  158.         final org.drip.spline.params.SegmentCustomBuilderControl scbc)
  159.     {
  160.         if (null == strName || strName.isEmpty() || null == valParams || null == scbc || null ==
  161.             strManifestMeasure || strManifestMeasure.isEmpty())
  162.             return null;

  163.         int iNumQuote = null == adblQuote ? 0 : adblQuote.length;
  164.         int iNumComp = null == aCalibComp ? 0 : aCalibComp.length;

  165.         if (0 == iNumComp || iNumComp != iNumQuote) return null;

  166.         try {
  167.             org.drip.state.identifier.FXLabel fxLabel = null;

  168.             if (aCalibComp[0] instanceof org.drip.product.rates.DualStreamComponent)
  169.                 fxLabel = ((org.drip.product.rates.DualStreamComponent)
  170.                     aCalibComp[0]).derivedStream().fxLabel();
  171.             else {
  172.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.FXLabel>
  173.                     mapFXLabel = aCalibComp[0].fxLabel();

  174.                 if (null != mapFXLabel && 0 != mapFXLabel.size()) fxLabel = mapFXLabel.get ("DERIVED");
  175.             }

  176.             org.drip.state.representation.LatentStateSpecification[] aLSS = new
  177.                 org.drip.state.representation.LatentStateSpecification[] {new
  178.                     org.drip.state.representation.LatentStateSpecification
  179.                         (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FX,
  180.                             org.drip.analytics.definition.LatentStateStatic.FX_QM_FORWARD_OUTRIGHT,
  181.                                 fxLabel)};

  182.             org.drip.state.inference.LatentStateSegmentSpec[] aSegmentSpec = new
  183.                 org.drip.state.inference.LatentStateSegmentSpec[iNumComp];

  184.             for (int i = 0; i < iNumComp; ++i) {
  185.                 org.drip.product.calib.ProductQuoteSet pqs = aCalibComp[i].calibQuoteSet (aLSS);

  186.                 if (null == pqs || !pqs.set (strManifestMeasure, adblQuote[i])) return null;

  187.                 aSegmentSpec[i] = new org.drip.state.inference.LatentStateSegmentSpec (aCalibComp[i], pqs);
  188.             }

  189.             org.drip.state.inference.LatentStateStretchSpec[] aStretchSpec = new
  190.                 org.drip.state.inference.LatentStateStretchSpec[] {new
  191.                     org.drip.state.inference.LatentStateStretchSpec (strName, aSegmentSpec)};

  192.             org.drip.state.inference.LinearLatentStateCalibrator llsc = new
  193.                 org.drip.state.inference.LinearLatentStateCalibrator (scbc,
  194.                     org.drip.spline.stretch.BoundarySettings.FinancialStandard(),
  195.                         org.drip.spline.stretch.MultiSegmentSequence.CALIBRATE, null, null);

  196.             return ShapePreservingFXCurve (llsc, aStretchSpec, cp, valParams, pricerParams, csqs, vcp,
  197.                 dblEpochResponse);
  198.         } catch (java.lang.Exception e) {
  199.             e.printStackTrace();
  200.         }

  201.         return null;
  202.     }

  203.     /**
  204.      * Construct an instance of the Shape Preserver of the desired basis type, using the specified basis set
  205.      *  builder parameters.
  206.      *
  207.      * @param strName Curve Name
  208.      * @param cp The FX Currency Pair
  209.      * @param valParams Valuation Parameters
  210.      * @param pricerParams Pricer Parameters
  211.      * @param csqs Market Parameters
  212.      * @param vcp Quoting Parameters
  213.      * @param strBasisType The Basis Type
  214.      * @param fsbp The Function Set Basis Parameters
  215.      * @param aCalibComp Array of Calibration Components
  216.      * @param strManifestMeasure The Calibration Manifest Measure
  217.      * @param adblQuote Array of Calibration Quotes
  218.      * @param dblEpochResponse The Stretch Start DF
  219.      *
  220.      * @return Instance of the Shape Preserver of the desired basis type
  221.      */

  222.     public static final org.drip.state.fx.FXCurve ShapePreservingFXCurve (
  223.         final java.lang.String strName,
  224.         final org.drip.product.params.CurrencyPair cp,
  225.         final org.drip.param.valuation.ValuationParams valParams,
  226.         final org.drip.param.pricer.CreditPricerParams pricerParams,
  227.         final org.drip.param.market.CurveSurfaceQuoteContainer csqs,
  228.         final org.drip.param.valuation.ValuationCustomizationParams vcp,
  229.         final java.lang.String strBasisType,
  230.         final org.drip.spline.basis.FunctionSetBuilderParams fsbp,
  231.         final org.drip.product.definition.CalibratableComponent[] aCalibComp,
  232.         final java.lang.String strManifestMeasure,
  233.         final double[] adblQuote,
  234.         final double dblEpochResponse)
  235.     {
  236.         if (null == strName || strName.isEmpty() || null == strBasisType || strBasisType.isEmpty() || null ==
  237.             valParams || null == fsbp || null == strManifestMeasure || strManifestMeasure.isEmpty())
  238.             return null;

  239.         int iNumQuote = null == adblQuote ? 0 : adblQuote.length;
  240.         int iNumComp = null == aCalibComp ? 0 : aCalibComp.length;

  241.         if (0 == iNumComp || iNumComp != iNumQuote) return null;

  242.         try {
  243.             org.drip.state.identifier.FXLabel fxLabel = null;

  244.             if (aCalibComp[0] instanceof org.drip.product.rates.DualStreamComponent)
  245.                 fxLabel = ((org.drip.product.rates.DualStreamComponent)
  246.                     aCalibComp[0]).derivedStream().fxLabel();
  247.             else {
  248.                 org.drip.analytics.support.CaseInsensitiveTreeMap<org.drip.state.identifier.FXLabel>
  249.                     mapFXLabel = aCalibComp[0].fxLabel();

  250.                 if (null != mapFXLabel && 0 != mapFXLabel.size()) fxLabel = mapFXLabel.get ("DERIVED");
  251.             }

  252.             org.drip.state.representation.LatentStateSpecification[] aLSS = new
  253.                 org.drip.state.representation.LatentStateSpecification[] {new
  254.                     org.drip.state.representation.LatentStateSpecification
  255.                         (org.drip.analytics.definition.LatentStateStatic.LATENT_STATE_FX,
  256.                             org.drip.analytics.definition.LatentStateStatic.FX_QM_FORWARD_OUTRIGHT,
  257.                                 fxLabel)};

  258.             org.drip.state.inference.LatentStateSegmentSpec[] aSegmentSpec = new
  259.                 org.drip.state.inference.LatentStateSegmentSpec[iNumComp];

  260.             for (int i = 0; i < iNumComp; ++i) {
  261.                 org.drip.product.calib.ProductQuoteSet pqs = aCalibComp[i].calibQuoteSet (aLSS);

  262.                 if (null == pqs || !pqs.set (strManifestMeasure, adblQuote[i])) return null;

  263.                 aSegmentSpec[i] = new org.drip.state.inference.LatentStateSegmentSpec (aCalibComp[i], pqs);
  264.             }

  265.             org.drip.state.inference.LatentStateStretchSpec[] aStretchSpec = new
  266.                 org.drip.state.inference.LatentStateStretchSpec[] {new
  267.                     org.drip.state.inference.LatentStateStretchSpec (strName, aSegmentSpec)};

  268.             org.drip.state.inference.LinearLatentStateCalibrator llsc = new
  269.                 org.drip.state.inference.LinearLatentStateCalibrator (new
  270.                     org.drip.spline.params.SegmentCustomBuilderControl (strBasisType, fsbp,
  271.                         org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), new
  272.                             org.drip.spline.params.ResponseScalingShapeControl (true, new
  273.                                 org.drip.function.r1tor1.QuadraticRationalShapeControl (0.)), null),
  274.                                     org.drip.spline.stretch.BoundarySettings.FinancialStandard(),
  275.                                         org.drip.spline.stretch.MultiSegmentSequence.CALIBRATE, null, null);

  276.             return ShapePreservingFXCurve (llsc, aStretchSpec, cp, valParams, pricerParams, csqs, vcp,
  277.                 dblEpochResponse);
  278.         } catch (java.lang.Exception e) {
  279.             e.printStackTrace();
  280.         }

  281.         return null;
  282.     }

  283.     /**
  284.      * Construct an Instance of the Shape Preserver of the Cubic Polynomial Type, using the Specified Basis
  285.      *  Set Builder Parameters.
  286.      *
  287.      * @param strName Curve Name
  288.      * @param cp The FX Currency Pair
  289.      * @param iSpotDate Spot Date
  290.      * @param aComp Array of Calibration Components
  291.      * @param adblQuote Array of Calibration Quotes
  292.      * @param strManifestMeasure The Calibration Manifest Measure
  293.      * @param dblFXSpot The FX Spot
  294.      *
  295.      * @return Instance of the Shape Preserver of the Cubic Polynomial Type
  296.      */

  297.     public static final org.drip.state.fx.FXCurve CubicPolyShapePreserver (
  298.         final java.lang.String strName,
  299.         final org.drip.product.params.CurrencyPair cp,
  300.         final int iSpotDate,
  301.         final org.drip.product.definition.CalibratableComponent[] aComp,
  302.         final double[] adblQuote,
  303.         final java.lang.String strManifestMeasure,
  304.         final double dblFXSpot)
  305.     {
  306.         try {
  307.             return ShapePreservingFXCurve (strName, cp, org.drip.param.valuation.ValuationParams.Spot
  308.                 (iSpotDate), null, null, null,
  309.                     org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL, new
  310.                         org.drip.spline.basis.PolynomialFunctionSetParams (4), aComp, strManifestMeasure,
  311.                             adblQuote, dblFXSpot);
  312.         } catch (java.lang.Exception e) {
  313.             e.printStackTrace();
  314.         }

  315.         return null;
  316.     }

  317.     /**
  318.      * Create an Instance of the Custom Splined FX Forward Curve
  319.      *
  320.      * @param strName Curve Name
  321.      * @param dtStart The Tenor Start Date
  322.      * @param cp The Currency Pair
  323.      * @param astrTenor Array of the Tenors
  324.      * @param adblFXForward Array of the FX Forwards
  325.      * @param scbc The Segment Custom Builder Control
  326.      * @param dblFXSpot FX Spot
  327.      *
  328.      * @return The Instance of the FX Forward Curve
  329.      */

  330.     public static final org.drip.state.fx.FXCurve CustomSplineCurve (
  331.         final java.lang.String strName,
  332.         final org.drip.analytics.date.JulianDate dtStart,
  333.         final org.drip.product.params.CurrencyPair cp,
  334.         final java.lang.String[] astrTenor,
  335.         final double[] adblFXForward,
  336.         final org.drip.spline.params.SegmentCustomBuilderControl scbc,
  337.         final double dblFXSpot)
  338.     {
  339.         if (null == strName || strName.isEmpty() || null == astrTenor || null == dtStart ||
  340.             !org.drip.numerical.common.NumberUtil.IsValid (dblFXSpot))
  341.             return null;

  342.         int iNumTenor = astrTenor.length;

  343.         if (0 == iNumTenor) return null;

  344.         int[] aiBasisPredictorOrdinate = new int[iNumTenor + 1];
  345.         double[] adblBasisResponseValue = new double[iNumTenor + 1];
  346.         org.drip.spline.params.SegmentCustomBuilderControl[] aSCBC = new
  347.             org.drip.spline.params.SegmentCustomBuilderControl[iNumTenor];

  348.         for (int i = 0; i <= iNumTenor; ++i) {
  349.             if (0 != i) {
  350.                 java.lang.String strTenor = astrTenor[i - 1];

  351.                 if (null == strTenor || strTenor.isEmpty()) return null;

  352.                 org.drip.analytics.date.JulianDate dtMaturity = dtStart.addTenor (strTenor);

  353.                 if (null == dtMaturity) return null;

  354.                 aiBasisPredictorOrdinate[i] = dtMaturity.julian();
  355.             } else
  356.                 aiBasisPredictorOrdinate[i] = dtStart.julian();

  357.             adblBasisResponseValue[i] = 0 == i ? dblFXSpot : adblFXForward[i - 1];

  358.             if (0 != i) aSCBC[i - 1] = scbc;
  359.         }

  360.         try {
  361.             return new org.drip.state.curve.BasisSplineFXForward (cp, new
  362.                 org.drip.spline.grid.OverlappingStretchSpan
  363.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.CreateCalibratedStretchEstimator
  364.                         (strName, aiBasisPredictorOrdinate, adblBasisResponseValue, aSCBC, null,
  365.                             org.drip.spline.stretch.BoundarySettings.NaturalStandard(),
  366.                                 org.drip.spline.stretch.MultiSegmentSequence.CALIBRATE)));
  367.         } catch (java.lang.Exception e) {
  368.             e.printStackTrace();
  369.         }

  370.         return null;
  371.     }

  372.     /**
  373.      * Create an Instance of the Cubic Polynomial Splined FX Forward Curve
  374.      *
  375.      * @param strName Curve Name
  376.      * @param dtStart The Tenor Start Date
  377.      * @param cp The Currency Pair
  378.      * @param astrTenor Array of the Tenors
  379.      * @param adblFXForward Array of the FX Forwards
  380.      * @param dblFXSpot FX Spot
  381.      *
  382.      * @return The Instance of the FX Forward Curve
  383.      */

  384.     public static final org.drip.state.fx.FXCurve CubicPolynomialCurve (
  385.         final java.lang.String strName,
  386.         final org.drip.analytics.date.JulianDate dtStart,
  387.         final org.drip.product.params.CurrencyPair cp,
  388.         final java.lang.String[] astrTenor,
  389.         final double[] adblFXForward,
  390.         final double dblFXSpot)
  391.     {
  392.         try {
  393.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  394.                 org.drip.spline.params.SegmentCustomBuilderControl
  395.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL, new
  396.                         org.drip.spline.basis.PolynomialFunctionSetParams (4),
  397.                             org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  398.                                 dblFXSpot);
  399.         } catch (java.lang.Exception e) {
  400.             e.printStackTrace();
  401.         }

  402.         return null;
  403.     }

  404.     /**
  405.      * Create an Instance of the Quartic Polynomial Splined FX Forward Curve
  406.      *
  407.      * @param strName Curve Name
  408.      * @param dtStart The Tenor Start Date
  409.      * @param cp The Currency Pair
  410.      * @param astrTenor Array of the Tenors
  411.      * @param adblFXForward Array of the FX Forwards
  412.      * @param dblFXSpot FX Spot
  413.      *
  414.      * @return The Instance of the FX Forward Curve
  415.      */

  416.     public static final org.drip.state.fx.FXCurve QuarticPolynomialCurve (
  417.         final java.lang.String strName,
  418.         final org.drip.analytics.date.JulianDate dtStart,
  419.         final org.drip.product.params.CurrencyPair cp,
  420.         final java.lang.String[] astrTenor,
  421.         final double[] adblFXForward,
  422.         final double dblFXSpot)
  423.     {
  424.         try {
  425.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  426.                 org.drip.spline.params.SegmentCustomBuilderControl
  427.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_POLYNOMIAL, new
  428.                         org.drip.spline.basis.PolynomialFunctionSetParams (5),
  429.                             org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  430.                                 dblFXSpot);
  431.         } catch (java.lang.Exception e) {
  432.             e.printStackTrace();
  433.         }

  434.         return null;
  435.     }

  436.     /**
  437.      * Create an Instance of the Kaklis-Pandelis Splined FX Forward Curve
  438.      *
  439.      * @param strName Curve Name
  440.      * @param dtStart The Tenor Start Date
  441.      * @param cp The Currency Pair
  442.      * @param astrTenor Array of the Tenors
  443.      * @param adblFXForward Array of the FX Forwards
  444.      * @param dblFXSpot FX Spot
  445.      *
  446.      * @return The Instance of the FX Forward Curve
  447.      */

  448.     public static final org.drip.state.fx.FXCurve KaklisPandelisCurve (
  449.         final java.lang.String strName,
  450.         final org.drip.analytics.date.JulianDate dtStart,
  451.         final org.drip.product.params.CurrencyPair cp,
  452.         final java.lang.String[] astrTenor,
  453.         final double[] adblFXForward,
  454.         final double dblFXSpot)
  455.     {
  456.         try {
  457.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  458.                 org.drip.spline.params.SegmentCustomBuilderControl
  459.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_KAKLIS_PANDELIS, new
  460.                         org.drip.spline.basis.KaklisPandelisSetParams (2),
  461.                             org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  462.                                 dblFXSpot);
  463.         } catch (java.lang.Exception e) {
  464.             e.printStackTrace();
  465.         }

  466.         return null;
  467.     }

  468.     /**
  469.      * Create an Instance of the KLK Hyperbolic Splined FX Forward Curve
  470.      *
  471.      * @param strName Curve Name
  472.      * @param dtStart The Tenor Start Date
  473.      * @param cp The Currency Pair
  474.      * @param astrTenor Array of the Tenors
  475.      * @param adblFXForward Array of the FX Forwards
  476.      * @param dblFXSpot FX Spot
  477.      * @param dblTension The Tension Parameter
  478.      *
  479.      * @return The Instance of the FX Forward Curve
  480.      */

  481.     public static final org.drip.state.fx.FXCurve KLKHyperbolicCurve (
  482.         final java.lang.String strName,
  483.         final org.drip.analytics.date.JulianDate dtStart,
  484.         final org.drip.product.params.CurrencyPair cp,
  485.         final java.lang.String[] astrTenor,
  486.         final double[] adblFXForward,
  487.         final double dblFXSpot,
  488.         final double dblTension)
  489.     {
  490.         try {
  491.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  492.                 org.drip.spline.params.SegmentCustomBuilderControl
  493.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_KLK_HYPERBOLIC_TENSION,
  494.                         new org.drip.spline.basis.ExponentialTensionSetParams (dblTension),
  495.                             org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  496.                                 dblFXSpot);
  497.         } catch (java.lang.Exception e) {
  498.             e.printStackTrace();
  499.         }

  500.         return null;
  501.     }

  502.     /**
  503.      * Create an Instance of the KLK Rational Linear Splined FX Forward Curve
  504.      *
  505.      * @param strName Curve Name
  506.      * @param dtStart The Tenor Start Date
  507.      * @param cp The Currency Pair
  508.      * @param astrTenor Array of the Tenors
  509.      * @param adblFXForward Array of the FX Forwards
  510.      * @param dblFXSpot FX Spot
  511.      * @param dblTension The Tension Parameter
  512.      *
  513.      * @return The Instance of the FX Forward Curve
  514.      */

  515.     public static final org.drip.state.fx.FXCurve KLKRationalLinearCurve (
  516.         final java.lang.String strName,
  517.         final org.drip.analytics.date.JulianDate dtStart,
  518.         final org.drip.product.params.CurrencyPair cp,
  519.         final java.lang.String[] astrTenor,
  520.         final double[] adblFXForward,
  521.         final double dblFXSpot,
  522.         final double dblTension)
  523.     {
  524.         try {
  525.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  526.                 org.drip.spline.params.SegmentCustomBuilderControl
  527.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_KLK_RATIONAL_LINEAR_TENSION,
  528.                 new org.drip.spline.basis.ExponentialTensionSetParams (dblTension),
  529.                     org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  530.                         dblFXSpot);
  531.         } catch (java.lang.Exception e) {
  532.             e.printStackTrace();
  533.         }

  534.         return null;
  535.     }

  536.     /**
  537.      * Create an Instance of the KLK Rational Quadratic Splined FX Forward Curve
  538.      *
  539.      * @param strName Curve Name
  540.      * @param dtStart The Tenor Start Date
  541.      * @param cp The Currency Pair
  542.      * @param astrTenor Array of the Tenors
  543.      * @param adblFXForward Array of the FX Forwards
  544.      * @param dblFXSpot FX Spot
  545.      * @param dblTension The Tension Parameter
  546.      *
  547.      * @return The Instance of the FX Forward Curve
  548.      */

  549.     public static final org.drip.state.fx.FXCurve KLKRationalQuadraticCurve (
  550.         final java.lang.String strName,
  551.         final org.drip.analytics.date.JulianDate dtStart,
  552.         final org.drip.product.params.CurrencyPair cp,
  553.         final java.lang.String[] astrTenor,
  554.         final double[] adblFXForward,
  555.         final double dblFXSpot,
  556.         final double dblTension)
  557.     {
  558.         try {
  559.             return CustomSplineCurve (strName, dtStart, cp, astrTenor, adblFXForward, new
  560.                 org.drip.spline.params.SegmentCustomBuilderControl
  561.                     (org.drip.spline.stretch.MultiSegmentSequenceBuilder.BASIS_SPLINE_KLK_RATIONAL_QUADRATIC_TENSION,
  562.                 new org.drip.spline.basis.ExponentialTensionSetParams (dblTension),
  563.                     org.drip.spline.params.SegmentInelasticDesignControl.Create (2, 2), null, null),
  564.                         dblFXSpot);
  565.         } catch (java.lang.Exception e) {
  566.             e.printStackTrace();
  567.         }

  568.         return null;
  569.     }
  570. }