コード例 #1
0
 // extracted to aid inlining performance
 private string msgValueNotFound <T1>(MarketDataId <T1> id)
 {
     return(Messages.format("Market data not found for identifier '{}' of type '{}'", id, id.GetType().Name));
 }
コード例 #2
0
        // semi-parallel gamma PV01 for one scenario
        private CurrencyParameterSensitivities pv01SemiParallelGammaBucketed(ResolvedFraTrade trade, RatesMarketData marketData)
        {
            // find the curve identifiers and resolve to a single curve
            Currency         currency = trade.Product.Currency;
            ISet <IborIndex> indices  = trade.Product.allIndices();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> discountIds = marketData.getLookup().getDiscountMarketDataIds(currency);
            ImmutableSet <MarketDataId <object> > discountIds = marketData.Lookup.getDiscountMarketDataIds(currency);
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet<com.opengamma.strata.data.MarketDataId<?>> forwardIds = indices.stream().flatMap(idx -> marketData.getLookup().getForwardMarketDataIds(idx).stream()).collect(toImmutableSet());
            ImmutableSet <MarketDataId <object> > forwardIds = indices.stream().flatMap(idx => marketData.Lookup.getForwardMarketDataIds(idx).stream()).collect(toImmutableSet());
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> allIds = com.google.common.collect.Sets.union(discountIds, forwardIds);
            ISet <MarketDataId <object> > allIds = Sets.union(discountIds, forwardIds);

            if (allIds.Count != 1)
            {
                throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup refers to more than one: {}", allIds));
            }
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.MarketDataId<?> singleId = allIds.iterator().next();
            MarketDataId <object> singleId = allIds.GetEnumerator().next();

            if (!(singleId is CurveId))
            {
//JAVA TO C# CONVERTER WARNING: The .NET Type.FullName property will not always yield results identical to the Java Class.getName method:
                throw new System.ArgumentException(Messages.format("Implementation only supports a single curve, but lookup does not refer to a curve: {} {}", singleId.GetType().FullName, singleId));
            }
            CurveId curveId = (CurveId)singleId;
            Curve   curve   = marketData.MarketData.getValue(curveId);

            // calculate gamma
            CurrencyParameterSensitivity gamma = CurveGammaCalculator.DEFAULT.calculateSemiParallelGamma(curve, currency, c => calculateCurveSensitivity(trade, marketData, curveId, c));

            return(CurrencyParameterSensitivities.of(gamma).multipliedBy(ONE_BASIS_POINT * ONE_BASIS_POINT));
        }
コード例 #3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @SuppressWarnings("unchecked") @Override public <T> com.opengamma.strata.data.scenario.MarketDataBox<T> getValue(com.opengamma.strata.data.MarketDataId<T> id)
        public override MarketDataBox <T> getValue <T>(MarketDataId <T> id)
        {
            // this code exists to ensure that the error messages from market data building
            // are exposed to users when the failures are not checked

            // a special case for FX rates containing the same currency twice
            if (id is FxRateId && ((FxRateId)id).Pair.Identity)
            {
                FxRateId fxRateId     = (FxRateId)id;
                FxRate   identityRate = FxRate.of(fxRateId.Pair, 1);
                return(MarketDataBox.ofSingleValue((T)identityRate));
            }

            // find the data and check it against the failures
            Optional <MarketDataBox <T> > opt = underlying.findValue(id);

            if (!opt.Present)
            {
                Failure failure = valueFailures.get(id);
                if (failure != null)
                {
                    throw new FailureException(failure);
                }
                throw new MarketDataNotFoundException(Messages.format("Market data not found for identifier '{}' of type '{}'", id, id.GetType().Name));
            }
            return(opt.get());
        }