Beispiel #1
0
 //-------------------------------------------------------------------------
 public virtual void test_isCrossCurrency()
 {
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).CrossCurrency, true);
     assertEquals(Swap.of(MOCK_GBP1, MOCK_GBP2, MOCK_USD1).CrossCurrency, true);
     assertEquals(Swap.of(MOCK_GBP1, MOCK_GBP2).CrossCurrency, false);
     assertEquals(Swap.of(MOCK_GBP1).CrossCurrency, false);
 }
Beispiel #2
0
 //-------------------------------------------------------------------------
 public virtual void test_getLegs_SwapLegType()
 {
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(FIXED), ImmutableList.of(MOCK_GBP1));
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(IBOR), ImmutableList.of(MOCK_USD1));
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(OVERNIGHT), ImmutableList.of());
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLegs(OTHER), ImmutableList.of());
 }
Beispiel #3
0
        public virtual void test_of_list()
        {
            Swap test = Swap.of(ImmutableList.of(MOCK_GBP1, MOCK_USD1));

            assertEquals(test.Legs, ImmutableList.of(MOCK_GBP1, MOCK_USD1));
            assertEquals(ImmutableList.copyOf(test.Legs), ImmutableList.of(MOCK_GBP1, MOCK_USD1));
            assertThrowsIllegalArg(() => Swap.of((IList <SwapLeg>)null));
        }
Beispiel #4
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);

            coverImmutableBean(test);
            Swap test2 = Swap.of(MOCK_GBP1);

            coverBeanEquals(test, test2);
        }
Beispiel #5
0
 public virtual void test_getLeg_PayReceive()
 {
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLeg(PAY), MOCK_GBP1);
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).getLeg(RECEIVE), MOCK_USD1);
     assertEquals(Swap.of(MOCK_GBP1).getLeg(PAY), MOCK_GBP1);
     assertEquals(Swap.of(MOCK_USD1).getLeg(PAY), null);
     assertEquals(Swap.of(MOCK_GBP1).getLeg(RECEIVE), null);
     assertEquals(Swap.of(MOCK_USD1).getLeg(RECEIVE), MOCK_USD1);
 }
Beispiel #6
0
        public virtual void test_getEndDate()
        {
            SwapLeg leg1 = MockSwapLeg.of(FIXED, PAY, date(2015, 6, 29), date(2017, 6, 30), Currency.USD);
            SwapLeg leg2 = MockSwapLeg.of(FIXED, RECEIVE, date(2015, 6, 30), date(2017, 6, 29), Currency.USD);

            assertEquals(Swap.of(leg1).EndDate, AdjustableDate.of(date(2017, 6, 30)));
            assertEquals(Swap.of(leg2).EndDate, AdjustableDate.of(date(2017, 6, 29)));
            assertEquals(Swap.of(leg1, leg2).EndDate, AdjustableDate.of(date(2017, 6, 30)));
            assertEquals(Swap.of(leg2, leg1).EndDate, AdjustableDate.of(date(2017, 6, 30)));
        }
Beispiel #7
0
        public virtual void test_summarize_irs_weird()
        {
            PeriodicSchedule       accrual  = PeriodicSchedule.of(date(2018, 2, 12), date(2020, 2, 12), Frequency.P3M, BusinessDayAdjustment.NONE, SHORT_INITIAL, false);
            PaymentSchedule        payment  = PaymentSchedule.builder().paymentFrequency(Frequency.P3M).paymentDateOffset(DaysAdjustment.NONE).build();
            NotionalSchedule       notional = NotionalSchedule.of(GBP, ValueSchedule.builder().initialValue(1_000_000).stepSequence(ValueStepSequence.of(date(2018, 8, 12), date(2019, 8, 12), Frequency.P6M, ofDeltaAmount(-50_000))).build());
            RateCalculationSwapLeg payLeg   = RateCalculationSwapLeg.builder().payReceive(PAY).accrualSchedule(accrual).paymentSchedule(payment).notionalSchedule(notional).calculation(FixedRateCalculation.builder().dayCount(ACT_360).rate(ValueSchedule.builder().initialValue(0.0012).stepSequence(ValueStepSequence.of(date(2018, 8, 12), date(2019, 8, 12), Frequency.P6M, ofDeltaAmount(0.0001))).build()).build()).build();
            RateCalculationSwapLeg recLeg   = RateCalculationSwapLeg.builder().payReceive(RECEIVE).accrualSchedule(accrual).paymentSchedule(payment).notionalSchedule(notional).calculation(IborRateCalculation.builder().index(IborIndices.GBP_LIBOR_3M).gearing(ValueSchedule.of(1.1)).spread(ValueSchedule.of(0.002)).build()).build();
            Swap test = Swap.of(payLeg, recLeg);

            assertEquals(test.summaryDescription(), "2Y GBP 1mm variable Rec GBP-LIBOR-3M * 1.1 + 0.2% / Pay 0.12% variable : 12Feb18-12Feb20");
        }
Beispiel #8
0
        public virtual void test_serialization()
        {
            Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);

            assertSerialization(test);
        }
Beispiel #9
0
        //-------------------------------------------------------------------------
        public virtual void test_allIndices()
        {
            Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);

            assertEquals(test.allIndices(), ImmutableSet.of(IborIndices.GBP_LIBOR_3M, FxIndices.EUR_GBP_ECB, OvernightIndices.EUR_EONIA));
        }
Beispiel #10
0
        //-------------------------------------------------------------------------
        public virtual void test_allCurrencies()
        {
            Swap test = Swap.of(MOCK_GBP1, MOCK_USD1);

            assertEquals(test.allCurrencies(), ImmutableSet.of(GBP, USD, EUR));
        }
Beispiel #11
0
 public virtual void test_getReceiveLeg()
 {
     assertEquals(Swap.of(MOCK_GBP1, MOCK_USD1).ReceiveLeg, MOCK_USD1);
     assertEquals(Swap.of(MOCK_GBP1).ReceiveLeg, null);
     assertEquals(Swap.of(MOCK_USD1).ReceiveLeg, MOCK_USD1);
 }