//-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(SecurityTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            Security security = refData.getValue(trade.SecurityId);
            QuoteId  id       = QuoteId.of(trade.SecurityId.StandardId);

            return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(id)).outputCurrencies(security.Currency).build());
        }
        //-------------------------------------------------------------------------
        public FunctionRequirements requirements(SecurityId securityId, LegalEntityId issuerId, Currency currency)
        {
            // repo
            RepoGroup repoKey = repoCurveSecurityGroups.get(securityId);

            if (repoKey == null)
            {
                repoKey = repoCurveGroups.get(issuerId);
            }
            if (repoKey == null)
            {
                throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no repo curve defined for '{}' and '{}'", securityId, issuerId));
            }
            CurveId repoCurveId = repoCurves.get(Pair.of(repoKey, currency));

            if (repoCurveId == null)
            {
                throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no repo curve defined for '{}' and '{}'", securityId, issuerId));
            }
            // issuer
            LegalEntityGroup issuerKey = issuerCurveGroups.get(issuerId);

            if (issuerKey == null)
            {
                throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no issuer curve defined for '{}'", issuerId));
            }
            CurveId issuerCurveId = issuerCurves.get(Pair.of(issuerKey, currency));

            if (issuerCurveId == null)
            {
                throw new System.ArgumentException(Messages.format("Legal entity discounting lookup has no issuer curve defined for '{}'", issuerId));
            }
            // result
            return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(repoCurveId, issuerCurveId)).outputCurrencies(currency).observableSource(observableSource).build());
        }
        //-------------------------------------------------------------------------
        public FunctionRequirements requirements <T1>(ISet <Currency> currencies, ISet <T1> indices) where T1 : com.opengamma.strata.basics.index.Index
        {
            foreach (Currency currency in currencies)
            {
                if (!discountCurves.Keys.Contains(currency))
                {
                    throw new System.ArgumentException(msgCurrencyNotFound(currency));
                }
            }
            foreach (Index index in indices)
            {
                if (!forwardCurves.Keys.Contains(index))
                {
                    throw new System.ArgumentException(msgIndexNotFound(index));
                }
            }

            // keys for time-series
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <ObservableId> indexQuoteIds = indices.Select(IndexQuoteId.of).collect(toImmutableSet());

            // keys for forward curves
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> indexCurveIds = indices.stream().map(idx -> forwardCurves.get(idx)).collect(toImmutableSet());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <MarketDataId <object> > indexCurveIds = indices.Select(idx => forwardCurves.get(idx)).collect(toImmutableSet());

            // keys for discount factors
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> discountFactorsIds = currencies.stream().map(ccy -> discountCurves.get(ccy)).collect(toImmutableSet());
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            ISet <MarketDataId <object> > discountFactorsIds = currencies.Select(ccy => discountCurves.get(ccy)).collect(toImmutableSet());

            return(FunctionRequirements.builder().valueRequirements(Sets.union(indexCurveIds, discountFactorsIds)).timeSeriesRequirements(indexQuoteIds).outputCurrencies(currencies).observableSource(observableSource).build());
        }
 //-------------------------------------------------------------------------
 public FunctionRequirements requirements(ISet <IborIndex> indices)
 {
     foreach (Index index in indices)
     {
         if (!volatilityIds.Keys.Contains(index))
         {
             throw new System.ArgumentException(msgIndexNotFound(index));
         }
     }
     return(FunctionRequirements.builder().valueRequirements(ImmutableSet.copyOf(volatilityIds.values())).build());
 }
Exemplo n.º 5
0
 //-------------------------------------------------------------------------
 public FunctionRequirements requirements(ISet <CurrencyPair> currencyPairs)
 {
     foreach (CurrencyPair currencyPair in currencyPairs)
     {
         if (!volatilityIds.Keys.Contains(currencyPair))
         {
             throw new System.ArgumentException(msgPairNotFound(currencyPair));
         }
     }
     return(FunctionRequirements.builder().valueRequirements(ImmutableSet.copyOf(volatilityIds.values())).build());
 }
Exemplo n.º 6
0
 public virtual void test_map()
 {
     assertEquals(LOOKUP.queryType(), typeof(CreditRatesMarketDataLookup));
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_A, USD), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_A_USD, DC_USD, RC_A).outputCurrencies(USD).build());
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_A, GBP), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_A_GBP, DC_GBP, RC_A).outputCurrencies(GBP).build());
     assertEquals(LOOKUP_WITH_SOURCE.requirements(ISSUER_B, GBP), FunctionRequirements.builder().observableSource(OBS_SOURCE).valueRequirements(CC_B_GBP, DC_GBP, RC_B).outputCurrencies(GBP).build());
     assertEquals(LOOKUP.requirements(ISSUER_A, USD), FunctionRequirements.builder().valueRequirements(CC_A_USD, DC_USD, RC_A).outputCurrencies(USD).build());
     assertEquals(LOOKUP.requirements(ISSUER_A, GBP), FunctionRequirements.builder().valueRequirements(CC_A_GBP, DC_GBP, RC_A).outputCurrencies(GBP).build());
     assertEquals(LOOKUP.requirements(ISSUER_B, GBP), FunctionRequirements.builder().valueRequirements(CC_B_GBP, DC_GBP, RC_B).outputCurrencies(GBP).build());
     assertThrowsIllegalArg(() => LOOKUP.requirements(ISSUER_A, EUR));
     assertThrowsIllegalArg(() => LOOKUP.requirements(ISSUER_C, USD));
     assertEquals(LOOKUP.creditRatesProvider(MOCK_MARKET_DATA), DefaultLookupCreditRatesProvider.of((DefaultCreditRatesMarketDataLookup)LOOKUP, MOCK_MARKET_DATA));
 }
        //-------------------------------------------------------------------------
        public FunctionRequirements requirements(ISet <IborIndex> indices)
        {
            ISet <IborFutureOptionVolatilitiesId> volIds = new HashSet <IborFutureOptionVolatilitiesId>();

            foreach (Index index in indices)
            {
                if (!volatilityIds.Keys.Contains(index))
                {
                    throw new System.ArgumentException(msgIndexNotFound(index));
                }
                volIds.Add(volatilityIds.get(index));
            }
            return(FunctionRequirements.builder().valueRequirements(volIds).build());
        }
