Esempio n. 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_builder()
        {
            ImmutableFixedOvernightSwapConvention test = ImmutableFixedOvernightSwapConvention.builder().name(NAME).fixedLeg(FIXED).floatingLeg(FFUND_LEG).spotDateOffset(PLUS_ONE_DAY).build();

            assertEquals(test.Name, NAME);
            assertEquals(test.FixedLeg, FIXED);
            assertEquals(test.FloatingLeg, FFUND_LEG);
            assertEquals(test.SpotDateOffset, PLUS_ONE_DAY);
        }
        //-------------------------------------------------------------------------
        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 override bool Equals(object obj)
 {
     if (obj == this)
     {
         return(true);
     }
     if (obj != null && obj.GetType() == this.GetType())
     {
         ImmutableFixedOvernightSwapConvention other = (ImmutableFixedOvernightSwapConvention)obj;
         return(JodaBeanUtils.equal(name, other.name) && JodaBeanUtils.equal(fixedLeg, other.fixedLeg) && JodaBeanUtils.equal(floatingLeg, other.floatingLeg) && JodaBeanUtils.equal(spotDateOffset, other.spotDateOffset));
     }
     return(false);
 }
        public virtual void test_serialization()
        {
            ImmutableFixedOvernightSwapConvention test = ImmutableFixedOvernightSwapConvention.of(NAME, FIXED, FFUND_LEG, PLUS_TWO_DAYS);

            assertSerialization(test);
        }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test(dataProvider = "spotLag") public void test_spot_lag(ImmutableFixedOvernightSwapConvention convention, int lag)
        public virtual void test_spot_lag(ImmutableFixedOvernightSwapConvention convention, int lag)
        {
            assertEquals(convention.SpotDateOffset.Days, lag);
        }