Ejemplo n.º 1
0
        // collect the set of indices, validating they are IborIndex
        private static ImmutableSet <IborIndex> buildIndices(RateComputation floatingRate)
        {
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            floatingRate.collectIndices(builder);
//JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter:
            return(builder.build().Select(index => typeof(IborIndex).cast(index)).collect(toImmutableSet()));
        }
Ejemplo n.º 2
0
 private static ImmutableSet <string> getEntries(File jarFile, string rootPath)
 {
     ImmutableSet.Builder <string> builder = ImmutableSet.builder();
     try
     {
         using (JarFile jar = new JarFile(jarFile))
         {
             IEnumerator <JarEntry> jarEntries = jar.entries();
             while (jarEntries.MoveNext())
             {
                 JarEntry entry     = jarEntries.Current;
                 string   entryName = entry.Name;
                 if (entryName.StartsWith(rootPath, StringComparison.Ordinal) && !entryName.Equals(rootPath))
                 {
                     string relativeEntryPath = entryName.Substring(rootPath.Length + 1);
                     if (relativeEntryPath.Trim().Length > 0)
                     {
                         builder.add(relativeEntryPath);
                     }
                 }
             }
         }
     }
     catch (Exception e)
     {
         throw new System.ArgumentException(Messages.format("Error scanning entries in JAR file: {}", jarFile), e);
     }
     return(builder.build());
 }
 /// <summary>
 /// Returns the set of indices referred to by the cap/floor.
 /// <para>
 /// A cap/floor will typically refer to one index, such as 'GBP-LIBOR-3M'.
 /// Calling this method will return the complete list of indices.
 ///
 /// </para>
 /// </summary>
 /// <returns> the set of indices referred to by this cap/floor </returns>
 public ImmutableSet <Index> allIndices()
 {
     ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
     builder.add(capFloorLeg.Calculation.Index);
     if (payLeg != null)
     {
         payLeg.collectIndices(builder);
     }
     return(builder.build());
 }
 // collect the set of indices
 private static ImmutableSet <Index> buildIndices(IList <ResolvedSwapLeg> legs)
 {
     // avoid streams as profiling showed a hotspot
     ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
     foreach (ResolvedSwapLeg leg in legs)
     {
         leg.collectIndices(builder);
     }
     return(builder.build());
 }
 // collect the set of currencies
 private static ImmutableSet <Currency> buildCurrencies(IList <ResolvedSwapLeg> legs)
 {
     // avoid streams as profiling showed a hotspot
     ImmutableSet.Builder <Currency> builder = ImmutableSet.builder();
     foreach (ResolvedSwapLeg leg in legs)
     {
         builder.add(leg.Currency);
     }
     return(builder.build());
 }
 // collect the set of indices
 private static ImmutableSet <Index> buildIndices(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
 {
     ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
     builder.add(capFloorLeg.Index);
     if (payLeg != null)
     {
         payLeg.collectIndices(builder);
     }
     return(builder.build());
 }
 // collect the set of currencies
 private static ImmutableSet <Currency> buildCurrencies(ResolvedIborCapFloorLeg capFloorLeg, ResolvedSwapLeg payLeg)
 {
     ImmutableSet.Builder <Currency> builder = ImmutableSet.builder();
     builder.add(capFloorLeg.Currency);
     if (payLeg != null)
     {
         builder.add(payLeg.Currency);
     }
     return(builder.build());
 }
        /// <summary>
        /// Creates a new function which invokes the delegate function, passes the result to the derived function
        /// and returns the combined results.
        /// </summary>
        /// <param name="derivedFunction">  a function which calculates one measure using the measure values calculated by the other function </param>
        /// <param name="delegate">  a function which calculates multiple measures </param>
        internal DerivedCalculationFunctionWrapper(DerivedCalculationFunction <T, R> derivedFunction, CalculationFunction <T> @delegate)
        {
            this.derivedFunction = derivedFunction;
            this.@delegate       = @delegate;

            ISet <Measure> delegateMeasures = @delegate.supportedMeasures();

//JAVA TO C# CONVERTER TODO TASK: There is no .NET equivalent to the java.util.Collection 'containsAll' method:
            this.requiredMeasuresSupported = delegateMeasures.containsAll(derivedFunction.requiredMeasures());
            this.supportedMeasures_Renamed = requiredMeasuresSupported ? ImmutableSet.builder <Measure>().addAll(delegateMeasures).add(derivedFunction.measure()).build() : delegateMeasures;
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Returns the set of rate indices referred to by the CMS.
        /// <para>
        /// The CMS leg will refer to one index, such as 'GBP-LIBOR-3M'.
        /// The pay leg may refer to a different index.
        /// The swap index will not be included.
        ///
        /// </para>
        /// </summary>
        /// <returns> the set of indices referred to by this CMS </returns>
        public ImmutableSet <Index> allRateIndices()
        {
            IborIndex cmsIndex = cmsLeg.UnderlyingIndex;

            if (payLeg == null)
            {
                return(ImmutableSet.of(cmsIndex));
            }
            ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
            payLeg.collectIndices(builder);
            builder.add(cmsIndex);
            return(builder.build());
        }
Ejemplo n.º 10
0
 public ImmutableSet <Currency> allCurrencies()
 {
     if (payLeg == null)
     {
         return(ImmutableSet.of(cmsLeg.Currency));
     }
     else
     {
         ImmutableSet.Builder <Currency> builder = ImmutableSet.builder();
         builder.add(cmsLeg.Currency);
         builder.addAll(payLeg.allCurrencies());
         return(builder.build());
     }
 }
Ejemplo n.º 11
0
        public override ISet <string> tokens(Bean bean)
        {
            if (bean.propertyNames().size() == 1)
            {
                string        singlePropertyName = Iterables.getOnlyElement(bean.propertyNames());
                object        propertyValue      = bean.property(singlePropertyName).get();
                ISet <string> valueTokens        = ValuePathEvaluator.tokens(propertyValue);

                return(ImmutableSet.builder <string>().add(singlePropertyName).addAll(valueTokens).build());
            }
            else
            {
                return(bean.propertyNames());
            }
        }
Ejemplo n.º 12
0
 //-------------------------------------------------------------------------
 public ResolvedSwap resolve(ReferenceData refData)
 {
     // avoid streams as profiling showed a hotspot
     // most efficient to loop around legs once
     ImmutableList.Builder <ResolvedSwapLeg> resolvedLegs = ImmutableList.builder();
     ImmutableSet.Builder <Currency>         currencies   = ImmutableSet.builder();
     ImmutableSet.Builder <Index>            indices      = ImmutableSet.builder();
     foreach (SwapLeg leg in legs)
     {
         ResolvedSwapLeg resolvedLeg = leg.resolve(refData);
         resolvedLegs.add(resolvedLeg);
         currencies.add(resolvedLeg.Currency);
         leg.collectIndices(indices);
     }
     return(new ResolvedSwap(resolvedLegs.build(), currencies.build(), indices.build()));
 }
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <R> java.util.Set<com.opengamma.strata.data.MarketDataId<R>> findIds(com.opengamma.strata.data.MarketDataName<R> name)
        public ISet <MarketDataId <R> > findIds <R>(MarketDataName <R> name)
        {
            ISet <MarketDataId <R> > ids = underlying.findIds(name);

            if (id is NamedMarketDataId)
            {
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.opengamma.strata.data.NamedMarketDataId<?> named = (com.opengamma.strata.data.NamedMarketDataId<?>) id;
                NamedMarketDataId <object> named = (NamedMarketDataId <object>)id;
                if (named.MarketDataName.Equals(name))
                {
                    return(ImmutableSet.builder <MarketDataId <R> >().addAll(ids).add((MarketDataId <R>)id).build());
                }
            }
            return(ids);
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(T target, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            OvernightFuture product = target.Product;
            QuoteId         quoteId = QuoteId.of(target.Product.SecurityId.StandardId, FieldName.SETTLEMENT_PRICE);
            OvernightIndex  index   = product.Index;

            // use lookup to build requirements
            RatesMarketDataLookup ratesLookup = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements  ratesReqs   = ratesLookup.requirements(ImmutableSet.of(), ImmutableSet.of(index));
//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<?>> valueReqs = com.google.common.collect.ImmutableSet.builder<com.opengamma.strata.data.MarketDataId<?>>().add(quoteId).addAll(ratesReqs.getValueRequirements()).build();
            ImmutableSet <MarketDataId <object> > valueReqs = ImmutableSet.builder <MarketDataId <object> >().add(quoteId).addAll(ratesReqs.ValueRequirements).build();

            return(ratesReqs.toBuilder().valueRequirements(valueReqs).build());
        }
        //-------------------------------------------------------------------------
        public virtual FunctionRequirements requirements(CmsTrade trade, ISet <Measure> measures, CalculationParameters parameters, ReferenceData refData)
        {
            // extract data from product
            Cms             product    = trade.Product;
            ISet <Currency> currencies = product.allPaymentCurrencies();
            IborIndex       cmsIndex   = trade.Product.CmsLeg.UnderlyingIndex;
            ISet <Index>    payIndices = trade.Product.allRateIndices();
            ISet <Index>    indices    = ImmutableSet.builder <Index>().add(cmsIndex).addAll(payIndices).build();

            // use lookup to build requirements
            RatesMarketDataLookup    ratesLookup    = parameters.getParameter(typeof(RatesMarketDataLookup));
            FunctionRequirements     ratesReqs      = ratesLookup.requirements(currencies, indices);
            SwaptionMarketDataLookup swaptionLookup = parameters.getParameter(typeof(SwaptionMarketDataLookup));
            FunctionRequirements     swaptionReqs   = swaptionLookup.requirements(cmsIndex);

            return(ratesReqs.combinedWith(swaptionReqs));
        }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Merges multiple sets of requirements into a single set.
        /// </summary>
        /// <param name="requirements">  market data requirements </param>
        /// <returns> a single set of requirements containing all the requirements from the input sets </returns>
        public static MarketDataRequirements combine(IList <MarketDataRequirements> requirements)
        {
            ImmutableSet.Builder <ObservableId> observablesBuilder = ImmutableSet.builder();
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: com.google.common.collect.ImmutableSet.Builder<com.opengamma.strata.data.MarketDataId<?>> nonObservablesBuilder = com.google.common.collect.ImmutableSet.builder();
            ImmutableSet.Builder <MarketDataId <object> > nonObservablesBuilder = ImmutableSet.builder();
            ImmutableSet.Builder <ObservableId>           timeSeriesBuilder     = ImmutableSet.builder();
            ImmutableSet.Builder <Currency> outputCurrenciesBuilder             = ImmutableSet.builder();

            foreach (MarketDataRequirements req in requirements)
            {
                observablesBuilder.addAll(req.observables);
                nonObservablesBuilder.addAll(req.nonObservables);
                timeSeriesBuilder.addAll(req.timeSeries);
                outputCurrenciesBuilder.addAll(req.outputCurrencies);
            }
            return(new MarketDataRequirements(observablesBuilder.build(), nonObservablesBuilder.build(), timeSeriesBuilder.build(), outputCurrenciesBuilder.build()));
        }
Ejemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @SuppressWarnings("unchecked") public <T> java.util.Set<com.opengamma.strata.data.MarketDataId<T>> findIds(com.opengamma.strata.data.MarketDataName<T> name)
        public ISet <MarketDataId <T> > findIds <T>(MarketDataName <T> name)
        {
            return(ImmutableSet.builder <MarketDataId <T> >().addAll(underlying1.findIds(name)).addAll(underlying2.findIds(name)).build());
        }
Ejemplo n.º 18
0
 //-------------------------------------------------------------------------
 /// <summary>
 /// Returns the set of indices referred to by the swap.
 /// <para>
 /// A swap will typically refer to at least one index, such as 'GBP-LIBOR-3M'.
 /// Calling this method will return the complete list of indices, including
 /// any associated with FX reset.
 ///
 /// </para>
 /// </summary>
 /// <returns> the set of indices referred to by this swap </returns>
 public ImmutableSet <Index> allIndices()
 {
     ImmutableSet.Builder <Index> builder = ImmutableSet.builder();
     legs.ForEach(leg => leg.collectIndices(builder));
     return(builder.build());
 }
Ejemplo n.º 19
0
 /// <summary>
 /// Returns the set of currencies referred to by the swap.
 /// <para>
 /// This returns the complete set of currencies for the swap, not just the payment currencies.
 ///
 /// </para>
 /// </summary>
 /// <returns> the set of currencies referred to by this swap </returns>
 public ImmutableSet <Currency> allCurrencies()
 {
     ImmutableSet.Builder <Currency> builder = ImmutableSet.builder();
     legs.ForEach(leg => leg.collectCurrencies(builder));
     return(builder.build());
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Obtains a failure for multiple failure items.
 /// </summary>
 /// <param name="item">  the first failure item </param>
 /// <param name="additionalItems">  additional failure items </param>
 /// <returns> the failure </returns>
 public static Failure of(FailureItem item, params FailureItem[] additionalItems)
 {
     return(of(ImmutableSet.builder <FailureItem>().add(item).add(additionalItems).build()));
 }
Ejemplo n.º 21
0
 /// <summary>
 /// Returns a set containing any Ibor indices in the arguments.
 /// </summary>
 private static ISet <Index> indices(Index index, params Index[] otherIndices)
 {
     // The type parameter is needed for the benefit of the Eclipse compiler
     return(ImmutableSet.builder <Index>().add(index).add(otherIndices).build());
 }