/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(ResolvedCdsIndexTrade beanToCopy) { this.info = beanToCopy.getInfo(); this.product = beanToCopy.getProduct(); this.upfrontFee = beanToCopy.upfrontFee; }
/** * Calculates the expected loss of the underlying product. * <p> * The expected loss is the (undiscounted) expected default settlement value paid by the protection seller. * The resulting value is always positive. * * @param trade the trade * @param ratesProvider the rates provider * @return the recovery01 */ public CurrencyAmount expectedLoss( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider) { return productPricer.expectedLoss(trade.getProduct(), ratesProvider); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 3237038: // info return ((ResolvedCdsIndexTrade) bean).getInfo(); case -309474065: // product return ((ResolvedCdsIndexTrade) bean).getProduct(); case 963468344: // upfrontFee return ((ResolvedCdsIndexTrade) bean).upfrontFee; } return super.propertyGet(bean, propertyName, quiet); }
/** * Computes parallel CS01 for CDS index using a single credit curve. * <p> * This is coherent to the pricer {@link IsdaHomogenousCdsIndexTradePricer}. * The relevant credit curve must be stored in {@code RatesProvider}. * <p> * The CDS index trades used in the curve calibration are reused as bucket CDS index by this method. * Thus the credit curve must store {@link ResolvedTradeParameterMetadata}. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the parallel CS01 */ public CurrencyAmount parallelCs01( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { List<ResolvedCdsIndexTrade> bucketCdsIndex = getBucketCdsIndex(trade.getProduct(), ratesProvider); return parallelCs01(trade, bucketCdsIndex, ratesProvider, refData); }
/** * Computes bucketed CS01 for CDS index using a single credit curve. * <p> * This is coherent to the pricer {@link IsdaHomogenousCdsIndexTradePricer}. * The relevant credit curve must be stored in {@code RatesProvider}. * <p> * The CDS index trades used in the curve calibration are reused as bucket CDS index by this method. * Thus the credit curve must store {@link ResolvedTradeParameterMetadata}. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the bucketed CS01 */ public CurrencyParameterSensitivity bucketedCs01( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { List<ResolvedCdsIndexTrade> bucketCdsIndex = getBucketCdsIndex(trade.getProduct(), ratesProvider); return bucketedCs01(trade, bucketCdsIndex, ratesProvider, refData); }
/** * Calculates the par spread of the underlying product. * <p> * The par spread is a coupon rate such that the clean price is 0. * The result is represented in decimal form. * <p> * This is coherent to {@link #price(ResolvedCdsIndexTrade, CreditRatesProvider, PriceType, ReferenceData)}. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the par spread */ public double parSpread( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.parSpread(trade.getProduct(), ratesProvider, settlementDate, refData); }
/** * Calculates the jump-to-default of the underlying product. * <p> * The jump-to-default is the value of the product in case of immediate default of a constituent single name. * <p> * Under the homogeneous pool assumption, the jump-to-default values are the same for all of the undefaulted names, * and zero for defaulted names. Thus the resulting object contains a single number. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the recovery01 */ public JumpToDefault jumpToDefault( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.jumpToDefault(trade.getProduct(), ratesProvider, settlementDate, refData); }
/** * Calculates the price of the underlying product, which is 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. * <p> * This is coherent to {@link #presentValueOnSettle(ResolvedCdsIndexTrade, CreditRatesProvider, PriceType, ReferenceData)}. * * @param trade the trade * @param ratesProvider the rates provider * @param priceType the price type * @param refData the reference data * @return the price */ public double price( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.price(trade.getProduct(), ratesProvider, settlementDate, priceType, refData); }
/** * Calculates the risky PV01 of the underlying product. * <p> * RPV01 is defined as minus of the present value sensitivity to coupon rate. * <p> * This is computed based on the settlement date rather than the valuation date. * * @param trade the trade * @param ratesProvider the rates provider * @param priceType the price type * @param refData the reference date * @return the RPV01 */ public CurrencyAmount rpv01OnSettle( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.rpv01(trade.getProduct(), ratesProvider, settlementDate, priceType, refData); }
/** * Calculates the recovery01 of the underlying product. * <p> * The recovery01 is defined as the present value sensitivity to the recovery rate. * Since the ISDA standard model requires the recovery rate to be constant throughout the lifetime of the CDS, * one currency amount is returned by this method. * <p> * This is computed based on the settlement date rather than the valuation date. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the recovery01 */ public CurrencyAmount recovery01OnSettle( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.recovery01(trade.getProduct(), ratesProvider, settlementDate, refData); }
/** * Calculates the present value of the underlying product. * <p> * The present value is computed based on the settlement date rather than the valuation date. * <p> * This method can calculate the clean or dirty present value, see {@link PriceType}. * If calculating the clean value, the accrued interest is calculated based on the step-in date. * * @param trade the trade * @param ratesProvider the rates provider * @param priceType the price type * @param refData the reference data * @return the price */ public CurrencyAmount presentValueOnSettle( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, PriceType priceType, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.presentValue(trade.getProduct(), ratesProvider, settlementDate, priceType, refData); }
private LocalDate calculateSettlementDate( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { return trade.getInfo().getSettlementDate() .orElse(trade.getProduct().calculateSettlementDateFromValuation(ratesProvider.getValuationDate(), refData)); }
/** * Calculates the price sensitivity of the underlying product. * <p> * The price sensitivity of the product is the sensitivity of price to the underlying curves. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the present value sensitivity */ public PointSensitivities priceSensitivity( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.priceSensitivity(trade.getProduct(), ratesProvider, settlementDate, refData).build(); }
/** * Calculates the par spread sensitivity of the underling product. * <p> * The par spread sensitivity of the product is the sensitivity of par spread to the underlying curves. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the present value sensitivity */ public PointSensitivities parSpreadSensitivity( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.parSpreadSensitivity(trade.getProduct(), ratesProvider, settlementDate, refData).build(); }
/** * Calculates the present value sensitivity of the underlying product. * <p> * The present value sensitivity of the product is the sensitivity of present value to the underlying curves. * The present value sensitivity is computed based on the settlement date rather than the valuation date. * <p> * This is coherent to {@link #presentValueOnSettle(ResolvedCdsIndexTrade, CreditRatesProvider, PriceType, ReferenceData)}. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the present value sensitivity */ public PointSensitivities presentValueOnSettleSensitivity( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { LocalDate settlementDate = calculateSettlementDate(trade, ratesProvider, refData); return productPricer.presentValueSensitivity(trade.getProduct(), ratesProvider, settlementDate, refData).build(); }
public void test_full_resolve() { ResolvedCdsIndexTrade test = sut() .resolve(REF_DATA); assertEquals(test.getProduct(), PRODUCT.resolve(REF_DATA)); assertEquals(test.getInfo(), TRADE_INFO); assertEquals(test.getUpfrontFee().get(), UPFRONT.resolve(REF_DATA)); }
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_min_resolve() { ResolvedCdsIndexTrade test = CdsIndexTrade.builder() .product(PRODUCT) .info(TRADE_INFO) .build() .resolve(REF_DATA); assertEquals(test.getProduct(), PRODUCT.resolve(REF_DATA)); assertEquals(test.getInfo(), TRADE_INFO); assertFalse(test.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 present value sensitivity of the trade. * <p> * The present value sensitivity of the trade is the sensitivity of present value to the underlying curves. * * @param trade the trade * @param ratesProvider the rates provider * @param refData the reference data * @return the present value sensitivity */ public PointSensitivities presentValueSensitivity( ResolvedCdsIndexTrade trade, CreditRatesProvider ratesProvider, ReferenceData refData) { PointSensitivityBuilder pvSensiProduct = productPricer.presentValueSensitivity( trade.getProduct(), ratesProvider, ratesProvider.getValuationDate(), refData); if (!trade.getUpfrontFee().isPresent()) { return pvSensiProduct.build(); } Payment upfront = trade.getUpfrontFee().get(); PointSensitivityBuilder pvUpfront = upfrontPricer.presentValueSensitivity( upfront, ratesProvider.discountFactors(upfront.getCurrency()).toDiscountFactors()); return pvSensiProduct.combinedWith(pvUpfront).build(); }