Beispiel #1
0
        //-------------------------------------------------------------------------
        // build conventions
        private static FixedOvernightSwapConvention makeConvention(string name, OvernightIndex index, DayCount dayCount, Frequency frequency, int paymentLag, int spotLag)
        {
            HolidayCalendarId calendar          = index.FixingCalendar;
            DaysAdjustment    paymentDateOffset = DaysAdjustment.ofBusinessDays(paymentLag, calendar);
            DaysAdjustment    spotDateOffset    = DaysAdjustment.ofBusinessDays(spotLag, calendar);

            return(ImmutableFixedOvernightSwapConvention.of(name, FixedRateSwapLegConvention.builder().currency(index.Currency).dayCount(dayCount).accrualFrequency(frequency).accrualBusinessDayAdjustment(BusinessDayAdjustment.of(MODIFIED_FOLLOWING, calendar)).paymentFrequency(frequency).paymentDateOffset(paymentDateOffset).stubConvention(StubConvention.SMART_INITIAL).build(), OvernightRateSwapLegConvention.builder().index(index).accrualMethod(COMPOUNDED).accrualFrequency(frequency).paymentFrequency(frequency).paymentDateOffset(paymentDateOffset).stubConvention(StubConvention.SMART_INITIAL).build(), spotDateOffset));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of()
        {
            ImmutableFixedOvernightSwapConvention test = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);

            assertEquals(test.Name, NAME);
            assertEquals(test.FixedLeg, FIXED);
            assertEquals(test.FloatingLeg, FFUND_LEG);
            assertEquals(test.SpotDateOffset, PLUS_TWO_DAYS);
        }
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ImmutableFixedOvernightSwapConvention test = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);

            coverImmutableBean(test);
            ImmutableFixedOvernightSwapConvention test2 = ImmutableFixedOvernightSwapConvention.of("GBP-Swap", FIXED2, FLOATING_LEG2, PLUS_ONE_DAY);

            coverBeanEquals(test, test2);
            ImmutableFixedOvernightSwapConvention test3 = ImmutableFixedOvernightSwapConvention.of("USD-Swap2", FIXED, FFUND_LEG2, PLUS_ONE_DAY);

            coverBeanEquals(test, test3);
        }
        public virtual void test_toTrade_dates()
        {
            FixedOvernightSwapConvention @base = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);
            LocalDate tradeDate = LocalDate.of(2015, 5, 5);
            LocalDate startDate = date(2015, 8, 5);
            LocalDate endDate   = date(2015, 11, 5);
            SwapTrade test      = @base.toTrade(tradeDate, startDate, endDate, BUY, NOTIONAL_2M, 0.25d);
            Swap      expected  = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), FFUND_LEG.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M));

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
        public virtual void test_toTrade_periodTenor()
        {
            FixedOvernightSwapConvention @base = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);
            LocalDate tradeDate = LocalDate.of(2015, 5, 5);
            LocalDate startDate = date(2015, 8, 7);
            LocalDate endDate   = date(2025, 8, 7);
            SwapTrade test      = @base.createTrade(tradeDate, Period.ofMonths(3), TENOR_10Y, BUY, NOTIONAL_2M, 0.25d, REF_DATA);
            Swap      expected  = Swap.of(FIXED.toLeg(startDate, endDate, PAY, NOTIONAL_2M, 0.25d), FFUND_LEG.toLeg(startDate, endDate, RECEIVE, NOTIONAL_2M));

            assertEquals(test.Info.TradeDate, tradeDate);
            assertEquals(test.Product, expected);
        }
        public virtual void test_serialization()
        {
            ImmutableFixedOvernightSwapConvention test = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);

            assertSerialization(test);
        }