Ejemplo n.º 1
0
        /**
         * Bootstrapper the credit curve from a single market CDS quote. Obviously the resulting credit (hazard)
         * curve will be flat.
         *
         * @param calibrationCDS The single market CDS - this is the reference instruments used to build the credit curve
         * @param marketQuote The market quote of the CDS
         * @param yieldCurve The yield (or discount) curve
         * @return The credit curve
         */
        public PiecewiseconstantHazardRate calibrateCreditCurve(
            CDS calibrationCDS,
            CdsQuoteConvention marketQuote,
            YieldTermStructure yieldCurve)
        {
            double puf    = 0.0;
            double coupon = 0.0;

            if (marketQuote is CdsParSpread)
            {
                puf    = 0.0;
                coupon = marketQuote.getCoupon();
            }
            else if (marketQuote is CdsQuotedSpread)
            {
                puf    = 0.0;
                coupon = ((CdsQuotedSpread)marketQuote).getQuotedSpread();
            }
            else if (marketQuote is PointsUpFront)
            {
                PointsUpFront temp = (PointsUpFront)marketQuote;
                puf    = temp.getPointsUpFront();
                coupon = temp.getCoupon();
            }

            return(calibrateCreditCurve(
                       new CDS[] { calibrationCDS }, new double[] { coupon }, yieldCurve, new double[] { puf }));
        }
Ejemplo n.º 2
0
        /**
         * Put any CDS market quote into the form needed for the curve builder,
         * namely coupon and points up-front (which can be zero).
         *
         * @param calibrationCDS
         * @param marketQuote
         * @param yieldCurve
         * @return The market quotes in the form required by the curve builder
         */
        private double[] getStandardQuoteForm(
            CDS calibrationCDS,
            CdsQuoteConvention marketQuote,
            YieldTermStructure yieldCurve)
        {
            AnalyticalCdsPricer pricer = new AnalyticalCdsPricer();

            double[] res = new double[2];
            if (marketQuote is CdsParSpread)
            {
                res[0] = marketQuote.getCoupon();
            }
            else if (marketQuote is CdsQuotedSpread)
            {
                CdsQuotedSpread             temp    = (CdsQuotedSpread)marketQuote;
                double                      coupon  = temp.getCoupon();
                double                      qSpread = temp.getQuotedSpread();
                PiecewiseconstantHazardRate cc      = calibrateCreditCurve(
                    new CDS[] { calibrationCDS }, new double[] { qSpread }, yieldCurve, new double[1]);
                res[0] = coupon;
                res[1] = pricer.pv(calibrationCDS, yieldCurve, cc, coupon, CdsPriceType.CLEAN);
            }
            else if (marketQuote is PointsUpFront)
            {
                PointsUpFront temp = (PointsUpFront)marketQuote;
                res[0] = temp.getCoupon();
                res[1] = temp.getPointsUpFront();
            }
            return(res);
        }