//-------------------------------------------------------------------------
        public virtual void test_of_map()
        {
            ImmutableMap <SecurityId, RepoGroup>               repoSecurityGroups = ImmutableMap.of(SEC_A1, GROUP_REPO_X);
            ImmutableMap <LegalEntityId, RepoGroup>            repoGroups         = ImmutableMap.of(ISSUER_A, GROUP_REPO_Y, ISSUER_B, GROUP_REPO_Y, ISSUER_C, GROUP_REPO_Y, ISSUER_D, GROUP_REPO_Y);
            ImmutableMap <Pair <RepoGroup, Currency>, CurveId> repoCurves         = ImmutableMap.of(Pair.of(GROUP_REPO_X, USD), CURVE_ID_USD1, Pair.of(GROUP_REPO_Y, USD), CURVE_ID_USD2, Pair.of(GROUP_REPO_Y, GBP), CURVE_ID_GBP1);

            ImmutableMap <LegalEntityId, LegalEntityGroup>            issuerGroups = ImmutableMap.of(ISSUER_A, GROUP_ISSUER_M, ISSUER_B, GROUP_ISSUER_N, ISSUER_C, GROUP_ISSUER_M);
            ImmutableMap <Pair <LegalEntityGroup, Currency>, CurveId> issuerCurves = ImmutableMap.of(Pair.of(GROUP_ISSUER_M, USD), CURVE_ID_USD3, Pair.of(GROUP_ISSUER_N, USD), CURVE_ID_USD4, Pair.of(GROUP_ISSUER_N, GBP), CURVE_ID_GBP2);

            LegalEntityDiscountingMarketDataLookup test = LegalEntityDiscountingMarketDataLookup.of(repoSecurityGroups, repoGroups, repoCurves, issuerGroups, issuerCurves);

            assertEquals(test.queryType(), typeof(LegalEntityDiscountingMarketDataLookup));

            assertEquals(test.requirements(SEC_A1, ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD1, CURVE_ID_USD3).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_A2, ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD2, CURVE_ID_USD3).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_B1, ISSUER_B, USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_USD2, CURVE_ID_USD4).outputCurrencies(USD).build());
            assertEquals(test.requirements(SEC_B1, ISSUER_B, GBP), FunctionRequirements.builder().valueRequirements(CURVE_ID_GBP1, CURVE_ID_GBP2).outputCurrencies(GBP).build());
            assertThrowsIllegalArg(() => test.requirements(SEC_B1, LegalEntityId.of("XXX", "XXX"), GBP));
            assertThrowsIllegalArg(() => test.requirements(SecurityId.of("XXX", "XXX"), LegalEntityId.of("XXX", "XXX"), GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_A1, ISSUER_A, GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_C1, ISSUER_C, GBP));
            assertThrowsIllegalArg(() => test.requirements(SEC_D1, ISSUER_D, GBP));

            assertEquals(test.discountingProvider(MOCK_MARKET_DATA), DefaultLookupLegalEntityDiscountingProvider.of((DefaultLegalEntityDiscountingMarketDataLookup)test, MOCK_MARKET_DATA));
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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);
        }