public virtual void test_parSpread()
        {
            double computed   = PRICER.parSpread(TRADE, RATES_PROVIDER, REF_DATA);
            double expected   = PRICER_PRODUCT.parSpread(PRODUCT, RATES_PROVIDER, SETTLEMENT_DATE, REF_DATA);
            double computedMf = PRICER_MF.parSpread(TRADE_NO_SETTLE_DATE, RATES_PROVIDER, REF_DATA);
            double expectedMf = PRICER_PRODUCT_MF.parSpread(PRODUCT, RATES_PROVIDER, SETTLEMENT_DATE, REF_DATA);

            assertEquals(computed, expected, TOL);
            assertEquals(computedMf, expectedMf, TOL);
        }
Exemple #2
0
        /// <summary>
        /// Converts points upfront to quoted spread.
        /// <para>
        /// Thus {@code quote} must be {@code CdsQuoteConvention.POINTS_UPFRONT}.
        /// </para>
        /// <para>
        /// The relevant discount curve and recovery rate curve must be stored in {@code ratesProvider}.
        /// The credit curve is internally calibrated to convert one quote type to the other quote type.
        ///
        /// </para>
        /// </summary>
        /// <param name="trade">  the trade </param>
        /// <param name="quote">  the quote </param>
        /// <param name="ratesProvider">  the rates provider </param>
        /// <param name="refData">  the reference data </param>
        /// <returns> the quote </returns>
        public virtual CdsQuote quotedSpreadFromPointsUpfront(ResolvedCdsTrade trade, CdsQuote quote, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            ArgChecker.notNull(trade, "trade");
            ArgChecker.notNull(quote, "quote");
            ArgChecker.notNull(ratesProvider, "ratesProvider");
            ArgChecker.notNull(refData, "refData");
            ArgChecker.isTrue(quote.QuoteConvention.Equals(CdsQuoteConvention.POINTS_UPFRONT), "quote must be points upfront");

            ResolvedCds         product          = trade.Product;
            Currency            currency         = product.Currency;
            StandardId          legalEntityId    = product.LegalEntityId;
            LocalDate           valuationDate    = ratesProvider.ValuationDate;
            NodalCurve          creditCurve      = calibrator.calibrate(ImmutableList.of(trade), DoubleArray.of(product.FixedRate), DoubleArray.of(quote.QuotedValue), CurveName.of("temp"), valuationDate, ratesProvider.discountFactors(currency), ratesProvider.recoveryRates(legalEntityId), refData);
            CreditRatesProvider ratesProviderNew = ratesProvider.toImmutableCreditRatesProvider().toBuilder().creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, creditCurve)))).build();
            double sp = pricer.parSpread(trade, ratesProviderNew, refData);

            return(CdsQuote.of(CdsQuoteConvention.QUOTED_SPREAD, sp));
        }
Exemple #3
0
        protected internal virtual DoubleArray impliedSpread(IList <ResolvedCdsTrade> bucketCds, CreditRatesProvider ratesProvider, ReferenceData refData)
        {
            int size = bucketCds.Count;

            return(DoubleArray.of(size, n => pricer.parSpread(bucketCds[n], ratesProvider, refData)));
        }