public void test_serialization() { NotionalSchedule test = NotionalSchedule.of(GBP, 1000d); assertSerialization(test); }
public void test_of_null() { assertThrowsIllegalArg(() -> NotionalSchedule.of(null)); assertThrowsIllegalArg(() -> NotionalSchedule.of(null, 1000d)); assertThrowsIllegalArg(() -> NotionalSchedule.of(GBP, null)); assertThrowsIllegalArg(() -> NotionalSchedule.of(null, ValueSchedule.of(1000d))); assertThrowsIllegalArg(() -> NotionalSchedule.of(null, null)); }
public void test_of_CurrencyAmount() { NotionalSchedule test = NotionalSchedule.of(CA_GBP_1000); assertEquals(test.getCurrency(), GBP); assertEquals(test.getAmount(), ValueSchedule.of(1000d)); assertEquals(test.getFxReset(), Optional.empty()); assertEquals(test.isInitialExchange(), false); assertEquals(test.isIntermediateExchange(), false); assertEquals(test.isFinalExchange(), false); }
public void test_of_CurrencyAndAmount() { NotionalSchedule test = NotionalSchedule.of(GBP, 1000d); assertEquals(test.getCurrency(), GBP); assertEquals(test.getAmount(), ValueSchedule.of(1000d)); assertEquals(test.getFxReset(), Optional.empty()); assertEquals(test.isInitialExchange(), false); assertEquals(test.isIntermediateExchange(), false); assertEquals(test.isFinalExchange(), false); }
public void test_of_CurrencyAndValueSchedule() { ValueSchedule valueSchedule = ValueSchedule.of(1000d, ValueStep.of(1, ValueAdjustment.ofReplace(2000d))); NotionalSchedule test = NotionalSchedule.of(GBP, valueSchedule); assertEquals(test.getCurrency(), GBP); assertEquals(test.getAmount(), valueSchedule); assertEquals(test.getFxReset(), Optional.empty()); assertEquals(test.isInitialExchange(), false); assertEquals(test.isIntermediateExchange(), false); assertEquals(test.isFinalExchange(), false); }
public void test_collectIndices_simple() { RateCalculationSwapLeg test = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .startDate(DATE_01_05) .endDate(DATE_04_05) .frequency(P1M) .businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P1M) .paymentDateOffset(PLUS_TWO_DAYS) .build()) .notionalSchedule(NotionalSchedule.of(GBP, 1000d)) .calculation(IborRateCalculation.builder() .dayCount(DayCounts.ACT_365F) .index(GBP_LIBOR_3M) .fixingDateOffset(MINUS_TWO_DAYS) .build()) .build(); ImmutableSet.Builder<Index> builder = ImmutableSet.builder(); test.collectIndices(builder); assertEquals(builder.build(), ImmutableSet.of(GBP_LIBOR_3M)); assertEquals(test.allIndices(), ImmutableSet.of(GBP_LIBOR_3M)); assertEquals(test.allCurrencies(), ImmutableSet.of(GBP)); }
public void test_toLeg1() { FixedRateSwapLegConvention base = FixedRateSwapLegConvention.of(GBP, ACT_365F, P3M, BDA_MOD_FOLLOW); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(P3M) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .stubConvention(StubConvention.SMART_INITIAL) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P3M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(FixedRateCalculation.of(0.25d, ACT_365F)) .build(); assertEquals(test, expected); }
.rate(ValueSchedule.of(0.025d)) .build(); NotionalSchedule notionalSchedule = NotionalSchedule.of(GBP, 1000d); RateCalculationSwapLeg test = RateCalculationSwapLeg.builder() .payReceive(PAY)
public void test_toLeg() { InflationRateSwapLegConvention base = InflationRateSwapLegConvention.of(GB_HICP, LAG_3M, MONTHLY, BDA_MOD_FOLLOW); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg( startDate, endDate, PAY, NOTIONAL_2M); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(Frequency.TERM) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(Frequency.TERM) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(InflationRateCalculation.of(GB_HICP, 3, MONTHLY)) .build(); assertEquals(test, expected); }
public void test_toLeg() { IborRateSwapLegConvention base = IborRateSwapLegConvention.builder() .index(GBP_LIBOR_3M) .build(); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(P3M) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P3M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(IborRateCalculation.of(GBP_LIBOR_3M)) .build(); assertEquals(test, expected); }
.paymentDateOffset(DaysAdjustment.ofCalendarDays(0, BusinessDayAdjustment.of(MODIFIED_FOLLOWING, AUSY))) .build()) .notionalSchedule(NotionalSchedule.of(AUD, 500000000)) .calculation(IborRateCalculation.builder() .index(AUD_BBSW_3M)
public void test_toLeg() { OvernightRateSwapLegConvention base = OvernightRateSwapLegConvention.of(GBP_SONIA, TERM, 2); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(TERM) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .stubConvention(StubConvention.SMART_INITIAL) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(TERM) .paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBP_SONIA.getFixingCalendar())) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(OvernightRateCalculation.of(GBP_SONIA)) .build(); assertEquals(test, expected); }
Swap swap = swapTrade.getProduct(); NotionalSchedule notional = NotionalSchedule.of(BRL, 10000000d); RateCalculationSwapLeg recLeg = RateCalculationSwapLeg.builder() .payReceive(PAY)
public void test_toLeg_withSpread() { IborRateSwapLegConvention base = IborRateSwapLegConvention.builder() .index(GBP_LIBOR_3M) .build(); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(P3M) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P3M) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(IborRateCalculation.builder() .index(GBP_LIBOR_3M) .spread(ValueSchedule.of(0.25d)) .build()) .build(); assertEquals(test, expected); }
public void test_toLeg_withSpread() { OvernightRateSwapLegConvention base = OvernightRateSwapLegConvention.builder() .index(GBP_SONIA) .accrualMethod(AVERAGED) .build(); LocalDate startDate = LocalDate.of(2015, 5, 5); LocalDate endDate = LocalDate.of(2020, 5, 5); RateCalculationSwapLeg test = base.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d); RateCalculationSwapLeg expected = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .frequency(TERM) .startDate(startDate) .endDate(endDate) .businessDayAdjustment(BDA_MOD_FOLLOW) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(TERM) .paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(OvernightRateCalculation.builder() .index(GBP_SONIA) .accrualMethod(AVERAGED) .spread(ValueSchedule.of(0.25d)) .build()) .build(); assertEquals(test, expected); }
public void coverage() { NotionalSchedule test = NotionalSchedule.of(GBP, 1000d); coverImmutableBean(test); NotionalSchedule test2 = NotionalSchedule.builder() .currency(USD) .amount(ValueSchedule.of(2000d)) .fxReset(FxResetCalculation.builder() .referenceCurrency(GBP) .index(GBP_USD_WM) .fixingDateOffset(DaysAdjustment.ofBusinessDays(-2, GBLO)) .build()) .initialExchange(true) .intermediateExchange(true) .finalExchange(true) .build(); coverBeanEquals(test, test2); }
.paymentDateOffset(DaysAdjustment.NONE) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL_2M)) .calculation(FixedRateCalculation.builder() .rate(ValueSchedule.of(0.25d))
public void test_serialization() { RateCalculationSwapLeg test = RateCalculationSwapLeg.builder() .payReceive(PAY) .accrualSchedule(PeriodicSchedule.builder() .startDate(DATE_01_05) .endDate(DATE_04_05) .frequency(P1M) .businessDayAdjustment(BusinessDayAdjustment.of(FOLLOWING, GBLO)) .build()) .paymentSchedule(PaymentSchedule.builder() .paymentFrequency(P1M) .paymentDateOffset(PLUS_TWO_DAYS) .build()) .notionalSchedule(NotionalSchedule.of(GBP, 1000d)) .calculation(FixedRateCalculation.builder() .dayCount(DayCounts.ACT_365F) .rate(ValueSchedule.of(0.025d)) .build()) .build(); assertSerialization(test); }
private SwapLeg createInflationSwapLeg(boolean interpolated, PayReceive pay) { BusinessDayAdjustment adj = BusinessDayAdjustment.of(FOLLOWING, GBLO); PeriodicSchedule accrualSchedule = PeriodicSchedule.builder() .startDate(DATE_14_06_09) .endDate(DATE_19_06_09) .frequency(Frequency.ofYears(5)) .businessDayAdjustment(adj) .build(); PaymentSchedule paymentSchedule = PaymentSchedule.builder() .paymentFrequency(Frequency.ofYears(5)) .paymentDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)) .build(); InflationRateCalculation rateCalc = InflationRateCalculation.builder() .index(GB_RPI) .indexCalculationMethod(interpolated ? INTERPOLATED : MONTHLY) .lag(Period.ofMonths(3)) .build(); NotionalSchedule notionalSchedule = NotionalSchedule.of(GBP, NOTIONAL); SwapLeg swapLeg = RateCalculationSwapLeg.builder() .payReceive(pay) .accrualSchedule(accrualSchedule) .paymentSchedule(paymentSchedule) .notionalSchedule(notionalSchedule) .calculation(rateCalc) .build(); return swapLeg; }
.compoundingMethod(CompoundingMethod.STRAIGHT) .build()) .notionalSchedule(NotionalSchedule.of(GBP, NOTIONAL)) .calculation(FixedRateCalculation.builder() .rate(ValueSchedule.of(parRateComputed))