/** * Restricted copy constructor. * @param beanToCopy the bean to copy from, not null */ private Builder(CdsIndex beanToCopy) { this.buySell = beanToCopy.getBuySell(); this.cdsIndexId = beanToCopy.getCdsIndexId(); this.legalEntityIds = beanToCopy.getLegalEntityIds(); this.currency = beanToCopy.getCurrency(); this.notional = beanToCopy.getNotional(); this.paymentSchedule = beanToCopy.getPaymentSchedule(); this.fixedRate = beanToCopy.getFixedRate(); this.dayCount = beanToCopy.getDayCount(); this.paymentOnDefault = beanToCopy.getPaymentOnDefault(); this.protectionStart = beanToCopy.getProtectionStart(); this.stepinDateOffset = beanToCopy.getStepinDateOffset(); this.settlementDateOffset = beanToCopy.getSettlementDateOffset(); }
@Override public PortfolioItemSummary summarize() { // 2Y Buy USD 1mm INDEX / 1.5% : 21Jan18-21Jan20 PeriodicSchedule paymentSchedule = product.getPaymentSchedule(); StringBuilder buf = new StringBuilder(96); buf.append(SummarizerUtils.datePeriod(paymentSchedule.getStartDate(), paymentSchedule.getEndDate())); buf.append(' '); buf.append(product.getBuySell()); buf.append(' '); buf.append(SummarizerUtils.amount(product.getCurrency(), product.getNotional())); buf.append(' '); buf.append(product.getCdsIndexId().getValue()); buf.append(" / "); buf.append(SummarizerUtils.percent(product.getFixedRate())); buf.append(" : "); buf.append(SummarizerUtils.dateRange(paymentSchedule.getStartDate(), paymentSchedule.getEndDate())); return SummarizerUtils.summary(this, ProductType.CDS_INDEX, buf.toString(), product.getCurrency()); }
PeriodicSchedule sch = PeriodicSchedule.of(startDate, endDate, P3M, BusinessDayAdjustment.NONE, SHORT_INITIAL, RollConventions.NONE); CdsIndex test = CdsIndex.builder() .paymentSchedule(sch) .buySell(SELL) .stepinDateOffset(STEPIN_DAY_ADJ) .build(); assertEquals(test.getPaymentSchedule(), sch); assertEquals(test.getBuySell(), SELL); assertEquals(test.getCurrency(), JPY); assertEquals(test.getDayCount(), ACT_365F); assertEquals(test.getFixedRate(), COUPON); assertEquals(test.getCdsIndexId(), INDEX_ID); assertEquals(test.getLegalEntityIds(), LEGAL_ENTITIES); assertEquals(test.getNotional(), NOTIONAL); assertEquals(test.getPaymentOnDefault(), PaymentOnDefault.NONE); assertEquals(test.getProtectionStart(), ProtectionStartOfDay.NONE); assertEquals(test.getSettlementDateOffset(), SETTLE_DAY_ADJ); assertEquals(test.getStepinDateOffset(), STEPIN_DAY_ADJ); assertEquals(test.isCrossCurrency(), false); assertEquals(test.allPaymentCurrencies(), ImmutableSet.of(JPY)); assertEquals(test.allCurrencies(), ImmutableSet.of(JPY));
if (indexOptEl.isPresent()) { String indexName = indexOptEl.get().getChild("indexName").getContent(); CdsIndex cdsIndex = CdsIndex.builder() .buySell(buySell) .cdsIndexId(StandardId.of("CDX-Name", indexName))
CdsIndexCalibrationTrade trade = node.trade(quantity, marketData, REF_DATA); CdsTrade cdsTrade = TEMPLATE.createTrade(INDEX_ID, VAL_DATE, SELL, -quantity, 0.01, REF_DATA); CdsIndex cdsIndex = CdsIndex.of( SELL, INDEX_ID, LEGAL_ENTITIES, TEMPLATE.getConvention().getCurrency(), -quantity, date(2015, 6, 20), date(2025, 6, 20), Frequency.P3M, TEMPLATE.getConvention().getSettlementDateOffset().getCalendar(), 0.01); CdsIndex cdsIndexMod = cdsIndex.toBuilder() .paymentSchedule( cdsIndex.getPaymentSchedule().toBuilder() .rollConvention(RollConventions.DAY_20) .startDateBusinessDayAdjustment(cdsIndex.getPaymentSchedule().getBusinessDayAdjustment()) .build()) .build(); CdsTrade cdsTrade1 = TEMPLATE.createTrade(INDEX_ID, VAL_DATE, SELL, -quantity, rate, REF_DATA); CdsIndexCalibrationTrade trade1 = node1.trade(quantity, marketData, REF_DATA); CdsIndex cdsIndex1 = CdsIndex.of( SELL, INDEX_ID, LEGAL_ENTITIES, TEMPLATE.getConvention().getCurrency(), -quantity, date(2015, 6, 20), date(2025, 6, 20), Frequency.P3M, TEMPLATE.getConvention().getSettlementDateOffset().getCalendar(), rate); CdsIndex cdsIndexMod1 = cdsIndex1.toBuilder() .paymentSchedule( cdsIndex.getPaymentSchedule().toBuilder() .rollConvention(RollConventions.DAY_20) .startDateBusinessDayAdjustment(cdsIndex1.getPaymentSchedule().getBusinessDayAdjustment()) .build()) .build();
@Override public PortfolioItemSummary summarize() { String description = "CDS Index calibration trade"; Currency currency = underlyingTrade.getProduct().getCurrency(); return SummarizerUtils.summary(this, ProductType.CALIBRATION, description, currency); }
public void cdsIndex01() { String location = "classpath:com/opengamma/strata/loader/fpml/cdindex-ex01-cdx.xml"; ByteSource resource = ResourceLocator.of(location).getByteSource(); List<Trade> trades = FpmlDocumentParser.of(FpmlPartySelector.matching("Party2")).parseTrades(resource); assertEquals(trades.size(), 1); CdsIndexTrade cdsTrade = (CdsIndexTrade) trades.get(0); assertEquals(cdsTrade.getInfo().getTradeDate(), Optional.of(date(2005, 1, 24))); CdsIndex expected = CdsIndex.builder() .buySell(BUY) .cdsIndexId(StandardId.of("CDX-Name", "Dow Jones CDX NA IG.2")) .currency(USD) .notional(25000000d) .paymentSchedule(PeriodicSchedule.builder() .startDate(date(2004, 3, 23)) .endDate(date(2009, 3, 20)) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .businessDayAdjustment(BusinessDayAdjustment.NONE) .frequency(Frequency.P3M) .build()) .fixedRate(0.0060) .dayCount(ACT_360) .build(); assertEqualsBean(cdsTrade.getProduct(), expected); assertEquals(cdsTrade.getUpfrontFee().get(), AdjustablePayment.of(USD, 16000, AdjustableDate.of(date(2004, 3, 23)))); }
@Override protected Object propertyGet(Bean bean, String propertyName, boolean quiet) { switch (propertyName.hashCode()) { case 244977400: // buySell return ((CdsIndex) bean).getBuySell(); case -464117509: // cdsIndexId return ((CdsIndex) bean).getCdsIndexId(); case 1085098268: // legalEntityIds return ((CdsIndex) bean).getLegalEntityIds(); case 575402001: // currency return ((CdsIndex) bean).getCurrency(); case 1585636160: // notional return ((CdsIndex) bean).getNotional(); case -1499086147: // paymentSchedule return ((CdsIndex) bean).getPaymentSchedule(); case 747425396: // fixedRate return ((CdsIndex) bean).getFixedRate(); case 1905311443: // dayCount return ((CdsIndex) bean).getDayCount(); case -480203780: // paymentOnDefault return ((CdsIndex) bean).getPaymentOnDefault(); case 2103482633: // protectionStart return ((CdsIndex) bean).getProtectionStart(); case 852621746: // stepinDateOffset return ((CdsIndex) bean).getStepinDateOffset(); case 135924714: // settlementDateOffset return ((CdsIndex) bean).getSettlementDateOffset(); } return super.propertyGet(bean, propertyName, quiet); }
public void coverage() { coverImmutableBean(PRODUCT); CdsIndex other = CdsIndex.builder() .buySell(SELL) .cdsIndexId(StandardId.of("OG", "AA-INDEX")) .legalEntityIds(ImmutableList.of(StandardId.of("OG", "ABC1"), StandardId.of("OG", "ABC2"))) .currency(JPY) .notional(1d) .paymentSchedule( PeriodicSchedule.of( LocalDate.of(2014, 1, 4), LocalDate.of(2020, 11, 20), P6M, BusinessDayAdjustment.of(BusinessDayConventions.FOLLOWING, JPTO), StubConvention.SHORT_FINAL, RollConventions.NONE)) .fixedRate(0.01) .dayCount(ACT_365F) .paymentOnDefault(PaymentOnDefault.NONE) .protectionStart(ProtectionStartOfDay.NONE) .settlementDateOffset(DaysAdjustment.NONE) .stepinDateOffset(DaysAdjustment.NONE) .build(); coverBeanEquals(PRODUCT, other); }
public void test_of() { BusinessDayAdjustment bussAdj = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN); PeriodicSchedule expected = PeriodicSchedule.builder() .startDate(START_DATE) .endDate(END_DATE) .businessDayAdjustment(bussAdj) .startDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .endDateBusinessDayAdjustment(BusinessDayAdjustment.NONE) .frequency(P3M) .rollConvention(RollConventions.NONE) .stubConvention(SMART_INITIAL) .build(); assertEquals(PRODUCT.getPaymentSchedule(), expected); assertEquals(PRODUCT.getBuySell(), BUY); assertEquals(PRODUCT.getCurrency(), USD); assertEquals(PRODUCT.getDayCount(), ACT_360); assertEquals(PRODUCT.getFixedRate(), COUPON); assertEquals(PRODUCT.getCdsIndexId(), INDEX_ID); assertEquals(PRODUCT.getLegalEntityIds(), LEGAL_ENTITIES); assertEquals(PRODUCT.getNotional(), NOTIONAL); assertEquals(PRODUCT.getPaymentOnDefault(), ACCRUED_PREMIUM); assertEquals(PRODUCT.getProtectionStart(), BEGINNING); assertEquals(PRODUCT.getSettlementDateOffset(), SETTLE_DAY_ADJ); assertEquals(PRODUCT.getStepinDateOffset(), STEPIN_DAY_ADJ); CdsIndex test = CdsIndex.of(BUY, INDEX_ID, LEGAL_ENTITIES, USD, NOTIONAL, START_DATE, END_DATE, P3M, SAT_SUN, COUPON); assertEquals(test, PRODUCT); }
CdsIndexTrade cdsIndex = CdsIndexTrade.builder() .info(cdsTrade.getInfo()) .product(CdsIndex.builder() .buySell(cdsProduct.getBuySell()) .currency(cdsProduct.getCurrency())