Beispiel #1
0
        public virtual void test_swapIndicies()
        {
            ImmutableMap <string, SwapIndex> mapAll   = SwapIndices.ENUM_LOOKUP.lookupAll();
            ImmutableList <SwapIndex>        indexAll = mapAll.values().asList();
            ImmutableList <string>           nameAll  = mapAll.Keys.asList();
            int size = indexAll.size();

            for (int i = 0; i < size; ++i)
            {
                // check no duplication
                for (int j = i + 1; j < size; ++j)
                {
                    assertFalse(nameAll.get(i).Equals(nameAll.get(j)));
                    assertFalse(indexAll.get(i).Equals(indexAll.get(j)));
                }
            }
            foreach (string name in nameAll)
            {
                SwapIndex index = mapAll.get(name);
                assertEquals(SwapIndex.of(name), index);
                assertEquals(index.Active, true);
                FixedIborSwapTemplate   temp = index.Template;
                FixedIborSwapConvention conv = temp.Convention;
                Tenor     tenor = temp.Tenor;
                LocalTime time  = index.FixingTime;
                ZoneId    zone  = index.FixingZone;
                // test consistency between name and template
                assertTrue(name.Contains(tenor.ToString()));
                if (name.StartsWith("USD", StringComparison.Ordinal))
                {
                    assertTrue(name.Contains("1100") || name.Contains("1500"));
                    assertTrue(conv.Equals(FixedIborSwapConventions.USD_FIXED_6M_LIBOR_3M));
                    assertTrue(zone.Equals(NEY_YORK));
                }
                if (name.StartsWith("GBP", StringComparison.Ordinal))
                {
                    assertTrue(name.Contains("1100"));
                    if (tenor.Equals(Tenor.TENOR_1Y))
                    {
                        assertTrue(conv.Equals(FixedIborSwapConventions.GBP_FIXED_1Y_LIBOR_3M));
                    }
                    else
                    {
                        assertTrue(conv.Equals(FixedIborSwapConventions.GBP_FIXED_6M_LIBOR_6M));
                    }
                    assertTrue(zone.Equals(LONDON));
                }
                if (name.StartsWith("EUR", StringComparison.Ordinal))
                {
                    assertTrue(name.Contains("1100") || name.Contains("1200"));
                    if (tenor.Equals(Tenor.TENOR_1Y))
                    {
                        assertTrue(conv.Equals(FixedIborSwapConventions.EUR_FIXED_1Y_EURIBOR_3M));
                    }
                    else
                    {
                        assertTrue(conv.Equals(FixedIborSwapConventions.EUR_FIXED_1Y_EURIBOR_6M));
                    }
                    assertTrue(zone.Equals(FRANKFURT));
                }
                if (name.Contains("1100"))
                {
                    assertTrue(time.Equals(LocalTime.of(11, 0)));
                }
                if (name.Contains("1200"))
                {
                    assertTrue(time.Equals(LocalTime.of(12, 0)));
                }
                if (name.Contains("1500"))
                {
                    assertTrue(time.Equals(LocalTime.of(15, 0)));
                }
                assertEquals(index.calculateFixingDateTime(date(2015, 6, 30)), date(2015, 6, 30).atTime(time).atZone(zone));
            }
        }