Ejemplo n.º 1
0
        public void TestTenor_Equals_Positive1()
        {
            Tenor tenorLow  = new Tenor(0, 0, 0, 1);
            Tenor tenorMid  = new Tenor(0, 0, 1, 1);
            Tenor tenorMid2 = new Tenor(0, 0, 0, 8);
            Tenor tenorHigh = new Tenor(0, 1, 1, 1);

            Assert.AreEqual(false, tenorLow.Equals(tenorMid));
            Assert.AreEqual(false, tenorLow.Equals(tenorHigh));
            Assert.AreEqual(false, tenorMid.Equals(tenorHigh));

            Assert.AreEqual(true, tenorLow.Equals(tenorLow));
            Assert.AreEqual(true, tenorMid.Equals(tenorMid));
            Assert.AreEqual(true, tenorMid.Equals(tenorMid2));
            Assert.AreEqual(true, tenorHigh.Equals(tenorHigh));

            Assert.AreEqual(false, tenorMid.Equals(tenorLow));
            Assert.AreEqual(false, tenorHigh.Equals(tenorLow));
            Assert.AreEqual(false, tenorHigh.Equals(tenorMid));
        }
            public override Tenor checkSensitivityTenor(Tenor tenor)
            {
                Tenor adjustedTenor = SensitivityCsvInfoResolver.this.checkSensitivityTenor(tenor);

                return(adjustedTenor.Equals(Tenor.TENOR_12M) ? Tenor.TENOR_1Y : adjustedTenor);
            }
Ejemplo n.º 3
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));
            }
        }