コード例 #1
0
        //-------------------------------------------------------------------------
        public virtual void test_builder_empty()
        {
            CurveSensitivities test = CurveSensitivities.builder(PortfolioItemInfo.empty()).build();

            assertEquals(test.Info, PortfolioItemInfo.empty());
            assertEquals(test.TypedSensitivities, ImmutableMap.of());
        }
コード例 #2
0
        public virtual void test_builder_tenors()
        {
            CurveName curveName = CurveName.of("GBP");
            CurrencyParameterSensitivity sens1Y = CurrencyParameterSensitivity.of(curveName, ImmutableList.of(TENOR_MD_1Y), GBP, DoubleArray.of(3));
            CurveSensitivities           test   = CurveSensitivities.builder(PortfolioItemInfo.empty()).add(ZERO_RATE_DELTA, curveName, GBP, TENOR_MD_1M, 4).add(ZERO_RATE_DELTA, curveName, GBP, TENOR_MD_1W, 1).add(ZERO_RATE_DELTA, curveName, GBP, TENOR_MD_1Y, 2).add(ZERO_RATE_DELTA, curveName, GBP, TENOR_MD_1W, 2).add(ZERO_RATE_DELTA, sens1Y).build();

            assertEquals(test.Info, PortfolioItemInfo.empty());
            assertEquals(test.TypedSensitivities.size(), 1);
            CurrencyParameterSensitivities sens = test.getTypedSensitivity(ZERO_RATE_DELTA);

            assertEquals(sens.Sensitivities.size(), 1);
            CurrencyParameterSensitivity singleSens = sens.getSensitivity(curveName, GBP);

            assertEquals(singleSens.Sensitivity, DoubleArray.of(3, 4, 5));
            assertEquals(singleSens.getParameterMetadata(0), TENOR_MD_1W);
            assertEquals(singleSens.getParameterMetadata(1), TENOR_MD_1M);
            assertEquals(singleSens.getParameterMetadata(2), TENOR_MD_1Y);
        }
コード例 #3
0
        public virtual void test_builder_mixCurrency()
        {
            CurveName          curveName = CurveName.of("WEIRD");
            CurveSensitivities test      = CurveSensitivities.builder(PortfolioItemInfo.empty()).add(ZERO_RATE_DELTA, curveName, GBP, TENOR_MD_1Y, 1).add(ZERO_RATE_DELTA, curveName, USD, TENOR_MD_1Y, 2).build();

            assertEquals(test.Info, PortfolioItemInfo.empty());
            assertEquals(test.TypedSensitivities.size(), 1);
            CurrencyParameterSensitivities sens = test.getTypedSensitivity(ZERO_RATE_DELTA);

            assertEquals(sens.Sensitivities.size(), 2);
            CurrencyParameterSensitivity sensGbp = sens.getSensitivity(curveName, GBP);

            assertEquals(sensGbp.Sensitivity, DoubleArray.of(1));
            assertEquals(sensGbp.getParameterMetadata(0), TENOR_MD_1Y);
            CurrencyParameterSensitivity sensUsd = sens.getSensitivity(curveName, USD);

            assertEquals(sensUsd.Sensitivity, DoubleArray.of(2));
            assertEquals(sensUsd.getParameterMetadata(0), TENOR_MD_1Y);
        }