Ejemplo n.º 1
0
        //-------------------------------------------------------------------------
        public virtual void test_discountFactor_notFound()
        {
            LegalEntityId    issuerId    = LegalEntityId.of("OG-Ticker", "Issuer-2");
            LegalEntityGroup issuerGroup = LegalEntityGroup.of("ISSUER2");
            RepoGroup        repoGroup   = RepoGroup.of("ISSUER2 BND 5Y");
            SecurityId       securityId  = SecurityId.of("OG-Ticker", "Issuer-2-bond-5Y");
            ImmutableLegalEntityDiscountingProvider test = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER, issuerId, issuerGroup)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(issuerId, repoGroup)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build();

            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.issuerCurveDiscountFactors(issuerId, GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(ID_SECURITY, ID_ISSUER, USD));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(SecurityId.of("OG-Ticker", "foo-bond"), LegalEntityId.of("OG-Ticker", "foo"), GBP));
            assertThrowsIllegalArg(() => test.repoCurveDiscountFactors(securityId, issuerId, GBP));
        }
Ejemplo n.º 2
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            RepoCurveDiscountFactors test1 = RepoCurveDiscountFactors.of(DSC_FACTORS, GROUP);

            coverImmutableBean(test1);
            RepoCurveDiscountFactors test2 = RepoCurveDiscountFactors.of(ZeroRateDiscountFactors.of(USD, DATE, CURVE), RepoGroup.of("ISSUER2"));

            coverBeanEquals(test1, test2);
        }
Ejemplo n.º 3
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            RepoCurveZeroRateSensitivity test1 = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE);

            coverImmutableBean(test1);
            RepoCurveZeroRateSensitivity test2 = RepoCurveZeroRateSensitivity.of(GBP, YEARFRAC2, RepoGroup.of("ISSUER2 BND 5Y"), 12d);

            coverBeanEquals(test1, test2);
        }
Ejemplo n.º 4
0
        public virtual void test_compareKey()
        {
            RepoCurveZeroRateSensitivity a1    = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE);
            RepoCurveZeroRateSensitivity a2    = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, GROUP, VALUE);
            RepoCurveZeroRateSensitivity b     = RepoCurveZeroRateSensitivity.of(GBP, YEARFRAC, GROUP, VALUE);
            RepoCurveZeroRateSensitivity c     = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC2, GROUP, VALUE);
            RepoCurveZeroRateSensitivity d     = RepoCurveZeroRateSensitivity.of(CURRENCY, YEARFRAC, RepoGroup.of("ISSUER1 BND 3Y"), VALUE);
            IborRateSensitivity          other = IborRateSensitivity.of(IborIndexObservation.of(GBP_LIBOR_3M, date(2014, 6, 30), REF_DATA), 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);
        }
Ejemplo n.º 5
0
        public virtual void test_builder_fail()
        {
            // no relevant map for repo curve
            assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(ID_ISSUER, RepoGroup.of("ISSUER2 BND 5Y"))).build());
            // no relevant map for issuer curve
            assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, LegalEntityGroup.of("ISSUER2"))).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER)).build());
            // issuer curve and valuation date are missing
            assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).build());
            // issuer curve date is different from valuation date
            DiscountFactors dscFactorIssuer = ZeroRateDiscountFactors.of(GBP, date(2015, 6, 14), CURVE_ISSUER);

            assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), dscFactorIssuer)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), DSC_FACTORS_REPO)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build());
            // repo curve rate is different from valuation date
            DiscountFactors dscFactorRepo = ZeroRateDiscountFactors.of(GBP, date(2015, 6, 14), CURVE_REPO);

            assertThrowsIllegalArg(() => ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_SECURITY, GBP), dscFactorRepo)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, GROUP_REPO_SECURITY)).valuationDate(DATE).build());
        }
Ejemplo n.º 6
0
        //-------------------------------------------------------------------------
        public virtual void coverage()
        {
            ImmutableLegalEntityDiscountingProvider test1 = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), DSC_FACTORS_ISSUER)).issuerCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(GROUP_REPO_ISSUER, GBP), DSC_FACTORS_REPO)).repoCurveGroups(ImmutableMap.of(ID_ISSUER, GROUP_REPO_ISSUER)).build();

            coverImmutableBean(test1);
            LocalDate       val             = date(2015, 6, 14);
            DiscountFactors dscFactorIssuer = ZeroRateDiscountFactors.of(GBP, val, CURVE_ISSUER);
            DiscountFactors dscFactorRepo   = ZeroRateDiscountFactors.of(GBP, val, CURVE_REPO);
            ImmutableLegalEntityDiscountingProvider test2 = ImmutableLegalEntityDiscountingProvider.builder().issuerCurves(ImmutableMap.of(Pair.of(GROUP_ISSUER, GBP), dscFactorIssuer)).issuerCurveGroups(ImmutableMap.of(LegalEntityId.of("OG-Ticker", "foo"), GROUP_ISSUER)).repoCurves(ImmutableMap.of(Pair.of(RepoGroup.of("ISSUER2 BND 5Y"), GBP), dscFactorRepo)).repoCurveSecurityGroups(ImmutableMap.of(ID_SECURITY, RepoGroup.of("ISSUER2 BND 5Y"))).build();

            coverBeanEquals(test1, test2);
        }