//------------------------------------------------------------------------- private void assertDefinition(RatesCurveGroupDefinition defn) { assertEquals(defn.Name, CurveGroupName.of("Default")); assertEquals(defn.Entries.size(), 3); assertEquals(defn.SeasonalityDefinitions.size(), 1); assertEquals(defn.SeasonalityDefinitions.get(CurveName.of("USD-CPI")).AdjustmentType, ShiftType.SCALED); RatesCurveGroupEntry entry0 = findEntry(defn, "USD-Disc"); RatesCurveGroupEntry entry1 = findEntry(defn, "USD-3ML"); RatesCurveGroupEntry entry2 = findEntry(defn, "USD-CPI"); CurveDefinition defn0 = defn.findCurveDefinition(entry0.CurveName).get(); CurveDefinition defn1 = defn.findCurveDefinition(entry1.CurveName).get(); CurveDefinition defn2 = defn.findCurveDefinition(entry2.CurveName).get(); assertEquals(entry0.DiscountCurrencies, ImmutableSet.of(Currency.USD)); assertEquals(entry0.Indices, ImmutableSet.of()); assertEquals(defn0.Name, CurveName.of("USD-Disc")); assertEquals(defn0.YValueType, ValueType.ZERO_RATE); assertEquals(defn0.ParameterCount, 17); assertEquals(entry1.DiscountCurrencies, ImmutableSet.of()); assertEquals(entry1.Indices, ImmutableSet.of(IborIndices.USD_LIBOR_3M)); assertEquals(defn1.Name, CurveName.of("USD-3ML")); assertEquals(defn1.YValueType, ValueType.ZERO_RATE); assertEquals(defn1.ParameterCount, 27); assertEquals(entry2.DiscountCurrencies, ImmutableSet.of()); assertEquals(entry2.Indices, ImmutableSet.of(PriceIndices.US_CPI_U)); assertEquals(defn2.Name, CurveName.of("USD-CPI")); assertEquals(defn2.YValueType, ValueType.PRICE_INDEX); assertEquals(defn2.ParameterCount, 2); }
public virtual void test_builder2() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY3)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3); assertEquals(test.findEntry(CurveName.of("Test2")), null); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1); assertEquals(test.findCurveDefinition(CurveName.of("Test2")), null); assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null); }
public virtual void test_builder_seasonality() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addCurve(CURVE_DEFN1, GBP, GBP_LIBOR_1M, GBP_LIBOR_3M).addSeasonality(CURVE_NAME_I, SEASONALITY_ADDITIVE_DEF).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY3)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY3); assertEquals(test.findEntry(CurveName.of("Test2")), null); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1); assertEquals(test.findCurveDefinition(CurveName.of("Test2")), null); assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null); ImmutableMap <CurveName, SeasonalityDefinition> seasonMap = test.SeasonalityDefinitions; assertTrue(seasonMap.size() == 1); assertEquals(seasonMap.get(CURVE_NAME_I), SEASONALITY_ADDITIVE_DEF); }
public virtual void test_builder1() { RatesCurveGroupDefinition test = RatesCurveGroupDefinition.builder().name(CurveGroupName.of("Test")).addDiscountCurve(CURVE_DEFN1, GBP).addForwardCurve(CURVE_DEFN1, GBP_SONIA).addForwardCurve(CURVE_DEFN1, GBP_LIBOR_1W).addForwardCurve(CURVE_DEFN2, GBP_LIBOR_1M, GBP_LIBOR_3M).build(); assertEquals(test.Name, CurveGroupName.of("Test")); assertEquals(test.Entries, ImmutableList.of(ENTRY1, ENTRY2)); assertEquals(test.findDiscountCurveName(GBP), CURVE_NAME1); assertEquals(test.findDiscountCurveName(USD), null); assertEquals(test.findForwardCurveName(GBP_LIBOR_1W), CURVE_NAME1); assertEquals(test.findForwardCurveName(GBP_LIBOR_1M), CURVE_NAME2); assertEquals(test.findForwardCurveName(GBP_LIBOR_6M), null); assertEquals(test.findForwardCurveNames(GBP_LIBOR), ImmutableSet.of(CURVE_NAME1, CURVE_NAME2)); assertEquals(test.findEntry(CurveName.of("Test")), ENTRY1); assertEquals(test.findEntry(CurveName.of("Test2")), ENTRY2); assertEquals(test.findEntry(CurveName.of("Rubbish")), null); assertEquals(test.findCurveDefinition(CurveName.of("Test")), CURVE_DEFN1); assertEquals(test.findCurveDefinition(CurveName.of("Test2")), CURVE_DEFN2); assertEquals(test.findCurveDefinition(CurveName.of("Rubbish")), null); }
public MarketDataRequirements requirements(RatesCurveInputsId id, MarketDataConfig marketDataConfig) { RatesCurveGroupDefinition groupConfig = marketDataConfig.get(typeof(RatesCurveGroupDefinition), id.CurveGroupName); Optional <CurveDefinition> optionalDefinition = groupConfig.findCurveDefinition(id.CurveName); if (!optionalDefinition.Present) { return(MarketDataRequirements.empty()); } CurveDefinition definition = optionalDefinition.get(); return(MarketDataRequirements.builder().addValues(nodeRequirements(ImmutableList.of(definition))).build()); }
public MarketDataBox <RatesCurveInputs> build(RatesCurveInputsId id, MarketDataConfig marketDataConfig, ScenarioMarketData marketData, ReferenceData refData) { CurveGroupName groupName = id.CurveGroupName; CurveName curveName = id.CurveName; RatesCurveGroupDefinition groupDefn = marketDataConfig.get(typeof(RatesCurveGroupDefinition), groupName); Optional <CurveDefinition> optionalDefinition = groupDefn.findCurveDefinition(id.CurveName); if (!optionalDefinition.Present) { throw new System.ArgumentException(Messages.format("No curve named '{}' found in group '{}'", curveName, groupName)); } CurveDefinition configuredDefn = optionalDefinition.get(); // determine market data needs MarketDataBox <LocalDate> valuationDates = marketData.ValuationDate; bool multipleValuationDates = valuationDates.ScenarioValue; // curve definition can vary for each valuation date if (multipleValuationDates) { IList <CurveDefinition> curveDefns = IntStream.range(0, valuationDates.ScenarioCount).mapToObj(valuationDates.getValue).map((LocalDate valDate) => configuredDefn.filtered(valDate, refData)).collect(toImmutableList()); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> requirements = nodeRequirements(curveDefns); ISet <MarketDataId <object> > requirements = nodeRequirements(curveDefns); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, com.opengamma.strata.data.scenario.MarketDataBox<?>> marketDataValues = requirements.stream().collect(toImmutableMap(k -> k, k -> marketData.getValue(k))); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: IDictionary <MarketDataId <object>, MarketDataBox <object> > marketDataValues = requirements.collect(toImmutableMap(k => k, k => marketData.getValue(k))); return(buildMultipleCurveInputs(MarketDataBox.ofScenarioValues(curveDefns), marketDataValues, valuationDates, refData)); } // only one valuation date LocalDate valuationDate = valuationDates.getValue(0); CurveDefinition filteredDefn = configuredDefn.filtered(valuationDate, refData); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Set<com.opengamma.strata.data.MarketDataId<?>> requirements = nodeRequirements(com.google.common.collect.ImmutableList.of(filteredDefn)); ISet <MarketDataId <object> > requirements = nodeRequirements(ImmutableList.of(filteredDefn)); //JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET: //ORIGINAL LINE: java.util.Map<com.opengamma.strata.data.MarketDataId<?>, com.opengamma.strata.data.scenario.MarketDataBox<?>> marketDataValues = requirements.stream().collect(toImmutableMap(k -> k, k -> marketData.getValue(k))); //JAVA TO C# CONVERTER TODO TASK: Most Java stream collectors are not converted by Java to C# Converter: IDictionary <MarketDataId <object>, MarketDataBox <object> > marketDataValues = requirements.collect(toImmutableMap(k => k, k => marketData.getValue(k))); // Do any of the inputs contain values for multiple scenarios, or do they contain 1 value each? bool multipleInputValues = marketDataValues.Values.Any(MarketDataBox.isScenarioValue); return(multipleInputValues || multipleValuationDates?buildMultipleCurveInputs(MarketDataBox.ofSingleValue(filteredDefn), marketDataValues, valuationDates, refData) : buildSingleCurveInputs(filteredDefn, marketDataValues, valuationDate, refData)); }