//-------------------------------------------------------------------------
        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));
        }
Beispiel #2
0
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            Bill product = target.Product;

            // use lookup to build requirements
            LegalEntityDiscountingMarketDataLookup lookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            return(lookup.requirements(product.SecurityId, product.LegalEntityId, product.Currency));
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            CapitalIndexedBond product       = target.Product;
            Currency           currency      = product.Currency;
            SecurityId         securityId    = product.SecurityId;
            LegalEntityId      legalEntityId = product.LegalEntityId;

            // use lookup to build requirements
            RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements  ratesReqs   = ratesLookup.requirements(ImmutableSet.of(), ImmutableSet.of(product.RateCalculation.Index));
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));
            FunctionRequirements ledReqs = ledLookup.requirements(securityId, legalEntityId, currency);

            return(ratesReqs.combinedWith(ledReqs));
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFuture product  = target.Product;
            QuoteId    quoteId  = QuoteId.of(product.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            Currency   currency = product.Currency;

            // use lookup to build requirements
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(quoteId).outputCurrencies(currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in product.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            return(freqs);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            BondFutureOption option = target.Product;
            BondFuture       future = option.UnderlyingFuture;

            // use lookup to build requirements
            QuoteId optionQuoteId      = QuoteId.of(option.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            FunctionRequirements freqs = FunctionRequirements.builder().valueRequirements(optionQuoteId).outputCurrencies(future.Currency, option.Currency).build();
            LegalEntityDiscountingMarketDataLookup ledLookup = parameters.getParameter(typeof(LegalEntityDiscountingMarketDataLookup));

            foreach (FixedCouponBond bond in future.DeliveryBasket)
            {
                freqs = freqs.combinedWith(ledLookup.requirements(bond.SecurityId, bond.LegalEntityId, bond.Currency));
            }
            BondFutureOptionMarketDataLookup optionLookup = parameters.getParameter(typeof(BondFutureOptionMarketDataLookup));
            FunctionRequirements             optionReqs   = optionLookup.requirements(future.SecurityId);

            return(freqs.combinedWith(optionReqs));
        }