public virtual void test_resolve() { BusinessDayAdjustment bussAdj = BusinessDayAdjustment.of(FOLLOWING, SAT_SUN); ResolvedCds test = PRODUCT_STD.resolve(REF_DATA); int nDates = 44; LocalDate[] dates = new LocalDate[nDates]; for (int i = 0; i < nDates; ++i) { dates[i] = START_DATE.plusMonths(3 * i); } IList <CreditCouponPaymentPeriod> payments = new List <CreditCouponPaymentPeriod>(nDates - 1); for (int i = 0; i < nDates - 2; ++i) { LocalDate start = i == 0 ? dates[i] : bussAdj.adjust(dates[i], REF_DATA); LocalDate end = bussAdj.adjust(dates[i + 1], REF_DATA); payments.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end).unadjustedStartDate(dates[i]).unadjustedEndDate(dates[i + 1]).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end.minusDays(1)).paymentDate(end).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end)).build()); } LocalDate start = bussAdj.adjust(dates[nDates - 2], REF_DATA); LocalDate end = dates[nDates - 1]; payments.Add(CreditCouponPaymentPeriod.builder().startDate(start).endDate(end.plusDays(1)).unadjustedStartDate(dates[nDates - 2]).unadjustedEndDate(end).effectiveStartDate(start.minusDays(1)).effectiveEndDate(end).paymentDate(bussAdj.adjust(end, REF_DATA)).currency(USD).notional(NOTIONAL).fixedRate(COUPON).yearFraction(ACT_360.relativeYearFraction(start, end.plusDays(1))).build()); ResolvedCds expected = ResolvedCds.builder().buySell(BUY).legalEntityId(LEGAL_ENTITY).dayCount(ACT_360).paymentOnDefault(ACCRUED_PREMIUM).paymentPeriods(payments).protectionStart(BEGINNING).protectionEndDate(END_DATE).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); assertEquals(test, expected); }
public virtual 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[PAYMENTS.Count - 1].EffectiveEndDate).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[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); assertEquals(test, expected); }
private ResolvedCdsTrade(TradeInfo info, ResolvedCds product, Payment upfrontFee) { JodaBeanUtils.notNull(info, "info"); JodaBeanUtils.notNull(product, "product"); this.info = info; this.product = product; this.upfrontFee = upfrontFee; }
//------------------------------------------------------------------------- public virtual void coverage() { ResolvedCds test1 = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(BEGINNING).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); coverImmutableBean(test1); ResolvedCds test2 = ResolvedCds.builder().buySell(BuySell.SELL).dayCount(DayCounts.ACT_365F).legalEntityId(StandardId.of("OG", "EFG")).paymentOnDefault(PaymentOnDefault.NONE).protectionStart(ProtectionStartOfDay.NONE).paymentPeriods(PAYMENTS[0]).protectionEndDate(PAYMENTS[0].EffectiveEndDate).settlementDateOffset(DaysAdjustment.NONE).stepinDateOffset(DaysAdjustment.NONE).build(); coverBeanEquals(test1, test2); }
//------------------------------------------------------------------------- public virtual void coverage() { ResolvedCdsTrade test1 = ResolvedCdsTrade.builder().product(PRODUCT).upfrontFee(UPFRONT).info(TRADE_INFO).build(); coverImmutableBean(test1); ResolvedCds product = Cds.of(BUY, LEGAL_ENTITY, USD, 1.e9, START_DATE, END_DATE, Frequency.P6M, SAT_SUN, 0.067).resolve(REF_DATA); ResolvedCdsTrade test2 = ResolvedCdsTrade.builder().product(product).info(TradeInfo.empty()).build(); coverBeanEquals(test1, test2); }
public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { ResolvedCds other = (ResolvedCds)obj; return(JodaBeanUtils.equal(buySell, other.buySell) && JodaBeanUtils.equal(legalEntityId, other.legalEntityId) && JodaBeanUtils.equal(paymentPeriods, other.paymentPeriods) && JodaBeanUtils.equal(protectionEndDate, other.protectionEndDate) && JodaBeanUtils.equal(dayCount, other.dayCount) && JodaBeanUtils.equal(paymentOnDefault, other.paymentOnDefault) && JodaBeanUtils.equal(protectionStart, other.protectionStart) && JodaBeanUtils.equal(stepinDateOffset, other.stepinDateOffset) && JodaBeanUtils.equal(settlementDateOffset, other.settlementDateOffset)); } return(false); }
public virtual void test_effectiveStartDate() { ResolvedCds test1 = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(BEGINNING).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); LocalDate date1 = LocalDate.of(2016, 3, 22); assertEquals(test1.calculateEffectiveStartDate(date1), date1.minusDays(1)); LocalDate date2 = LocalDate.of(2013, 9, 22); assertEquals(test1.calculateEffectiveStartDate(date2), START_DATE.minusDays(1)); ResolvedCds test2 = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(ProtectionStartOfDay.NONE).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); LocalDate date3 = LocalDate.of(2016, 3, 22); assertEquals(test2.calculateEffectiveStartDate(date3), date3); LocalDate date4 = LocalDate.of(2013, 9, 22); assertEquals(test2.calculateEffectiveStartDate(date4), START_DATE); }
public virtual void test_builder() { ResolvedCds test = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(BEGINNING).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); assertEquals(test.BuySell, BUY); assertEquals(test.Currency, USD); assertEquals(test.AccrualStartDate, PAYMENTS[0].StartDate); assertEquals(test.AccrualEndDate, PAYMENTS[42].EndDate); assertEquals(test.DayCount, ACT_360); assertEquals(test.FixedRate, COUPON); assertEquals(test.LegalEntityId, LEGAL_ENTITY); assertEquals(test.Notional, NOTIONAL); assertEquals(test.PaymentOnDefault, ACCRUED_PREMIUM); assertEquals(test.PaymentPeriods, PAYMENTS); assertEquals(test.ProtectionEndDate, PAYMENTS[42].EffectiveEndDate); assertEquals(test.SettlementDateOffset, SETTLE_DAY_ADJ); assertEquals(test.ProtectionStart, BEGINNING); assertEquals(test.StepinDateOffset, STEPIN_DAY_ADJ); }
public virtual void test_accruedYearFraction() { double eps = 1.0e-15; ResolvedCds test = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(BEGINNING).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); double accStart = test.accruedYearFraction(START_DATE.minusDays(1)); double accNextMinusOne = test.accruedYearFraction(START_DATE.plusMonths(3).minusDays(1)); double accNext = test.accruedYearFraction(START_DATE.plusMonths(3)); double accNextOne = test.accruedYearFraction(START_DATE.plusMonths(3).plusDays(1)); double accMod = test.accruedYearFraction(START_DATE.plusYears(1)); double accEnd = test.accruedYearFraction(END_DATE); double accEndOne = test.accruedYearFraction(END_DATE.plusDays(1)); assertEquals(accStart, 0d); assertEquals(accNext, 0d); assertEquals(accNextMinusOne, ACT_360.relativeYearFraction(START_DATE, START_DATE.plusMonths(3).minusDays(1)), eps); assertEquals(accNextOne, 1d / 360d, eps); // 2.x assertEquals(accMod, 0.24722222222222223, eps); assertEquals(accEnd, 0.25555555555555554, eps); assertEquals(accEndOne, 0.25833333333333336, eps); }
public override Builder set(string propertyName, object newValue) { switch (propertyName.GetHashCode()) { case 3237038: // info this.info_Renamed = (TradeInfo)newValue; break; case -309474065: // product this.product_Renamed = (ResolvedCds)newValue; break; case 963468344: // upfrontFee this.upfrontFee_Renamed = (Payment)newValue; break; default: throw new NoSuchElementException("Unknown property: " + propertyName); } return(this); }
public virtual void test_serialization() { ResolvedCds test = ResolvedCds.builder().buySell(BUY).dayCount(ACT_360).legalEntityId(LEGAL_ENTITY).paymentOnDefault(ACCRUED_PREMIUM).protectionStart(BEGINNING).paymentPeriods(PAYMENTS).protectionEndDate(PAYMENTS[PAYMENTS.Count - 1].EffectiveEndDate).settlementDateOffset(SETTLE_DAY_ADJ).stepinDateOffset(STEPIN_DAY_ADJ).build(); assertSerialization(test); }
/// <summary> /// Sets the resolved CDS product. /// <para> /// The product captures the contracted financial details of the trade. /// </para> /// </summary> /// <param name="product"> the new value, not null </param> /// <returns> this, for chaining, not null </returns> public Builder product(ResolvedCds product) { JodaBeanUtils.notNull(product, "product"); this.product_Renamed = product; return(this); }
/// <summary> /// Restricted copy constructor. </summary> /// <param name="beanToCopy"> the bean to copy from, not null </param> internal Builder(ResolvedCdsTrade beanToCopy) { this.info_Renamed = beanToCopy.Info; this.product_Renamed = beanToCopy.Product; this.upfrontFee_Renamed = beanToCopy.upfrontFee; }