//-------------------------------------------------------------------------
        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));
        }
        public virtual void test_bondDiscountingProvider()
        {
            ImmutableMap <SecurityId, RepoGroup>               repoSecurityGroups = ImmutableMap.of(SEC_A1, GROUP_REPO_X);
            ImmutableMap <LegalEntityId, RepoGroup>            repoGroups         = ImmutableMap.of(ISSUER_B, GROUP_REPO_X);
            ImmutableMap <Pair <RepoGroup, Currency>, CurveId> repoCurves         = ImmutableMap.of(Pair.of(GROUP_REPO_X, USD), CURVE_ID_USD1);

            ImmutableMap <LegalEntityId, LegalEntityGroup>            issuerGroups = ImmutableMap.of(ISSUER_A, GROUP_ISSUER_M);
            ImmutableMap <Pair <LegalEntityGroup, Currency>, CurveId> issuerCurves = ImmutableMap.of(Pair.of(GROUP_ISSUER_M, USD), CURVE_ID_USD3);

            LegalEntityDiscountingMarketDataLookup test = LegalEntityDiscountingMarketDataLookup.of(repoSecurityGroups, repoGroups, repoCurves, issuerGroups, issuerCurves);
            LocalDate  valDate     = date(2015, 6, 30);
            Curve      repoCurve   = ConstantCurve.of(Curves.discountFactors(CURVE_ID_USD1.CurveName, ACT_360), 1d);
            Curve      issuerCurve = ConstantCurve.of(Curves.discountFactors(CURVE_ID_USD3.CurveName, ACT_360), 2d);
            MarketData md          = ImmutableMarketData.of(valDate, ImmutableMap.of(CURVE_ID_USD1, repoCurve, CURVE_ID_USD3, issuerCurve));
            LegalEntityDiscountingProvider provider = test.discountingProvider(md);

            assertEquals(provider.ValuationDate, valDate);
            assertEquals(provider.findData(CURVE_ID_USD1.CurveName), repoCurve);
            assertEquals(provider.findData(CURVE_ID_USD3.CurveName), issuerCurve);
            assertEquals(provider.findData(CurveName.of("Rubbish")), null);
            // check repo
            RepoCurveDiscountFactors rcdf = provider.repoCurveDiscountFactors(SEC_A1, ISSUER_A, USD);
            SimpleDiscountFactors    rdf  = (SimpleDiscountFactors)rcdf.DiscountFactors;

            assertEquals(rdf.Curve.Name, repoCurve.Name);
            assertEquals(rcdf, provider.repoCurveDiscountFactors(SEC_B1, ISSUER_B, USD));
            assertThrowsIllegalArg(() => provider.repoCurveDiscountFactors(SEC_A1, ISSUER_A, GBP));
            assertThrowsIllegalArg(() => provider.repoCurveDiscountFactors(SEC_C1, ISSUER_C, USD));
            // check issuer
            IssuerCurveDiscountFactors icdf = provider.issuerCurveDiscountFactors(ISSUER_A, USD);
            SimpleDiscountFactors      idf  = (SimpleDiscountFactors)icdf.DiscountFactors;

            assertEquals(idf.Curve.Name, issuerCurve.Name);
            assertThrowsIllegalArg(() => provider.issuerCurveDiscountFactors(ISSUER_A, GBP));
            assertThrowsIllegalArg(() => provider.issuerCurveDiscountFactors(ISSUER_C, USD));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @ImmutableConstructor private DefaultLegalEntityDiscountingMarketData(LegalEntityDiscountingMarketDataLookup lookup, com.opengamma.strata.data.MarketData marketData)
        private DefaultLegalEntityDiscountingMarketData(LegalEntityDiscountingMarketDataLookup lookup, MarketData marketData)
        {
            this.lookup     = ArgChecker.notNull(lookup, "lookup");
            this.marketData = ArgChecker.notNull(marketData, "marketData");
            this.discountingProvider_Renamed = lookup.discountingProvider(marketData);
        }