Beispiel #1
0
        //-------------------------------------------------------------------------
        public virtual void test_equals()
        {
            ImmutableFxIndex a = ImmutableFxIndex.builder().name("GBP-EUR").currencyPair(CurrencyPair.of(GBP, EUR)).fixingCalendar(GBLO).maturityDateOffset(DaysAdjustment.ofBusinessDays(2, GBLO)).build();
            ImmutableFxIndex b = a.toBuilder().name("EUR-GBP").build();

            assertEquals(a.Equals(b), false);
        }
        private static FxIndex parseFxIndex(CsvRow row)
        {
            string            name            = row.getField(NAME_FIELD);
            Currency          baseCurrency    = Currency.parse(row.getField(BASE_CURRENCY_FIELD));
            Currency          counterCurrency = Currency.parse(row.getField(COUNTER_CURRENCY_FIELD));
            HolidayCalendarId fixingCal       = HolidayCalendarId.of(row.getField(FIXING_CALENDAR_FIELD));
            int maturityDays = int.Parse(row.getField(MATURITY_DAYS_FIELD));
            HolidayCalendarId maturityCal = HolidayCalendarId.of(row.getField(MATURITY_CALENDAR_FIELD));

            // build result
            return(ImmutableFxIndex.builder().name(name).currencyPair(CurrencyPair.of(baseCurrency, counterCurrency)).fixingCalendar(fixingCal).maturityDateOffset(DaysAdjustment.ofBusinessDays(maturityDays, maturityCal)).build());
        }
Beispiel #3
0
        public virtual void test_dates()
        {
            FxIndex test = ImmutableFxIndex.builder().name("Test").currencyPair(CurrencyPair.of(EUR, GBP)).fixingCalendar(NO_HOLIDAYS).maturityDateOffset(DaysAdjustment.ofCalendarDays(2)).build();

            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 13), REF_DATA), date(2014, 10, 15));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 15), REF_DATA), date(2014, 10, 13));
            // weekend
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 16), REF_DATA), date(2014, 10, 18));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 18), REF_DATA), date(2014, 10, 16));
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 17), REF_DATA), date(2014, 10, 19));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 19), REF_DATA), date(2014, 10, 17));
            // input date is Sunday
            assertEquals(test.calculateMaturityFromFixing(date(2014, 10, 19), REF_DATA), date(2014, 10, 21));
            assertEquals(test.calculateFixingFromMaturity(date(2014, 10, 19), REF_DATA), date(2014, 10, 17));
        }