Пример #1
0
        //-------------------------------------------------------------------------
        public virtual void test_cloned()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity test  = @base.cloned();

            assertSame(test, @base);
        }
Пример #2
0
        //-------------------------------------------------------------------------
        // proper end-to-end tests are elsewhere
        public virtual void test_parameterSensitivity()
        {
            DiscountIborIndexRates test  = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    point = IborRateSensitivity.of(GBP_LIBOR_3M_AFTER, GBP, 1d);

            assertEquals(test.parameterSensitivity(point).size(), 1);
        }
Пример #3
0
        //-------------------------------------------------------------------------
        public virtual void test_build()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            PointSensitivities  test  = @base.build();

            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
Пример #4
0
        public virtual void test_rateIgnoringFixingsPointSensitivity_onValuation()
        {
            DiscountIborIndexRates test     = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    expected = IborRateSensitivity.of(GBP_LIBOR_3M_VAL, 1d);

            assertEquals(test.rateIgnoringFixingsPointSensitivity(GBP_LIBOR_3M_VAL), expected);
        }
Пример #5
0
        public virtual void test_ratePointSensitivity_afterValuation()
        {
            DiscountIborIndexRates test     = DiscountIborIndexRates.of(GBP_LIBOR_3M, DFCURVE, SERIES);
            IborRateSensitivity    expected = IborRateSensitivity.of(GBP_LIBOR_3M_AFTER, 1d);

            assertEquals(test.ratePointSensitivity(GBP_LIBOR_3M_AFTER), expected);
        }
Пример #6
0
        //-------------------------------------------------------------------------
        public virtual void test_mapSensitivity()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 1 / 32d);
            IborRateSensitivity test     = @base.mapSensitivity(s => 1 / s);

            assertEquals(test, expected);
        }
Пример #7
0
        //-------------------------------------------------------------------------
        public virtual void test_multipliedBy()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d * 3.5d);
            IborRateSensitivity test     = @base.multipliedBy(3.5d);

            assertEquals(test, expected);
        }
Пример #8
0
        //-------------------------------------------------------------------------
        public virtual void test_withSensitivity()
        {
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 20d);
            IborRateSensitivity test     = @base.withSensitivity(20d);

            assertEquals(test, expected);
        }
Пример #9
0
        public virtual void test_ratePointSensitivity_onValuation_noFixing()
        {
            SimpleIborIndexRates test     = SimpleIborIndexRates.of(GBP_LIBOR_3M, DATE_VAL, CURVE, SERIES_EMPTY);
            IborRateSensitivity  expected = IborRateSensitivity.of(GBP_LIBOR_3M_VAL, 1d);

            assertEquals(test.ratePointSensitivity(GBP_LIBOR_3M_VAL), expected);
            assertEquals(test.rateIgnoringFixingsPointSensitivity(GBP_LIBOR_3M_VAL), expected);
        }
Пример #10
0
        //-------------------------------------------------------------------------
        public virtual void test_buildInto()
        {
            IborRateSensitivity       @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            MutablePointSensitivities combo = new MutablePointSensitivities();
            MutablePointSensitivities test  = @base.buildInto(combo);

            assertSame(test, combo);
            assertEquals(test.Sensitivities, ImmutableList.of(@base));
        }
Пример #11
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            coverImmutableBean(test);
            IborRateSensitivity test2 = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), USD, 16d);

            coverBeanEquals(test, test2);
        }
Пример #12
0
        public virtual void test_of_withCurrency()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, GBP, 32d);

            assertEquals(test.Index, GBP_LIBOR_3M);
            assertEquals(test.Currency, GBP);
            assertEquals(test.Sensitivity, 32d);
            assertEquals(test.Index, GBP_LIBOR_3M);
        }
Пример #13
0
        public virtual void test_combinedWith_mutable()
        {
            IborRateSensitivity       @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            MutablePointSensitivities expected = new MutablePointSensitivities();

            expected.add(@base);
            PointSensitivityBuilder test = @base.combinedWith(new MutablePointSensitivities());

            assertEquals(test, expected);
        }
        //-------------------------------------------------------------------------
        public PointSensitivityBuilder ratePointSensitivity(IborIndexObservation observation)
        {
            LocalDate fixingDate    = observation.FixingDate;
            LocalDate valuationDate = ValuationDate;

            if (fixingDate.isBefore(valuationDate) || (fixingDate.Equals(valuationDate) && fixings.get(fixingDate).HasValue))
            {
                return(PointSensitivityBuilder.none());
            }
            return(IborRateSensitivity.of(observation, 1d));
        }
Пример #15
0
        //-------------------------------------------------------------------------
        public virtual void test_combinedWith()
        {
            IborRateSensitivity       base1    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity       base2    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 22d);
            MutablePointSensitivities expected = new MutablePointSensitivities();

            expected.add(base1).add(base2);
            PointSensitivityBuilder test = base1.combinedWith(base2);

            assertEquals(test, expected);
        }
Пример #16
0
        //-------------------------------------------------------------------------
        public virtual void test_withCurrency()
        {
            IborRateSensitivity @base = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            assertSame(@base.withCurrency(GBP), @base);

            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d);
            IborRateSensitivity test     = @base.withCurrency(USD);

            assertEquals(test, expected);
        }
Пример #17
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo()
        {
            double sensi = 32d;
            IborRateSensitivity @base    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, sensi);
            double              rate     = 1.5d;
            FxMatrix            matrix   = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
            IborRateSensitivity test1    = (IborRateSensitivity)@base.convertedTo(USD, matrix);
            IborRateSensitivity expected = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, sensi * rate);

            assertEquals(test1, expected);
            IborRateSensitivity test2 = (IborRateSensitivity)@base.convertedTo(GBP, matrix);

            assertEquals(test2, @base);
        }
Пример #18
0
        //-------------------------------------------------------------------------
        public virtual void test_compareKey()
        {
            IborRateSensitivity a1    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity a2    = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);
            IborRateSensitivity b     = IborRateSensitivity.of(IborIndexObservation.of(USD_LIBOR_3M, DATE2, REF_DATA), 32d);
            IborRateSensitivity c     = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, USD, 32d);
            IborRateSensitivity d     = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION2, 32d);
            ZeroRateSensitivity other = ZeroRateSensitivity.of(GBP, 2d, 32d);

            assertEquals(a1.compareKey(a2), 0);
            assertEquals(a1.compareKey(b) < 0, true);
            assertEquals(b.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(c) < 0, true);
            assertEquals(c.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(d) < 0, true);
            assertEquals(d.compareKey(a1) > 0, true);
            assertEquals(a1.compareKey(other) < 0, true);
            assertEquals(other.compareKey(a1) > 0, true);
        }
 public PointSensitivityBuilder rateIgnoringFixingsPointSensitivity(IborIndexObservation observation)
 {
     return(IborRateSensitivity.of(observation, 1d));
 }
Пример #20
0
        public virtual void test_serialization()
        {
            IborRateSensitivity test = IborRateSensitivity.of(GBP_LIBOR_3M_OBSERVATION, 32d);

            assertSerialization(test);
        }