BondProductBuilder.java

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

  82. /**
  83.  * <i>BondProductBuilder</i> holds the static parameters of the bond product needed for the full bond
  84.  * valuation. It contains the bond identifier parameters (ISIN, CUSIP), the issuer level parameters (Ticker,
  85.  * SPN or the credit curve string), coupon parameters (coupon rate, coupon frequency, coupon type, day
  86.  * count), maturity parameters (maturity date, maturity type, final maturity, redemption value), date
  87.  * parameters (announce, first settle, first coupon, interest accrual start, and issue dates), embedded
  88.  * option parameters (callable, putable, has been exercised), currency parameters (trade, coupon, and
  89.  * redemption currencies), floater parameters (floater flag, floating coupon convention, current coupon, rate
  90.  * index, spread), and whether the bond is perpetual or has defaulted.
  91.  *
  92.  *  <br><br>
  93.  *  <ul>
  94.  *      <li><b>Module </b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/ProductCore.md">Product Core Module</a></li>
  95.  *      <li><b>Library</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/FixedIncomeAnalyticsLibrary.md">Fixed Income Analytics</a></li>
  96.  *      <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>
  97.  *      <li><b>Package</b> = <a href = "https://github.com/lakshmiDRIP/DROP/tree/master/src/main/java/org/drip/product/creator/README.md">Streams and Products Construction Utilities</a></li>
  98.  *  </ul>
  99.  * <br><br>
  100.  *
  101.  * @author Lakshmi Krishnamurthy
  102.  *
  103.  */

  104. public class BondProductBuilder {
  105.     private static final boolean m_bBlog = false;
  106.     private static final boolean m_bDisplayWarnings = true;

  107.     /**
  108.      * ISIN
  109.      */

  110.     public java.lang.String _strISIN = "";

  111.     /**
  112.      * CUSIP
  113.      */

  114.     public java.lang.String _strCUSIP = "";

  115.     /**
  116.      * Ticker
  117.      */

  118.     public java.lang.String _strTicker = "";

  119.     /**
  120.      * Coupon
  121.      */

  122.     public double _dblCoupon = java.lang.Double.NaN;

  123.     /**
  124.      * Maturity
  125.      */

  126.     public org.drip.analytics.date.JulianDate _dtMaturity = null;

  127.     /**
  128.      * Coupon Frequency
  129.      */

  130.     public int _iCouponFreq = 0;

  131.     /**
  132.      * Coupon Type
  133.      */

  134.     public java.lang.String _strCouponType = "";

  135.     /**
  136.      * Maturity Type
  137.      */

  138.     public java.lang.String _strMaturityType = "";

  139.     /**
  140.      * Calculation Type
  141.      */

  142.     public java.lang.String _strCalculationType = "";

  143.     /**
  144.      * Day count Code
  145.      */

  146.     public java.lang.String _strDayCountCode = "";

  147.     /**
  148.      * Redemption Value
  149.      */

  150.     public double _dblRedemptionValue = java.lang.Double.NaN;

  151.     /**
  152.      * Announce Date
  153.      */

  154.     public org.drip.analytics.date.JulianDate _dtAnnounce = null;

  155.     /**
  156.      * First Settle Date
  157.      */

  158.     public org.drip.analytics.date.JulianDate _dtFirstSettle = null;

  159.     /**
  160.      * First Coupon Date
  161.      */

  162.     public org.drip.analytics.date.JulianDate _dtFirstCoupon = null;

  163.     /**
  164.      * Interest Accrual Start Date
  165.      */

  166.     public org.drip.analytics.date.JulianDate _dtInterestAccrualStart = null;

  167.     /**
  168.      * Issue Date
  169.      */

  170.     public org.drip.analytics.date.JulianDate _dtIssue = null;

  171.     /**
  172.      * Callable flag
  173.      */

  174.     public boolean _bIsCallable = false;

  175.     /**
  176.      * Putable flag
  177.      */

  178.     public boolean _bIsPutable = false;

  179.     /**
  180.      * Sinkable flag
  181.      */

  182.     public boolean _bIsSinkable = false;

  183.     /**
  184.      * Redemption Currency
  185.      */

  186.     public java.lang.String _strRedemptionCurrency = "";

  187.     /**
  188.      * Coupon Currency
  189.      */

  190.     public java.lang.String _strCouponCurrency = "";

  191.     /**
  192.      * Trade Currency
  193.      */

  194.     public java.lang.String _strTradeCurrency = "";

  195.     /**
  196.      * Has Been Exercised flag
  197.      */

  198.     public boolean _bHasBeenCalled = false;

  199.     /**
  200.      * Floater Coupon Day Count Convention
  201.      */

  202.     public java.lang.String _strFloatCouponConvention = "";

  203.     /**
  204.      * Current Coupon
  205.      */

  206.     public double _dblCurrentCoupon = java.lang.Double.NaN;

  207.     /**
  208.      * Is Floater flag
  209.      */

  210.     public boolean _bIsFloater = false;

  211.     /**
  212.      * Final Maturity Date
  213.      */

  214.     public org.drip.analytics.date.JulianDate _dtFinalMaturity = null;

  215.     /**
  216.      * Is Perpetual flag
  217.      */

  218.     public boolean _bIsPerpetual = false;

  219.     /**
  220.      * Is Defaulted flag
  221.      */

  222.     public boolean _bIsDefaulted = false;

  223.     /**
  224.      * Floater Spread
  225.      */

  226.     public double _dblFloatSpread = java.lang.Double.NaN;

  227.     /**
  228.      * Rate Index
  229.      */

  230.     public java.lang.String _strRateIndex = "";

  231.     /**
  232.      * Issuer SPN
  233.      */

  234.     public java.lang.String _strIssuerSPN = "";

  235.     private static final java.lang.String DES (
  236.         final BondProductBuilder bpb)
  237.     {
  238.         return bpb._strTicker + "  " + bpb._dtMaturity.toString() + "[" + bpb._strISIN + "]";
  239.     }

  240.     private org.drip.analytics.date.JulianDate reconcileStartDate()
  241.     {
  242.         if (null != _dtInterestAccrualStart) return _dtInterestAccrualStart;

  243.         if (null != _dtIssue) return _dtIssue;

  244.         if (null != _dtFirstSettle) return _dtFirstSettle;

  245.         return _dtAnnounce;
  246.     }

  247.     /**
  248.      * Create BondProductBuilder from the SQL ResultSet and the input MPC
  249.      *
  250.      * @param rs SQL ResultSet
  251.      * @param mpc org.drip.param.definition.MarketParams to help fill some of the fields in
  252.      *
  253.      * @return BondProductBuilder object
  254.      */

  255.     public static final BondProductBuilder CreateFromResultSet (
  256.         final java.sql.ResultSet rs,
  257.         final org.drip.param.definition.ScenarioMarketParams mpc)
  258.     {
  259.         try {
  260.             BondProductBuilder bpb = new BondProductBuilder();

  261.             if (null == (bpb._strISIN = rs.getString ("ISIN"))) {
  262.                 System.out.println ("No ISIN!");

  263.                 return null;
  264.             }

  265.             if (m_bBlog) System.out.println ("Loading " + bpb._strISIN + " ...");

  266.             if (null == (bpb._strCUSIP = rs.getString ("CUSIP"))) {
  267.                 System.out.println ("No CUSIP!");

  268.                 return null;
  269.             }

  270.             bpb._strTicker = rs.getString ("Ticker");

  271.             if (!org.drip.numerical.common.NumberUtil.IsValid (bpb._dblCoupon = 0.01 * rs.getDouble ("Coupon")))
  272.             {
  273.                 System.out.println ("Invalid coupon for ISIN " + bpb._strISIN);

  274.                 return null;
  275.             }

  276.             if (null == (bpb._dtMaturity = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry (rs.getDate
  277.                 ("Maturity")))) {
  278.                 System.out.println ("Invalid maturity for ISIN " + bpb._strISIN);

  279.                 return null;
  280.             }

  281.             bpb._iCouponFreq = rs.getInt ("CouponFreq");

  282.             bpb._strCouponType = rs.getString ("CouponType");

  283.             bpb._strMaturityType = rs.getString ("MaturityType");

  284.             bpb._strCalculationType = rs.getString ("CalculationType");

  285.             bpb._strDayCountCode = rs.getString ("DayCountConv");

  286.             bpb._dblRedemptionValue = rs.getDouble ("RedemptionValue");

  287.             if (null == (bpb._dtAnnounce = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry (rs.getDate
  288.                 ("AnnounceDate")))) {
  289.                 System.out.println ("Invalid announce date for ISIN " + DES (bpb));

  290.                 return null;
  291.             }

  292.             if (null == (bpb._dtFirstSettle = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry
  293.                 (rs.getDate ("FirstSettleDate")))) {
  294.                 System.out.println ("Invalid first settle date for ISIN " + DES (bpb));

  295.                 return null;
  296.             }

  297.             if (null == (bpb._dtFirstCoupon = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry
  298.                 (rs.getDate ("FirstCouponDate")))) {
  299.                 if (m_bBlog) System.out.println ("Invalid first coupon date for ISIN " + DES (bpb));
  300.             }

  301.             if (null == (bpb._dtInterestAccrualStart = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry
  302.                 (rs.getDate ("AccrualStartDate")))) {
  303.                 System.out.println ("Invalid accrual start date for " + DES (bpb));

  304.                 return null;
  305.             }

  306.             if (null == (bpb._dtIssue = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry (rs.getDate
  307.                 ("IssueDate")))) {
  308.                 System.out.println ("Invalid issue date for " + DES (bpb));

  309.                 return null;
  310.             }

  311.             bpb._bIsCallable = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  312.                 ("IsCallable"));

  313.             bpb._bIsPutable = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  314.                 ("IsPutable"));

  315.             bpb._bIsSinkable = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  316.                 ("IsSinkable"));

  317.             bpb._strRedemptionCurrency = org.drip.analytics.support.Helper.SwitchIRCurve
  318.                 (rs.getString ("RedemptionCurrency"));

  319.             if (null == bpb._strRedemptionCurrency || bpb._strRedemptionCurrency.isEmpty()) {
  320.                 System.out.println ("Invalid redemption currency for " + DES (bpb));

  321.                 return null;
  322.             }

  323.             bpb._strCouponCurrency = org.drip.analytics.support.Helper.SwitchIRCurve
  324.                 (rs.getString ("CouponCurrency"));

  325.             if (null == bpb._strCouponCurrency || bpb._strCouponCurrency.isEmpty()) {
  326.                 System.out.println ("Invalid coupon currency for " + DES (bpb));

  327.                 return null;
  328.             }

  329.             bpb._strTradeCurrency = org.drip.analytics.support.Helper.SwitchIRCurve
  330.                 (rs.getString ("TradeCurrency"));

  331.             if (null == bpb._strTradeCurrency || bpb._strTradeCurrency.isEmpty()) {
  332.                 System.out.println ("Invalid trade currency for " + DES (bpb));

  333.                 return null;
  334.             }

  335.             bpb._bHasBeenCalled = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  336.                 ("Called"));

  337.             bpb._strFloatCouponConvention = rs.getString ("FloatCouponConvention");

  338.             bpb._bIsFloater = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  339.                 ("Floater"));

  340.             // bpb._dblCurrentCoupon = 0.01 * rs.getDouble ("CurrentCoupon");

  341.             bpb._dtFinalMaturity = org.drip.analytics.date.DateUtil.MakeJulianFromRSEntry (rs.getDate
  342.                 ("FinalMaturity"));

  343.             bpb._bIsPerpetual = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  344.                 ("Perpetual"));

  345.             bpb._bIsDefaulted = org.drip.numerical.common.StringUtil.ParseFromUnitaryString (rs.getString
  346.                 ("Defaulted"));

  347.             bpb._dblFloatSpread = 0.0001 * rs.getDouble ("FloatSpread");

  348.             bpb._strRateIndex = rs.getString ("RateIndex");

  349.             if (bpb._bIsFloater && !org.drip.numerical.common.NumberUtil.IsValid (bpb._dblFloatSpread) && (null ==
  350.                 bpb._strRateIndex || bpb._strRateIndex.isEmpty())) {
  351.                 System.out.println ("Invalid float spread for " + DES (bpb));

  352.                 return null;
  353.             }

  354.             bpb._strIssuerSPN = rs.getString ("SPN");

  355.             if (!bpb.validate (mpc)) return null;

  356.             if (m_bBlog) System.out.println ("Loaded " + DES (bpb) + ".");

  357.             return bpb;
  358.         } catch (java.lang.Exception e) {
  359.             e.printStackTrace();
  360.         }

  361.         return null;
  362.     }

  363.     /**
  364.      * Create BondProductBuilder from the JSON Map and the input MPC
  365.      *
  366.      * @param mapJSON The JSON Ref Data Map
  367.      * @param mpc org.drip.param.definition.MarketParams to help fill some of the fields in
  368.      *
  369.      * @return BondProductBuilder object
  370.      */

  371.     public static final BondProductBuilder CreateFromJSONMap (
  372.         final org.drip.analytics.support.CaseInsensitiveTreeMap<java.lang.String> mapJSON,
  373.         final org.drip.param.definition.ScenarioMarketParams mpc)
  374.     {
  375.         /* if (null == mapJSON || 0 == mapJSON.size() || !mapJSON.containsKey ("isin") || !mapJSON.containsKey
  376.             ("cusip") || !mapJSON.containsKey ("ticker") || !mapJSON.containsKey ("coupon") ||
  377.                 !mapJSON.containsKey ("maturity") || !mapJSON.containsKey ("frequency") ||
  378.                     !mapJSON.containsKey ("couponType") || !mapJSON.containsKey ("maturityType") ||
  379.                         !mapJSON.containsKey ("calcType") || !mapJSON.containsKey ("dayCount") ||
  380.                             !mapJSON.containsKey ("redempValue") || !mapJSON.containsKey ("redempCrncy") ||
  381.                                 !mapJSON.containsKey ("cpnCrncy") || !mapJSON.containsKey ("tradeCrncy") ||
  382.                                     !mapJSON.containsKey ("firstCpnDate") || !mapJSON.containsKey
  383.                                         ("issueDate") || !mapJSON.containsKey ("called") ||
  384.                                             !mapJSON.containsKey ("defaulted") || !mapJSON.containsKey
  385.                                                 ("quotedMargin"))
  386.             return null; */

  387.         BondProductBuilder bpb = new BondProductBuilder();

  388.         if (null == (bpb._strISIN = mapJSON.get ("isin"))) return null;

  389.         if (null == (bpb._strCUSIP = mapJSON.get ("cusip"))) return null;

  390.         if (null == (bpb._strTicker = mapJSON.get ("ticker"))) return null;

  391.         if (!org.drip.numerical.common.NumberUtil.IsValid (bpb._dblCoupon = 0.01 * java.lang.Double.parseDouble
  392.             (mapJSON.get ("coupon"))))
  393.             return null;

  394.         if (null == (bpb._dtMaturity = org.drip.analytics.date.DateUtil.MakeJulianFromYYYYMMDD
  395.             (mapJSON.get ("maturity"), "-")))
  396.             return null;

  397.         bpb._iCouponFreq = java.lang.Integer.parseInt (mapJSON.get ("frequency"));

  398.         bpb._strCouponType = mapJSON.get ("couponType");

  399.         bpb._strMaturityType = mapJSON.get ("maturityType");

  400.         bpb._strCalculationType = mapJSON.get ("calcType");

  401.         bpb._strDayCountCode = mapJSON.get ("dayCount");

  402.         bpb._dblRedemptionValue = java.lang.Double.parseDouble (mapJSON.get ("redempValue"));

  403.         if (null == (bpb._strRedemptionCurrency = mapJSON.get ("redempCrncy")) ||
  404.             bpb._strRedemptionCurrency.isEmpty()) {
  405.             System.out.println ("Invalid redemption currency for " + DES (bpb));

  406.             return null;
  407.         }

  408.         if (null == (bpb._strCouponCurrency = mapJSON.get ("cpnCrncy")) || bpb._strCouponCurrency.isEmpty())
  409.         {
  410.             System.out.println ("Invalid Coupon currency for " + DES (bpb));

  411.             return null;
  412.         }

  413.         if (null == (bpb._strTradeCurrency = mapJSON.get ("tradeCrncy")) || bpb._strTradeCurrency.isEmpty())
  414.         {
  415.             System.out.println ("Invalid Trade currency for " + DES (bpb));

  416.             return null;
  417.         }

  418.         if (null == (bpb._dtFirstCoupon = org.drip.analytics.date.DateUtil.MakeJulianFromYYYYMMDD
  419.             (mapJSON.get ("firstCpnDate"), "-")))
  420.             return null;

  421.         if (null == (bpb._dtIssue = org.drip.analytics.date.DateUtil.MakeJulianFromYYYYMMDD
  422.             (mapJSON.get ("issueDate"), "-")))
  423.             return null;

  424.         try {
  425.             bpb._bIsCallable = java.lang.Boolean.parseBoolean (mapJSON.get ("callable"));

  426.             bpb._bIsPutable = java.lang.Boolean.parseBoolean (mapJSON.get ("putable"));

  427.             bpb._bIsSinkable = java.lang.Boolean.parseBoolean (mapJSON.get ("sinkable"));

  428.             bpb._bHasBeenCalled = java.lang.Boolean.parseBoolean (mapJSON.get ("called"));

  429.             // bpb._strFloatCouponConvention = rs.getString ("FloatCouponConvention");

  430.             bpb._bIsFloater = java.lang.Boolean.parseBoolean (mapJSON.get ("floater"));

  431.             // bpb._dblCurrentCoupon = 0.01 * rs.getDouble ("CurrentCoupon");

  432.             if (null == (bpb._dtFinalMaturity = org.drip.analytics.date.DateUtil.MakeJulianFromYYYYMMDD
  433.                 (mapJSON.get ("finalMaturityDt"), "-")))
  434.                 return null;

  435.             bpb._bIsPerpetual = java.lang.Boolean.parseBoolean (mapJSON.get ("perpetual"));

  436.             bpb._bIsDefaulted = java.lang.Boolean.parseBoolean (mapJSON.get ("defaulted"));

  437.             // bpb._dblFloatSpread = java.lang.Double.parseDouble (mapJSON.get ("quotedMargin"));

  438.             bpb._strRateIndex = mapJSON.get ("resetIndex");

  439.             if (bpb._bIsFloater && !org.drip.numerical.common.NumberUtil.IsValid (bpb._dblFloatSpread) && (null ==
  440.                 bpb._strRateIndex || bpb._strRateIndex.isEmpty())) {
  441.                 System.out.println ("Invalid float spread for " + DES (bpb));

  442.                 return null;
  443.             }

  444.             // bpb._strIssuerSPN = rs.getString ("SPN");

  445.             if (!bpb.validate (mpc)) return null;

  446.             if (m_bBlog) System.out.println ("Loaded " + DES (bpb) + ".");

  447.             return bpb;
  448.         } catch (java.lang.Exception e) {
  449.             e.printStackTrace();
  450.         }

  451.         return null;
  452.     }

  453.     /**
  454.      * Empty BondProductBuilder ctr - uninitialized members
  455.      */

  456.     public BondProductBuilder()
  457.     {
  458.     }

  459.     /**
  460.      * Set the Bond ISIN
  461.      *
  462.      * @param strISIN ISIN input
  463.      *
  464.      * @return Success (true), failure (false)
  465.      */

  466.     public boolean setISIN (
  467.         final java.lang.String strISIN)
  468.     {
  469.         if (null == strISIN || strISIN.trim().isEmpty() || "null".equalsIgnoreCase (strISIN.trim()))
  470.             return false;

  471.         _strISIN = strISIN;
  472.         return true;
  473.     }

  474.     /**
  475.      * Set the Bond CUSIP
  476.      *
  477.      * @param strCUSIP CUSIP input
  478.      *
  479.      * @return Success (true), failure (false)
  480.      */

  481.     public boolean setCUSIP (
  482.         final java.lang.String strCUSIP)
  483.     {
  484.         if (null == strCUSIP || strCUSIP.trim().isEmpty() || "null".equalsIgnoreCase (strCUSIP.trim()))
  485.             return false;

  486.         _strCUSIP = strCUSIP;
  487.         return true;
  488.     }

  489.     /**
  490.      * Set the Bond Ticker
  491.      *
  492.      * @param strTicker Ticker input
  493.      *
  494.      * @return Success (true), failure (false)
  495.      */

  496.     public boolean setTicker (
  497.         final java.lang.String strTicker)
  498.     {
  499.         if (null == (_strTicker = strTicker.trim())) _strTicker = "";

  500.         return true;
  501.     }

  502.     /**
  503.      * Set the Bond Coupon
  504.      *
  505.      * @param strCoupon Coupon input
  506.      *
  507.      * @return Success (true), failure (false)
  508.      */

  509.     public boolean setCoupon (
  510.         final java.lang.String strCoupon)
  511.     {
  512.         if (null == strCoupon || strCoupon.trim().isEmpty() || "null".equalsIgnoreCase (strCoupon.trim()))
  513.             _dblCoupon = 0.;

  514.         try {
  515.             _dblCoupon = java.lang.Double.parseDouble (strCoupon.trim());

  516.             return true;
  517.         } catch (java.lang.Exception e) {
  518.             if (m_bBlog) System.out.println ("Bad coupon " + strCoupon + " for ISIN " + _strISIN);
  519.         }

  520.         return false;
  521.     }

  522.     /**
  523.      * Set the Bond Maturity
  524.      *
  525.      * @param strMaturity Maturity input
  526.      *
  527.      * @return Success (true), failure (false)
  528.      */

  529.     public boolean setMaturity (
  530.         final java.lang.String strMaturity)
  531.     {
  532.         try {
  533.             if (null == (_dtMaturity = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate
  534.                 (strMaturity.trim())))
  535.                 return false;

  536.             return true;
  537.         } catch (java.lang.Exception e) {
  538.             if (m_bBlog) System.out.println ("Bad Maturity " + strMaturity + " for ISIN " + _strISIN);
  539.         }

  540.         return false;
  541.     }

  542.     /**
  543.      * Set the Bond Coupon Frequency
  544.      *
  545.      * @param strCouponFreq Coupon Frequency input
  546.      *
  547.      * @return Success (true), failure (false)
  548.      */

  549.     public boolean setCouponFreq (
  550.         final java.lang.String strCouponFreq)
  551.     {
  552.         if (null == strCouponFreq || strCouponFreq.isEmpty() || "null".equalsIgnoreCase (strCouponFreq))
  553.             _iCouponFreq = 0;
  554.         else {
  555.             try {
  556.                 _iCouponFreq = (int) java.lang.Double.parseDouble (strCouponFreq.trim());
  557.             } catch (java.lang.Exception e) {
  558.                 if (m_bBlog) System.out.println ("Bad Cpn Freq " + strCouponFreq + " for ISIN " + _strISIN);

  559.                 return false;
  560.             }
  561.         }

  562.         return true;
  563.     }

  564.     /**
  565.      * Set the Bond Coupon Type
  566.      *
  567.      * @param strCouponType Coupon Type input
  568.      *
  569.      * @return Success (true), failure (false)
  570.      */

  571.     public boolean setCouponType (
  572.         final java.lang.String strCouponType)
  573.     {
  574.         if (null == (_strCouponType = strCouponType.trim())) _strCouponType = "";

  575.         return true;
  576.     }

  577.     /**
  578.      * Set the Bond Maturity Type
  579.      *
  580.      * @param strMaturityType Maturity Type input
  581.      *
  582.      * @return Success (true), failure (false)
  583.      */

  584.     public boolean setMaturityType (
  585.         final java.lang.String strMaturityType)
  586.     {
  587.         if (null == (_strMaturityType = strMaturityType.trim())) _strMaturityType = "";

  588.         return true;
  589.     }

  590.     /**
  591.      * Set the Bond Calculation Type
  592.      *
  593.      * @param strCalculationType Calculation Type input
  594.      *
  595.      * @return Success (true), failure (false)
  596.      */

  597.     public boolean setCalculationType (
  598.         final java.lang.String strCalculationType)
  599.     {
  600.         if (null == (_strCalculationType = strCalculationType.trim())) _strCalculationType = "";

  601.         return true;
  602.     }

  603.     /**
  604.      * Set the Bond Day Count Code
  605.      *
  606.      * @param strDayCountCode Day Count Code input
  607.      *
  608.      * @return Success (true), failure (false)
  609.      */

  610.     public boolean setDayCountCode (
  611.         final java.lang.String strDayCountCode)
  612.     {
  613.         _strDayCountCode = "Unknown DC";

  614.         try {
  615.             _strDayCountCode = org.drip.analytics.support.Helper.ParseFromBBGDCCode
  616.                 (strDayCountCode.trim());

  617.             return true;
  618.         } catch (java.lang.Exception e) {
  619.         }

  620.         return false;
  621.     }

  622.     /**
  623.      * Set the Bond Redemption Value
  624.      *
  625.      * @param strRedemptionValue Redemption Value input
  626.      *
  627.      * @return Success (true), failure (false)
  628.      */

  629.     public boolean setRedemptionValue (
  630.         final java.lang.String strRedemptionValue)
  631.     {
  632.         try {
  633.             _dblRedemptionValue = java.lang.Double.parseDouble (strRedemptionValue.trim());

  634.             return true;
  635.         } catch (java.lang.Exception e) {
  636.             System.out.println ("Bad Redemption Value " + strRedemptionValue + " for ISIN " + _strISIN);
  637.         }

  638.         return false;
  639.     }

  640.     /**
  641.      * Set the Bond Announce
  642.      *
  643.      * @param strAnnounce Announce Date String
  644.      *
  645.      * @return Success (true), failure (false)
  646.      */

  647.     public boolean setAnnounce (
  648.         final java.lang.String strAnnounce)
  649.     {
  650.         try {
  651.             _dtAnnounce = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate (strAnnounce.trim());

  652.             return true;
  653.         } catch (java.lang.Exception e) {
  654.             if (m_bBlog) System.out.println ("Bad Announce " + strAnnounce + " for ISIN " + _strISIN);
  655.         }

  656.         return false;
  657.     }

  658.     /**
  659.      * Set the Bond First Settle
  660.      *
  661.      * @param strFirstSettle First Settle Date String
  662.      *
  663.      * @return Success (true), failure (false)
  664.      */

  665.     public boolean setFirstSettle (
  666.         final java.lang.String strFirstSettle)
  667.     {
  668.         try {
  669.             _dtFirstSettle = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate
  670.                 (strFirstSettle.trim());

  671.             return true;
  672.         } catch (java.lang.Exception e) {
  673.             if (m_bBlog) System.out.println ("Bad First Settle " + strFirstSettle + " for ISIN " + _strISIN);
  674.         }

  675.         return false;
  676.     }

  677.     /**
  678.      * Set the Bond First Coupon Date
  679.      *
  680.      * @param strFirstCoupon First Coupon Date String
  681.      *
  682.      * @return Success (true), failure (false)
  683.      */

  684.     public boolean setFirstCoupon (
  685.         final java.lang.String strFirstCoupon)
  686.     {
  687.         try {
  688.             _dtFirstCoupon = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate
  689.                 (strFirstCoupon.trim());

  690.             return true;
  691.         } catch (java.lang.Exception e) {
  692.             if (m_bBlog) System.out.println ("Bad First Coupon " + strFirstCoupon + " for ISIN " + _strISIN);
  693.         }

  694.         return false;
  695.     }

  696.     /**
  697.      * Set the Bond Interest Accrual Start Date
  698.      *
  699.      * @param strInterestAccrualStart Interest Accrual Start Date String
  700.      *
  701.      * @return Success (true), failure (false)
  702.      */

  703.     public boolean setInterestAccrualStart (
  704.         final java.lang.String strInterestAccrualStart)
  705.     {
  706.         try {
  707.             _dtInterestAccrualStart = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate
  708.                 (strInterestAccrualStart.trim());

  709.             return true;
  710.         } catch (java.lang.Exception e) {
  711.             if (m_bBlog)
  712.                 System.out.println ("Bad Announce " + strInterestAccrualStart + " for ISIN " + _strISIN);
  713.         }

  714.         return false;
  715.     }

  716.     /**
  717.      * Set the Bond Issue Date
  718.      *
  719.      * @param strIssue Issue Date String
  720.      *
  721.      * @return Success (true), failure (false)
  722.      */

  723.     public boolean setIssue (
  724.         final java.lang.String strIssue)
  725.     {
  726.         try {
  727.             _dtIssue = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate (strIssue.trim());

  728.             return true;
  729.         } catch (java.lang.Exception e) {
  730.             if (m_bBlog) System.out.println ("Bad Issue " + strIssue + " for ISIN " + _strISIN);
  731.         }

  732.         return false;
  733.     }

  734.     /**
  735.      * Set whether the Bond Is Callable
  736.      *
  737.      * @param strCallable Callable String
  738.      *
  739.      * @return Success (true), failure (false)
  740.      */

  741.     public boolean setIsCallable (
  742.         final java.lang.String strCallable)
  743.     {
  744.         if (null == strCallable) _bIsCallable = false;

  745.         if ("1".equalsIgnoreCase (strCallable.trim()))
  746.             _bIsCallable = true;
  747.         else
  748.             _bIsCallable = false;

  749.         return true;
  750.     }

  751.     /**
  752.      * Set whether the Bond Is Putable
  753.      *
  754.      * @param strPutable Putable String
  755.      *
  756.      * @return Success (true), failure (false)
  757.      */

  758.     public boolean setIsPutable (
  759.         final java.lang.String strPutable)
  760.     {
  761.         if (null == strPutable) _bIsPutable = false;

  762.         if ("1".equalsIgnoreCase (strPutable.trim()))
  763.             _bIsPutable = true;
  764.         else
  765.             _bIsPutable = false;

  766.         return true;
  767.     }

  768.     /**
  769.      * Set whether the Bond Is Sinkable
  770.      *
  771.      * @param strSinkable Sinkable String
  772.      *
  773.      * @return Success (true), failure (false)
  774.      */

  775.     public boolean setIsSinkable (
  776.         final java.lang.String strSinkable)
  777.     {
  778.         if (null == strSinkable) _bIsSinkable = false;

  779.         if ("1".equalsIgnoreCase (strSinkable.trim()))
  780.             _bIsSinkable = true;
  781.         else
  782.             _bIsSinkable = false;

  783.         return true;
  784.     }

  785.     /**
  786.      * Set The redemption Currency
  787.      *
  788.      * @param strRedemptionCurrency Redemption Currency String
  789.      *
  790.      * @return Success (true), failure (false)
  791.      */

  792.     public boolean setRedemptionCurrency (
  793.         final java.lang.String strRedemptionCurrency)
  794.     {
  795.         if (null == (_strRedemptionCurrency = strRedemptionCurrency.trim()) || "null".equalsIgnoreCase
  796.             (strRedemptionCurrency.trim()))
  797.             return false;

  798.         return true;
  799.     }

  800.     /**
  801.      * Set The Coupon Currency
  802.      *
  803.      * @param strCouponCurrency Coupon Currency String
  804.      *
  805.      * @return Success (true), failure (false)
  806.      */

  807.     public boolean setCouponCurrency (
  808.         final java.lang.String strCouponCurrency)
  809.     {
  810.         if (null == (_strCouponCurrency = strCouponCurrency.trim()) || "null".equalsIgnoreCase
  811.             (strCouponCurrency.trim()))
  812.             return false;

  813.         return true;
  814.     }

  815.     /**
  816.      * Set The Trade Currency
  817.      *
  818.      * @param strTradeCurrency Trade Currency String
  819.      *
  820.      * @return Success (true), failure (false)
  821.      */

  822.     public boolean setTradeCurrency (
  823.         final java.lang.String strTradeCurrency)
  824.     {
  825.         if (null == (_strTradeCurrency = strTradeCurrency.trim()) || "null".equalsIgnoreCase
  826.             (strTradeCurrency.trim()))
  827.             return false;

  828.         return true;
  829.     }

  830.     /**
  831.      * Set whether the bond Has Been Called
  832.      *
  833.      * @param strHasBeenCalled Has Been Called String
  834.      *
  835.      * @return Success (true), failure (false)
  836.      */

  837.     public boolean setHasBeenCalled (
  838.         final java.lang.String strHasBeenCalled)
  839.     {
  840.         if (null == strHasBeenCalled) _bHasBeenCalled = false;

  841.         if ("1".equalsIgnoreCase (strHasBeenCalled.trim()))
  842.             _bHasBeenCalled = true;
  843.         else
  844.             _bHasBeenCalled = false;

  845.         return true;
  846.     }

  847.     /**
  848.      * Set the bond's Float Coupon Convention
  849.      *
  850.      * @param strFloatCouponConvention Float Coupon Convention String
  851.      *
  852.      * @return Success (true), failure (false)
  853.      */

  854.     public boolean setFloatCouponConvention (
  855.         final java.lang.String strFloatCouponConvention)
  856.     {
  857.         if (null == (_strFloatCouponConvention = strFloatCouponConvention.trim()))
  858.             _strFloatCouponConvention = "";

  859.         return true;
  860.     }

  861.     /**
  862.      * Set the bond's Current Coupon
  863.      *
  864.      * @param strCurrentCoupon Current Coupon String
  865.      *
  866.      * @return Success (true), failure (false)
  867.      */

  868.     public boolean setCurrentCoupon (
  869.         final java.lang.String strCurrentCoupon)
  870.     {
  871.         if (null == strCurrentCoupon || strCurrentCoupon.trim().isEmpty() || "null".equalsIgnoreCase
  872.             (strCurrentCoupon.trim()))
  873.             _dblCurrentCoupon = 0.;
  874.         else {
  875.             try {
  876.                 _dblCurrentCoupon = java.lang.Double.parseDouble (strCurrentCoupon.trim());

  877.                 return true;
  878.             } catch (java.lang.Exception e) {
  879.                 if (m_bBlog)
  880.                     System.out.println ("Bad Curr Cpn " + strCurrentCoupon + " for ISIN " + _strISIN);
  881.             }
  882.         }

  883.         return false;
  884.     }

  885.     /**
  886.      * Set whether the bond is a floater or not
  887.      *
  888.      * @param strIsFloater String indicating whether the bond is a floater
  889.      *
  890.      * @return Success (true), failure (false)
  891.      */

  892.     public boolean setIsFloater (
  893.         final java.lang.String strIsFloater)
  894.     {
  895.         if (null == strIsFloater) _bIsFloater = false;

  896.         if ("1".equalsIgnoreCase (strIsFloater.trim()))
  897.             _bIsFloater = true;
  898.         else
  899.             _bIsFloater = false;

  900.         return true;
  901.     }

  902.     /**
  903.      * Set the final maturity of the bond
  904.      *
  905.      * @param strFinalMaturity String representing the bond's final maturity
  906.      *
  907.      * @return Success (true), failure (false)
  908.      */

  909.     public boolean setFinalMaturity (
  910.         final java.lang.String strFinalMaturity)
  911.     {
  912.         try {
  913.             _dtFinalMaturity = org.drip.analytics.date.DateUtil.MakeJulianDateFromBBGDate
  914.                 (strFinalMaturity.trim());

  915.             return true;
  916.         } catch (java.lang.Exception e) {
  917.             if (m_bBlog)
  918.                 System.out.println ("Bad Final Maturity " + strFinalMaturity + " for ISIN " + _strISIN);
  919.         }

  920.         return false;
  921.     }

  922.     /**
  923.      * Set whether the bond is perpetual or not
  924.      *
  925.      * @param strIsPerpetual String representing whether the bond is perpetual or not
  926.      *
  927.      * @return Success (true), failure (false)
  928.      */

  929.     public boolean setIsPerpetual (
  930.         final java.lang.String strIsPerpetual)
  931.     {
  932.         if (null == strIsPerpetual) _bIsPerpetual = false;

  933.         if ("1".equalsIgnoreCase (strIsPerpetual.trim()))
  934.             _bIsPerpetual = true;
  935.         else
  936.             _bIsPerpetual = false;

  937.         return true;
  938.     }

  939.     /**
  940.      * Set whether the bond is defaulted or not
  941.      *
  942.      * @param strIsDefaulted String representing whether the bond is defaulted or not
  943.      *
  944.      * @return Success (true), failure (false)
  945.      */

  946.     public boolean setIsDefaulted (
  947.         final java.lang.String strIsDefaulted)
  948.     {
  949.         if (null == strIsDefaulted) _bIsDefaulted = false;

  950.         if ("1".equalsIgnoreCase (strIsDefaulted.trim()))
  951.             _bIsDefaulted = true;
  952.         else
  953.             _bIsDefaulted = false;

  954.         return true;
  955.     }

  956.     /**
  957.      * Set the bond's floating rate spread
  958.      *
  959.      * @param strFloatSpread String representing the bond's floating spread
  960.      *
  961.      * @return Success (true), failure (false)
  962.      */

  963.     public boolean setFloatSpread (
  964.         final java.lang.String strFloatSpread)
  965.     {
  966.         try {
  967.             _dblFloatSpread = java.lang.Double.parseDouble (strFloatSpread.trim());

  968.             return true;
  969.         } catch (java.lang.Exception e) {
  970.             if (m_bBlog) System.out.println ("Bad Float Spread " + strFloatSpread + " for ISIN " + _strISIN);
  971.         }

  972.         return false;
  973.     }

  974.     /**
  975.      * Set the bond's floating rate spread from the MPC
  976.      *
  977.      * @param mpc org.drip.param.definition.MarketParams
  978.      *
  979.      * @return Success (true), failure (false)
  980.      */

  981.     public boolean setFloatSpread (
  982.         final org.drip.param.definition.ScenarioMarketParams mpc)
  983.     {
  984.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblCurrentCoupon)) {
  985.             System.out.println ("Curr cpn for ISIN " + _strISIN + " is NaN!");

  986.             return false;
  987.         }

  988.         if (null == mpc || null == mpc.scenarioDiscountCurveMap() || null == mpc.scenarioDiscountCurveMap().get (_strCouponCurrency) ||
  989.             null == mpc.scenarioDiscountCurveMap().get (_strCouponCurrency).base()) {
  990.             if (m_bBlog) System.out.println ("Bad mpc In for ISIN " + _strISIN);

  991.             return false;
  992.         }

  993.         try {
  994.             if (0. != _dblCurrentCoupon) {
  995.                 org.drip.state.discount.MergedDiscountForwardCurve dcBase = mpc.scenarioDiscountCurveMap().get (_strCouponCurrency).base();

  996.                 _dblFloatSpread = _dblCurrentCoupon - 100. * dcBase.libor (dcBase.epoch().julian(),
  997.                     (org.drip.analytics.support.Helper.GetTenorFromFreq (_iCouponFreq)));
  998.             } else
  999.                 _dblFloatSpread = 0.;

  1000.             return true;
  1001.         } catch (java.lang.Exception e) {
  1002.             if (m_bBlog) e.printStackTrace();
  1003.         }

  1004.         return false;
  1005.     }

  1006.     /**
  1007.      * Set the bond's Rate Index
  1008.      *
  1009.      * @param strRateIndex Rate Index
  1010.      *
  1011.      * @return Success (true), failure (false)
  1012.      */

  1013.     public boolean setRateIndex (
  1014.         final java.lang.String strRateIndex)
  1015.     {
  1016.         if (null == (_strRateIndex = strRateIndex)) _strRateIndex = "";

  1017.         return true;
  1018.     }

  1019.     /**
  1020.      * Set the bond's Issuer SPN
  1021.      *
  1022.      * @param strIssuerSPN Issuer SPN String
  1023.      *
  1024.      * @return Success (true), failure (false)
  1025.      */

  1026.     public boolean setIssuerSPN (
  1027.         final java.lang.String strIssuerSPN)
  1028.     {
  1029.         if (null == (_strIssuerSPN = strIssuerSPN)) _strIssuerSPN = "";

  1030.         return true;
  1031.     }

  1032.     /**
  1033.      * Validate the state
  1034.      *
  1035.      * @param mpc org.drip.param.definition.MarketParams
  1036.      *
  1037.      * @return Success (true), failure (false)
  1038.      */

  1039.     public boolean validate (
  1040.         final org.drip.param.definition.ScenarioMarketParams mpc)
  1041.     {
  1042.         if (null == _strISIN || _strISIN.isEmpty() || null == _strCUSIP || _strCUSIP.isEmpty()) {
  1043.             if (m_bDisplayWarnings)
  1044.                 System.out.println ("Check ISIN[" + _strISIN + "] or CUSIP[" + _strCUSIP + "]");

  1045.             return false;
  1046.         }

  1047.         if (0 == _iCouponFreq && 0. != _dblCoupon) {
  1048.             if (m_bDisplayWarnings)
  1049.                 System.out.println ("Coupon Freq and Cpn amt both not sero for ISIN[" + _strISIN + "]");

  1050.             return false;
  1051.         }

  1052.         if (49 == _iCouponFreq || 52 == _iCouponFreq) {
  1053.             if (m_bDisplayWarnings)
  1054.                 System.out.println ("ISIN[" + _strISIN + "] has cpn freq of " + _iCouponFreq + "!");

  1055.             return false;
  1056.         }

  1057.         if (null == _dtInterestAccrualStart) {
  1058.             if (null == (_dtInterestAccrualStart = reconcileStartDate())) {
  1059.                 if (m_bDisplayWarnings)
  1060.                     System.out.println ("All possible date init candidates are null for ISIN " + _strISIN);

  1061.                 return false;
  1062.             }
  1063.         }

  1064.         if (_bIsFloater && (null == _strRateIndex || _strRateIndex.isEmpty()) &&
  1065.             !org.drip.numerical.common.NumberUtil.IsValid (_dblFloatSpread) && java.lang.Double.isNaN
  1066.                 (_dblCurrentCoupon)) {
  1067.             if (m_bDisplayWarnings)
  1068.                 System.out.println ("Invalid Rate index & float spread & current coupon for " + _strISIN);

  1069.             return false;
  1070.         }

  1071.         if (_bIsFloater && (null == _strRateIndex || _strRateIndex.isEmpty())) {
  1072.             if (null == (_strRateIndex = org.drip.analytics.support.Helper.CalcRateIndex
  1073.                 (_strCouponCurrency, _iCouponFreq))) {
  1074.                 if (m_bDisplayWarnings)
  1075.                     System.out.println ("Warning: Cannot find Rate index for ISIN " + _strISIN);
  1076.             }
  1077.         }

  1078.         if (_bIsFloater && !org.drip.numerical.common.NumberUtil.IsValid (_dblFloatSpread)) {
  1079.             try {
  1080.                 if (!setFloatSpread (mpc)) {
  1081.                     if (m_bDisplayWarnings)
  1082.                         System.out.println ("Warning: Cannot set float spread for ISIN " + _strISIN +
  1083.                             " and Coupon Currency " + _strCouponCurrency);
  1084.                 }
  1085.             } catch (java.lang.Exception e) {
  1086.                 if (m_bDisplayWarnings)
  1087.                     System.out.println ("Warning: Cannot set float spread for ISIN " + _strISIN +
  1088.                         " and Coupon Currency " + _strCouponCurrency);

  1089.                 e.printStackTrace();
  1090.             }
  1091.         }

  1092.         if (null == _dtIssue) _dtIssue = reconcileStartDate();

  1093.         if (null == _dtFirstSettle) _dtFirstSettle = reconcileStartDate();

  1094.         if (null == _dtAnnounce) _dtAnnounce = reconcileStartDate();

  1095.         return true;
  1096.     }

  1097.     /**
  1098.      * Create an SQL Insert statement from the object's state
  1099.      *
  1100.      * @return String representing the SQL Insert
  1101.      */

  1102.     public java.lang.String makeSQLInsert()
  1103.     {
  1104.         java.lang.StringBuilder sb = new java.lang.StringBuilder();

  1105.         sb.append ("insert into BondValData values(");

  1106.         sb.append ("'").append (_strISIN).append ("', ");

  1107.         sb.append ("'").append (_strCUSIP).append ("', ");

  1108.         sb.append ("'").append (_strTicker).append ("', ");

  1109.         sb.append (_dblCoupon).append (", ");

  1110.         sb.append ("'").append (_dtMaturity.toOracleDate()).append ("', ");

  1111.         sb.append (_iCouponFreq).append (", ");

  1112.         sb.append ("'").append (_strCouponType).append ("', ");

  1113.         sb.append ("'").append (_strMaturityType).append ("', ");

  1114.         sb.append ("'").append (_strCalculationType).append ("', ");

  1115.         sb.append ("'").append (_strDayCountCode).append ("', ");

  1116.         sb.append (_dblRedemptionValue).append (", ");

  1117.         sb.append ("'").append (_dtAnnounce.toOracleDate()).append ("', ");

  1118.         sb.append ("'").append (_dtFirstSettle.toOracleDate()).append ("', ");

  1119.         if (null == _dtFirstCoupon)
  1120.             sb.append ("null, ");
  1121.         else
  1122.             sb.append ("'").append (_dtFirstCoupon.toOracleDate()).append ("', ");

  1123.         sb.append ("'").append (_dtInterestAccrualStart.toOracleDate()).append ("', ");

  1124.         sb.append ("'").append (_dtIssue.toOracleDate()).append ("', ");

  1125.         sb.append ("'").append (_bIsCallable ? 1 : 0).append ("', ");

  1126.         sb.append ("'").append (_bIsPutable ? 1 : 0).append ("', ");

  1127.         sb.append ("'").append (_bIsSinkable ? 1 : 0).append ("', ");

  1128.         sb.append ("'").append (_strRedemptionCurrency).append ("', ");

  1129.         sb.append ("'").append (_strCouponCurrency).append ("', ");

  1130.         sb.append ("'").append (_strTradeCurrency).append ("', ");

  1131.         sb.append ("'").append (_bHasBeenCalled ? 1 : 0).append ("', ");

  1132.         sb.append ("'").append (_strFloatCouponConvention).append ("', ");

  1133.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblCurrentCoupon))
  1134.             sb.append ("null, ");
  1135.         else
  1136.             sb.append (_dblCurrentCoupon).append (", ");

  1137.         sb.append ("'").append (_bIsFloater ? 1 : 0).append ("', ");

  1138.         if (null == _dtFinalMaturity)
  1139.             sb.append ("null, ");
  1140.         else
  1141.             sb.append ("'").append (_dtFinalMaturity.toOracleDate()).append ("', ");

  1142.         sb.append ("'").append (_bIsPerpetual ? 1 : 0).append ("', ");

  1143.         sb.append ("'").append (_bIsDefaulted ? 1 : 0).append ("', ");

  1144.         if (!org.drip.numerical.common.NumberUtil.IsValid (_dblFloatSpread))
  1145.             sb.append ("null, ");
  1146.         else
  1147.             sb.append (_dblFloatSpread).append (", ");

  1148.         sb.append ("'").append (_strRateIndex).append ("', ");

  1149.         sb.append ("'").append (_strIssuerSPN).append ("')");

  1150.         return sb.toString();
  1151.     }

  1152.     /**
  1153.      * Get the Bond's identifier Parameters
  1154.      *
  1155.      * @return BondIdentifierParams object
  1156.      */

  1157.     public org.drip.product.params.IdentifierSet getIdentifierParams()
  1158.     {
  1159.         org.drip.product.params.IdentifierSet idParams = new org.drip.product.params.IdentifierSet (_strISIN,
  1160.             _strCUSIP, _strISIN, _strTicker);

  1161.         return idParams.validate() ? idParams : null;
  1162.     }

  1163.     /**
  1164.      * Get the Bond's Coupon Parameters
  1165.      *
  1166.      * @return BondCouponParams object
  1167.      */

  1168.     public org.drip.product.params.CouponSetting getCouponParams()
  1169.     {
  1170.         org.drip.product.params.CouponSetting cpnParams = new org.drip.product.params.CouponSetting
  1171.             (null, _strCouponType, _dblCoupon, java.lang.Double.NaN, java.lang.Double.NaN);

  1172.         return cpnParams.validate() ? cpnParams : null;
  1173.     }

  1174.     /**
  1175.      * Get the Bond's Floater Parameters
  1176.      *
  1177.      * @return BondFloaterParams object
  1178.      */

  1179.     public org.drip.product.params.FloaterSetting getFloaterParams()
  1180.     {
  1181.         if (!_bIsFloater) return null;

  1182.         org.drip.product.params.FloaterSetting fltParams = new org.drip.product.params.FloaterSetting (
  1183.             org.drip.state.identifier.ForwardLabel.Standard (_strRateIndex),
  1184.             _strFloatCouponConvention,
  1185.             _dblFloatSpread,
  1186.             _dblCurrentCoupon
  1187.         );

  1188.         return fltParams.validate() ? fltParams : null;
  1189.     }

  1190.     /**
  1191.      * Get the Bond's Market Convention
  1192.      *
  1193.      * @return MarketConvention object
  1194.      */

  1195.     public org.drip.product.params.QuoteConvention getMarketConvention()
  1196.     {
  1197.         org.drip.product.params.QuoteConvention mktConv = new org.drip.product.params.QuoteConvention (null,
  1198.             _strCalculationType, _dtFirstSettle.julian(), _dblRedemptionValue, 0, "",
  1199.                 org.drip.analytics.daycount.Convention.DATE_ROLL_ACTUAL);

  1200.         return mktConv.validate() ? mktConv : null;
  1201.     }

  1202.     /**
  1203.      * Get the Bond's Credit Component Parameters
  1204.      *
  1205.      * @return CompCRValParams object
  1206.      */

  1207.     public org.drip.product.params.CreditSetting getCRValuationParams()
  1208.     {
  1209.         org.drip.product.params.CreditSetting crValParams = new org.drip.product.params.CreditSetting (30,
  1210.             java.lang.Double.NaN, true, "", true);

  1211.         return crValParams.validate() ? crValParams : null;
  1212.     }

  1213.     /**
  1214.      * Get the Bond's CF termination event Parameters
  1215.      *
  1216.      * @return BondCFTerminationEvent object
  1217.      */

  1218.     public org.drip.product.params.TerminationSetting getCFTEParams()
  1219.     {
  1220.         org.drip.product.params.TerminationSetting cfteParams = new
  1221.             org.drip.product.params.TerminationSetting (_bIsPerpetual, _bIsDefaulted, _bHasBeenCalled, null);

  1222.         return cfteParams.validate() ? cfteParams : null;
  1223.     }

  1224.     /**
  1225.      * Get the Bond's Notional Parameters
  1226.      *
  1227.      * @return BondNotionalParams object
  1228.      */

  1229.     public org.drip.product.params.NotionalSetting getNotionalParams()
  1230.     {
  1231.         org.drip.product.params.NotionalSetting notlParams = new org.drip.product.params.NotionalSetting
  1232.             (100., _strRedemptionCurrency, null,
  1233.                 org.drip.product.params.NotionalSetting.PERIOD_AMORT_AT_START, false);

  1234.         return notlParams.validate() ? notlParams : null;
  1235.     }

  1236.     /**
  1237.      * Get the Bond's Period Generation Parameters
  1238.      *
  1239.      * @return BondPeriodGenerationParams object
  1240.      */

  1241.     public org.drip.product.params.BondStream getPeriodGenParams()
  1242.     {
  1243.         return org.drip.product.params.BondStream.Create (_dtMaturity.julian(),
  1244.             _dtInterestAccrualStart.julian(), null == _dtFinalMaturity ? java.lang.Integer.MIN_VALUE :
  1245.                 _dtFinalMaturity.julian(), null == _dtFirstCoupon ? java.lang.Integer.MIN_VALUE :
  1246.                     _dtFirstCoupon.julian(), _dtInterestAccrualStart.julian(), _iCouponFreq,
  1247.                         _dblCurrentCoupon, _strDayCountCode, _strDayCountCode, null, null, null, null, null,
  1248.                             null, null, null, _strMaturityType, false, _strCouponCurrency,
  1249.                                 _strCouponCurrency, !org.drip.numerical.common.StringUtil.IsEmpty (_strRateIndex)
  1250.                                     ? org.drip.state.identifier.ForwardLabel.Standard (_strRateIndex) : null,
  1251.                                         !org.drip.numerical.common.StringUtil.IsEmpty (_strIssuerSPN) ?
  1252.                                             org.drip.state.identifier.EntityCDSLabel.Standard (_strIssuerSPN,
  1253.                                                 _strCouponCurrency) : null);
  1254.     }

  1255.     /**
  1256.      * Create an SQL Delete statement from the object's state
  1257.      *
  1258.      * @return String representing the SQL Delete
  1259.      */

  1260.     public java.lang.String makeSQLDelete()
  1261.     {
  1262.         java.lang.StringBuilder sb = new java.lang.StringBuilder();

  1263.         sb.append ("delete from BondValData where ISIN = '").append (_strISIN).append
  1264.             ("' or CUSIP = '").append (_strCUSIP).append ("'");

  1265.         return sb.toString();
  1266.     }
  1267. }