public virtual void test_createTrade_withFee() { TenorCdsTemplate base1 = TenorCdsTemplate.of(TENOR_10Y, CONV1); TenorCdsTemplate base2 = TenorCdsTemplate.of(AccrualStart.NEXT_DAY, TENOR_2Y, CONV2); LocalDate tradeDate = LocalDate.of(2015, 5, 5); AdjustablePayment payment1 = AdjustablePayment.of(EUR, NOTIONAL_2M, CONV1.SettlementDateOffset.adjust(tradeDate, REF_DATA)); AdjustablePayment payment2 = AdjustablePayment.of(USD, NOTIONAL_2M, CONV2.SettlementDateOffset.adjust(tradeDate, REF_DATA)); LocalDate startDate1 = date(2015, 3, 20); LocalDate endDate1 = date(2025, 6, 20); LocalDate startDate2 = date(2015, 5, 6); LocalDate endDate2 = date(2017, 6, 20); CdsTrade test1 = base1.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment1, REF_DATA); CdsTrade test2 = base2.createTrade(LEGAL_ENTITY, tradeDate, BUY, NOTIONAL_2M, 0.05d, payment2, REF_DATA); Cds expected1 = Cds.of(BUY, LEGAL_ENTITY, CONV1.Currency, NOTIONAL_2M, startDate1, endDate1, Frequency.P3M, CONV1.SettlementDateOffset.Calendar, 0.05d); PeriodicSchedule sch1 = expected1.PaymentSchedule; expected1 = expected1.toBuilder().paymentSchedule(sch1.toBuilder().startDateBusinessDayAdjustment(sch1.BusinessDayAdjustment).rollConvention(RollConventions.DAY_20).build()).build(); Cds expected2 = Cds.of(BUY, LEGAL_ENTITY, CONV2.Currency, NOTIONAL_2M, startDate2, endDate2, Frequency.P3M, CONV2.SettlementDateOffset.Calendar, 0.05d); PeriodicSchedule sch2 = expected2.PaymentSchedule; expected2 = expected2.toBuilder().paymentSchedule(sch2.toBuilder().startDateBusinessDayAdjustment(sch2.BusinessDayAdjustment).rollConvention(RollConventions.DAY_20).build()).build(); assertEquals(test1.Info.TradeDate, tradeDate); assertEquals(test1.UpfrontFee, payment1); assertEquals(test1.Product, expected1); assertEquals(test2.Info.TradeDate, tradeDate); assertEquals(test2.UpfrontFee, payment2); assertEquals(test2.Product, expected2); }
public virtual void test_of_accStart() { TenorCdsTemplate test = TenorCdsTemplate.of(AccrualStart.NEXT_DAY, TENOR_10Y, CONV2); assertEquals(test.AccrualStart, AccrualStart.NEXT_DAY); assertEquals(test.Tenor, TENOR_10Y); assertEquals(test.Convention, CONV2); }
//------------------------------------------------------------------------- public virtual void test_of() { TenorCdsTemplate test = TenorCdsTemplate.of(TENOR_10Y, CONV1); assertEquals(test.AccrualStart, AccrualStart.IMM_DATE); assertEquals(test.Tenor, TENOR_10Y); assertEquals(test.Convention, CONV1); }
//------------------------------------------------------------------------- public virtual void coverage() { TenorCdsTemplate test1 = TenorCdsTemplate.of(TENOR_10Y, CONV1); coverImmutableBean(test1); TenorCdsTemplate test2 = TenorCdsTemplate.of(AccrualStart.NEXT_DAY, TENOR_10Y, CONV2); coverBeanEquals(test1, test2); }
//----------------------------------------------------------------------- public override bool Equals(object obj) { if (obj == this) { return(true); } if (obj != null && obj.GetType() == this.GetType()) { TenorCdsTemplate other = (TenorCdsTemplate)obj; return(JodaBeanUtils.equal(accrualStart, other.accrualStart) && JodaBeanUtils.equal(tenor, other.tenor) && JodaBeanUtils.equal(convention, other.convention)); } return(false); }
public virtual void test_serialization() { TenorCdsTemplate test = TenorCdsTemplate.of(TENOR_10Y, CONV1); assertSerialization(test); }