예제 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_convertedTo_singleCurrency()
        {
            double             rate     = 1.5d;
            FxMatrix           matrix   = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
            PointSensitivities @base    = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1));
            PointSensitivities test1    = @base.convertedTo(USD, matrix);
            PointSensitivity   c1Conv   = CS1.convertedTo(USD, matrix);
            PointSensitivity   c2Conv   = CS2.convertedTo(USD, matrix);
            PointSensitivity   c3Conv   = CS3.convertedTo(USD, matrix);
            PointSensitivities expected = PointSensitivities.of(Lists.newArrayList(c3Conv, c2Conv, c1Conv));

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

            assertEquals(test2.normalized(), @base.normalized());
        }
예제 #2
0
        public virtual void test_convertedTo_multipleCurrency()
        {
            double             rate      = 1.5d;
            FxMatrix           matrix    = FxMatrix.of(CurrencyPair.of(GBP, USD), rate);
            PointSensitivities @base     = PointSensitivities.of(Lists.newArrayList(CS4, CS3, CS1));
            PointSensitivities test1     = @base.convertedTo(USD, matrix);
            PointSensitivity   c1Conv    = CS1.convertedTo(USD, matrix);
            PointSensitivity   c3Conv    = CS3.convertedTo(USD, matrix);
            PointSensitivity   c3c4Usd   = c3Conv.withSensitivity(c3Conv.Sensitivity + CS4.Sensitivity);
            PointSensitivities expected1 = PointSensitivities.of(Lists.newArrayList(c3c4Usd, c1Conv));

            assertEquals(test1.normalized(), expected1.normalized());
            PointSensitivities test2     = @base.convertedTo(GBP, matrix);
            PointSensitivity   c4Conv    = CS4.convertedTo(GBP, matrix);
            PointSensitivity   c3c4GBP   = CS3.withSensitivity(CS3.Sensitivity + c4Conv.Sensitivity);
            PointSensitivities expected2 = PointSensitivities.of(Lists.newArrayList(c3c4GBP, CS1));

            assertEquals(test2.normalized(), expected2.normalized());
        }
예제 #3
0
        public virtual void test_normalized_merges()
        {
            PointSensitivities test = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1, CS3B));

            assertEquals(test.normalized().Sensitivities, ImmutableList.of(CS1, CS2, CS3.withSensitivity(35d)));
        }
예제 #4
0
        //-------------------------------------------------------------------------
        public virtual void test_normalized_sorts()
        {
            PointSensitivities test = PointSensitivities.of(Lists.newArrayList(CS3, CS2, CS1));

            assertEquals(test.normalized().Sensitivities, ImmutableList.of(CS1, CS2, CS3));
        }