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

            assertEquals(computed, expected, TOL);
            assertEquals(computedMf, expectedMf, TOL);
        }
 private double[] getStandardQuoteForm(ResolvedCdsTrade calibrationCds, CdsQuote marketQuote, LocalDate valuationDate, CreditDiscountFactors discountFactors, RecoveryRates recoveryRates, bool computeJacobian, ReferenceData refData)
 {
     double[] res = new double[3];
     res[2] = 1d;
     if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.PAR_SPREAD))
     {
         res[0] = marketQuote.QuotedValue;
     }
     else if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.QUOTED_SPREAD))
     {
         double     qSpread                 = marketQuote.QuotedValue;
         CurveName  curveName               = CurveName.of("quoteConvertCurve");
         NodalCurve tempCreditCurve         = calibrate(ImmutableList.of(calibrationCds), DoubleArray.of(qSpread), DoubleArray.of(0d), curveName, valuationDate, discountFactors, recoveryRates, refData);
         Currency   currency                = calibrationCds.Product.Currency;
         StandardId legalEntityId           = calibrationCds.Product.LegalEntityId;
         ImmutableCreditRatesProvider rates = ImmutableCreditRatesProvider.builder().valuationDate(valuationDate).discountCurves(ImmutableMap.of(currency, discountFactors)).recoveryRateCurves(ImmutableMap.of(legalEntityId, recoveryRates)).creditCurves(ImmutableMap.of(Pair.of(legalEntityId, currency), LegalEntitySurvivalProbabilities.of(legalEntityId, IsdaCreditDiscountFactors.of(currency, valuationDate, tempCreditCurve)))).build();
         res[0] = calibrationCds.Product.FixedRate;
         res[1] = tradePricer.price(calibrationCds, rates, PriceType.CLEAN, refData);
         if (computeJacobian)
         {
             CurrencyParameterSensitivities pufSensi = rates.parameterSensitivity(tradePricer.priceSensitivity(calibrationCds, rates, refData));
             CurrencyParameterSensitivities spSensi  = rates.parameterSensitivity(tradePricer.parSpreadSensitivity(calibrationCds, rates, refData));
             res[2] = spSensi.getSensitivity(curveName, currency).Sensitivity.get(0) / pufSensi.getSensitivity(curveName, currency).Sensitivity.get(0);
         }
     }
     else if (marketQuote.QuoteConvention.Equals(CdsQuoteConvention.POINTS_UPFRONT))
     {
         res[0] = calibrationCds.Product.FixedRate;
         res[1] = marketQuote.QuotedValue;
     }
     else
     {
         throw new System.ArgumentException("Unknown CDSQuoteConvention type " + marketQuote.GetType());
     }
     return(res);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Computes the points upfront.
 /// <para>
 /// The points upfront quote is usually expressed in percentage.
 /// Here a fraction of notional is returned, e.g., 0.01 is 1(%) points up-front
 /// </para>
 /// <para>
 /// The relevant credit curve must be pre-calibrated and stored in {@code ratesProvider}.
 ///
 /// </para>
 /// </summary>
 /// <param name="trade">  the trade </param>
 /// <param name="ratesProvider">  the rates provider </param>
 /// <param name="refData">  the reference data </param>
 /// <returns> the points upfront </returns>
 public virtual double pointsUpfront(ResolvedCdsTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData)
 {
     return(pricer.price(trade, ratesProvider, PriceType.CLEAN, refData));
 }