예제 #1
0
        public void Curve_Building(List <double> QuotedSpot, List <double> QuotedSpread, double Spread_traded, double Upfront)
        {
            OMLib.Conventions.DayCount.Actual365 dayCounter = new OMLib.Conventions.DayCount.Actual365();

            //Build interest rate curve, discount curve
            InterestRateCurve  IRC = new InterestRateCurve();
            YieldTermStructure yt  = new YieldTermStructure(this.tradedate);

            yt = IRC.calculation(tradedate, QuotedSpot); //return a discounting curve
            this.Jump_Nodes = IRC.Nodes;
            this.yieldcurve = yt;
            // Build Payment Schedule
            List <ZeroRates> zero_rates = new List <ZeroRates>(yt.jumps_.Count);

            for (int i = 0; i < yt.t.Count; i++)
            {
                ZeroRates temp = new ZeroRates();
                temp.YearFraction = yt.t[i];
                temp.Rate         = yt.getKnotZeroRates()[i];
                zero_rates.Add(temp);
            }
            this.zero_rates = zero_rates;


            // Implied hazard rates from quoted spreads.
            hazardratecurve(yt, dayCounter, QuotedSpot, QuotedSpread, this.PremiumRate, Spread_traded, Upfront, this.Maturity, this.firstpaymentdate,
                            this.evalDate, this.formerpaymentdate, this.Frequency, this.Recovery);
            double k = piecewiseHazardRate.SurvivalProb(new DateTime(2021, 06, 20));

            // Build Yield Curve / Credit Curve to be output


            curve_output(yt, this.piecewiseHazardRate);
        }
예제 #2
0
        /**
         * The change in the intrinsic value of a CDS index when the yield curve is bumped by 1bps.
         * If the index is priced as a single name CDS, use {@link InterestRateSensitivityCalculator}.
         *
         * @param indexCDS The CDS index
         * @param indexCoupon The index coupon
         * @param yieldCurve The yield curve
         * @param intrinsicData Credit curves, weights and recovery rates of the intrinsic names
         * @return parallel IR01
         */
        public double parallelIR01(
            CDS indexCDS,
            double indexCoupon,
            YieldTermStructure yieldCurve,
            IntrinsicIndexDataBundle intrinsicData)
        {
            double pv     = indexPV(indexCDS, indexCoupon, yieldCurve, intrinsicData, CdsPriceType.DIRTY);
            int    nKnots = yieldCurve.t.Count;

            double[] rates = yieldCurve.getKnotZeroRates().ToArray();
            for (int i = 0; i < nKnots; ++i)
            {
                rates[i] += ONE_BPS;
            }
            YieldTermStructure yieldCurveUp = yieldCurve.withRates(rates.ToList());
            double             pvUp         = indexPV(indexCDS, indexCoupon, yieldCurveUp, intrinsicData, CdsPriceType.DIRTY);

            return(pvUp - pv);
        }