Exemplo n.º 8
0
        //-------------------------------------------------------------------------
        public FunctionRequirements requirements(ISet <SecurityId> securityIds)
        {
            ISet <BondFutureVolatilitiesId> volIds = new HashSet <BondFutureVolatilitiesId>();

            foreach (SecurityId securityId in securityIds)
            {
                if (!volatilityIds.Keys.Contains(securityId))
                {
                    throw new System.ArgumentException(msgSecurityNotFound(securityId));
                }
                volIds.Add(volatilityIds.get(securityId));
            }
            return(FunctionRequirements.builder().valueRequirements(volIds).build());
        }
        //-------------------------------------------------------------------------
        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));
        }
        //-------------------------------------------------------------------------
        public virtual void test_of_map()
        {
            ImmutableMap <Currency, CurveId> discounts = ImmutableMap.of(USD, CURVE_ID_DSC);
            ImmutableMap <Index, CurveId>    forwards  = ImmutableMap.of(USD_LIBOR_3M, CURVE_ID_FWD);
            RatesMarketDataLookup            test      = RatesMarketDataLookup.of(discounts, forwards);

            assertEquals(test.queryType(), typeof(RatesMarketDataLookup));
            assertEquals(test.DiscountCurrencies, ImmutableSet.of(USD));
            assertEquals(test.getDiscountMarketDataIds(USD), ImmutableSet.of(CURVE_ID_DSC));
            assertEquals(test.ForwardIndices, ImmutableSet.of(USD_LIBOR_3M));
            assertEquals(test.getForwardMarketDataIds(USD_LIBOR_3M), ImmutableSet.of(CURVE_ID_FWD));
            assertThrowsIllegalArg(() => test.getDiscountMarketDataIds(GBP));
            assertThrowsIllegalArg(() => test.getForwardMarketDataIds(GBP_LIBOR_3M));
            assertEquals(test.ObservableSource, ObservableSource.NONE);
            assertEquals(test.FxRateLookup, FxRateLookup.ofRates());

            assertEquals(test.requirements(USD), FunctionRequirements.builder().valueRequirements(CURVE_ID_DSC).outputCurrencies(USD).build());
            assertEquals(test.requirements(USD, USD_LIBOR_3M), FunctionRequirements.builder().valueRequirements(CURVE_ID_DSC, CURVE_ID_FWD).timeSeriesRequirements(IndexQuoteId.of(USD_LIBOR_3M)).outputCurrencies(USD).build());
            assertEquals(test.requirements(ImmutableSet.of(USD), ImmutableSet.of(USD_LIBOR_3M)), FunctionRequirements.builder().valueRequirements(CURVE_ID_DSC, CURVE_ID_FWD).timeSeriesRequirements(IndexQuoteId.of(USD_LIBOR_3M)).outputCurrencies(USD).build());
            assertThrowsIllegalArg(() => test.requirements(ImmutableSet.of(USD), ImmutableSet.of(GBP_LIBOR_3M)));

            assertEquals(test.ratesProvider(MOCK_MARKET_DATA), DefaultLookupRatesProvider.of((DefaultRatesMarketDataLookup)test, MOCK_MARKET_DATA));
        }
        //-------------------------------------------------------------------------
        public FunctionRequirements requirements(StandardId legalEntityId, Currency currency)
        {
            CurveId creditCurveId = creditCurveIds.get(Pair.of(legalEntityId, currency));

            if (creditCurveId == null)
            {
                throw new System.ArgumentException(Messages.format("Credit rates lookup has no credit curve defined for '{}' and '{}'", legalEntityId, currency));
            }
            CurveId discountCurveId = discountCurveIds.get(currency);

            if (discountCurveId == null)
            {
                throw new System.ArgumentException(Messages.format("Credit rates lookup has no discount curve defined for '{}'", currency));
            }
            CurveId recoveryRateCurveId = recoveryRateCurveIds.get(legalEntityId);

            if (recoveryRateCurveId == null)
            {
                throw new System.ArgumentException(Messages.format("Credit rates lookup has no recovery rate curve defined for '{}'", legalEntityId));
            }

            return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(creditCurveId, discountCurveId, recoveryRateCurveId)).outputCurrencies(currency).observableSource(observableSource).build());
        }
Exemplo n.º 13
0
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(GenericSecurityPosition position, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            QuoteId id = QuoteId.of(position.SecurityId.StandardId);

            return(FunctionRequirements.builder().valueRequirements(ImmutableSet.of(id)).outputCurrencies(position.Currency).build());
        }
 public FunctionRequirements requirements(TestTarget target, CalculationParameters parameters, ReferenceData refData)
 {
     return(FunctionRequirements.builder().valueRequirements(TestObservableId.of("a"), TestObservableId.of("b")).timeSeriesRequirements(TestObservableId.of("c")).outputCurrencies(Currency.GBP).build());
 }