/** * Calculates the price sensitivity of the product. * <p> * The price sensitivity of the product is the sensitivity of price to the underlying curves. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param refData the reference data * @return the present value sensitivity */ public PointSensitivityBuilder priceSensitivity( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, ReferenceData refData) { ResolvedCds cds = cdsIndex.toSingleNameCds(); return underlyingPricer.priceSensitivity(cds, ratesProvider, referenceDate, refData); }
/** * Calculates the par spread sensitivity of the product. * <p> * The par spread sensitivity of the product is the sensitivity of par spread to the underlying curves. * The resulting sensitivity is based on the currency of the CDS index product. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param refData the reference data * @return the par spread */ public PointSensitivityBuilder parSpreadSensitivity( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, ReferenceData refData) { ResolvedCds cds = cdsIndex.toSingleNameCds(); return underlyingPricer.parSpreadSensitivity(cds, ratesProvider, referenceDate, refData); }
/** * Calculates the par spread of the CDS index product. * <p> * The par spread is a coupon rate such that the clean PV is 0. * The result is represented in decimal form. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param refData the reference data * @return the par spread */ public double parSpread( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, ReferenceData refData) { ResolvedCds cds = cdsIndex.toSingleNameCds(); return underlyingPricer.parSpread(cds, ratesProvider, referenceDate, refData); }
/** * Calculates the price of the CDS index product, which is the minus of the present value per unit notional. * <p> * This method can calculate the clean or dirty price, see {@link PriceType}. * If calculating the clean price, the accrued interest is calculated based on the step-in date. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param priceType the price type * @param refData the reference data * @return the price */ public double price( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, PriceType priceType, ReferenceData refData) { ResolvedCds cds = cdsIndex.toSingleNameCds(); return underlyingPricer.price(cds, ratesProvider, referenceDate, priceType, refData); }
/** * Reduce this instance to {@code ResolvedCdsTrade}. * <p> * The resultant object is used for pricing CDS index trades under the homogeneous pool assumption on constituent * credit curves. * * @return the CDS trade */ public ResolvedCdsTrade toSingleNameCds() { return ResolvedCdsTrade.builder() .product(product.toSingleNameCds()) .info(info) .upfrontFee(upfrontFee) .build(); }
public void test_builder_min() { ResolvedCdsIndexTrade test = ResolvedCdsIndexTrade.builder() .product(PRODUCT) .info(TRADE_INFO) .build(); assertEquals(test.getProduct(), PRODUCT); assertEquals(test.getInfo(), TRADE_INFO); assertFalse(test.getUpfrontFee().isPresent()); ResolvedCdsTrade singleName = test.toSingleNameCds(); assertEquals(singleName.getProduct(), PRODUCT.toSingleNameCds()); assertEquals(singleName.getInfo(), TRADE_INFO); assertFalse(singleName.getUpfrontFee().isPresent()); }
public void test_builder_full() { ResolvedCdsIndexTrade test = ResolvedCdsIndexTrade.builder() .product(PRODUCT) .info(TRADE_INFO) .upfrontFee(UPFRONT) .build(); assertEquals(test.getProduct(), PRODUCT); assertEquals(test.getInfo(), TRADE_INFO); assertEquals(test.getUpfrontFee().get(), UPFRONT); ResolvedCdsTrade singleName = test.toSingleNameCds(); assertEquals(singleName.getProduct(), PRODUCT.toSingleNameCds()); assertEquals(singleName.getInfo(), TRADE_INFO); assertEquals(singleName.getUpfrontFee().get(), UPFRONT); }
/** * Calculates the expected loss of the CDS index product. * <p> * The expected loss is the (undiscounted) expected default settlement value paid by the protection seller. * The resulting value is always positive. * * @param cdsIndex the product * @param ratesProvider the rates provider * @return the expected loss */ public CurrencyAmount expectedLoss( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider) { if (isExpired(cdsIndex, ratesProvider)) { return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); } ResolvedCds cds = cdsIndex.toSingleNameCds(); double recoveryRate = underlyingPricer.recoveryRate(cds, ratesProvider); Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double survivalProbability = rates.getSecond().survivalProbability(cds.getProtectionEndDate()); double el = (1d - recoveryRate) * (1d - survivalProbability) * rates.getThird(); return CurrencyAmount.of(cds.getCurrency(), Math.abs(cds.getNotional()) * el); }
return JumpToDefault.of(currency, ImmutableMap.of(indexId, 0d)); ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate);
public void test_totoSingleNameCds() { ResolvedCdsIndex base = ResolvedCdsIndex.builder() .buySell(BUY) .dayCount(ACT_360) .cdsIndexId(INDEX_ID) .legalEntityIds(LEGAL_ENTITIES) .paymentOnDefault(ACCRUED_PREMIUM) .protectionStart(BEGINNING) .paymentPeriods(PAYMENTS) .protectionEndDate(PAYMENTS.get(PAYMENTS.size() - 1).getEffectiveEndDate()) .settlementDateOffset(SETTLE_DAY_ADJ) .stepinDateOffset(STEPIN_DAY_ADJ) .build(); ResolvedCds test = base.toSingleNameCds(); ResolvedCds expected = ResolvedCds.builder() .buySell(BUY) .dayCount(ACT_360) .legalEntityId(INDEX_ID) .paymentOnDefault(ACCRUED_PREMIUM) .protectionStart(BEGINNING) .paymentPeriods(PAYMENTS) .protectionEndDate(PAYMENTS.get(PAYMENTS.size() - 1).getEffectiveEndDate()) .settlementDateOffset(SETTLE_DAY_ADJ) .stepinDateOffset(STEPIN_DAY_ADJ) .build(); assertEquals(test, expected); }
/** * Calculates the risky PV01 of the CDS index product. * <p> * RPV01 is defined as minus of the present value sensitivity to coupon rate. * * @param cdsIndex the product * @param ratesProvider the rates provider * @param referenceDate the reference date * @param priceType the price type * @param refData the reference date * @return the RPV01 */ public CurrencyAmount rpv01( ResolvedCdsIndex cdsIndex, CreditRatesProvider ratesProvider, LocalDate referenceDate, PriceType priceType, ReferenceData refData) { if (isExpired(cdsIndex, ratesProvider)) { return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); } ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate); Triple<CreditDiscountFactors, LegalEntitySurvivalProbabilities, Double> rates = reduceDiscountFactors(cds, ratesProvider); double riskyAnnuity = underlyingPricer.riskyAnnuity( cds, rates.getFirst(), rates.getSecond(), referenceDate, stepinDate, effectiveStartDate, priceType); double amount = cds.getBuySell().normalize(cds.getNotional()) * riskyAnnuity * rates.getThird(); return CurrencyAmount.of(cds.getCurrency(), amount); }
return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate);
return PointSensitivityBuilder.none(); ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate);
return CurrencyAmount.of(cdsIndex.getCurrency(), 0d); ResolvedCds cds = cdsIndex.toSingleNameCds(); LocalDate stepinDate = cds.getStepinDateOffset().adjust(ratesProvider.getValuationDate(), refData); LocalDate effectiveStartDate = cds.calculateEffectiveStartDate(stepinDate);